QuantumLearner commited on
Commit
45df39a
·
verified ·
1 Parent(s): 630182d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -29
app.py CHANGED
@@ -247,7 +247,8 @@ if selected == "Multi-Objective Optimization":
247
  st.markdown("""
248
  ### Multi-Objective Optimization
249
 
250
- Multi-Objective Optimization in portfolio management allows investors to consider multiple objectives simultaneously. This method aims to find the best portfolio by balancing various goals such as maximizing returns, minimizing risk, maximizing the Sharpe ratio, enhancing diversification, and more.
 
251
  """)
252
 
253
  # Expander for Methodology and Formulas
@@ -292,7 +293,7 @@ if selected == "Multi-Objective Optimization":
292
  st.markdown("""
293
  #### Mathematical Optimization Process
294
 
295
- The optimization process involves solving a mathematical problem to find the portfolio weights \( w_i \) that best meet the selected objectives. The optimization problem can be formulated as follows:
296
 
297
  **Objective Function**:
298
  Minimize or maximize a weighted sum of multiple objectives. The overall objective function can be expressed as:
@@ -303,7 +304,7 @@ if selected == "Multi-Objective Optimization":
303
 
304
  st.markdown("""
305
  where:
306
- - \( \lambda_i \) are the weights assigned to each objective \( f_i(\mathbf{w}) \).
307
  - \( \mathbf{w} \) is the vector of portfolio weights.
308
 
309
  **Constraints**:
@@ -323,7 +324,7 @@ if selected == "Multi-Objective Optimization":
323
  st.markdown("""
324
  3. Additional constraints based on user preferences or regulatory requirements can also be included.
325
 
326
- The optimization is performed using numerical methods, such as the Sequential Least Squares Programming (SLSQP) algorithm. This algorithm iteratively adjusts the portfolio weights to find the optimal solution that satisfies the constraints and minimizes (or maximizes) the objective function.
327
 
328
  """)
329
 
@@ -389,7 +390,8 @@ elif selected == "Robust Optimization":
389
  st.markdown("""
390
  ### Robust Optimization
391
 
392
- Robust Optimization aims to create more stable portfolios by incorporating regularization techniques. This method adjusts the covariance matrix to reduce the impact of estimation errors, leading to more reliable portfolios, especially when dealing with noisy or uncertain data.
 
393
  """)
394
 
395
  # Expander for Detailed Methodology and Formulas
@@ -397,11 +399,12 @@ elif selected == "Robust Optimization":
397
  st.markdown("""
398
  #### Concept:
399
 
400
- In finance, the covariance matrix can be unstable due to limited data or market volatility. Robust Optimization addresses this by applying techniques such as covariance shrinkage to produce a more stable covariance matrix.
 
401
 
402
  #### Regularization Technique:
403
 
404
- One common approach in Robust Optimization is the Ledoit-Wolf shrinkage method, which adjusts the sample covariance matrix towards a more structured target, such as the identity matrix. This helps in reducing the estimation error.
405
 
406
  **Covariance Shrinkage**:
407
  """)
@@ -411,14 +414,15 @@ elif selected == "Robust Optimization":
411
 
412
  st.markdown("""
413
  Where:
414
- - \( \Sigma_{\text{shrink}} \) is the shrinkage estimator of the covariance matrix.
415
- - \( \lambda \) is the shrinkage intensity (a value between 0 and 1).
416
  - \( T \) is the target covariance matrix (e.g., identity matrix).
417
  - \( S \) is the sample covariance matrix.
418
 
419
  #### Shrinkage Intensity:
420
 
421
- The shrinkage intensity \( \lambda \) determines the balance between the sample covariance matrix and the target. A higher \( \lambda \) places more weight on the target matrix, while a lower \( \lambda \) places more weight on the sample covariance matrix.
 
422
 
423
  #### Mathematical Optimization Process:
424
 
@@ -452,7 +456,6 @@ elif selected == "Robust Optimization":
452
  - **Performance**: It can improve portfolio performance by avoiding extreme weights that might result from noisy data.
453
  - **Applicability**: Suitable for environments with high market volatility or limited historical data.
454
 
455
- Robust Optimization provides a balanced approach to portfolio management by considering both return and risk while mitigating the impact of estimation errors.
456
  """)
457
 
458
  st.sidebar.header("Optimization Parameters")
@@ -503,7 +506,7 @@ elif selected == "Mean-Variance Optimization":
503
  st.markdown("""
504
  ### Mean-Variance Optimization
505
 
506
- Mean-Variance Optimization, introduced by Harry Markowitz, is a fundamental portfolio optimization method. It aims to balance return and risk by maximizing the Sharpe ratio, thereby finding the portfolio with the best risk-adjusted returns.
507
  """)
508
 
509
  # Expander for Detailed Methodology and Formulas
@@ -511,7 +514,8 @@ elif selected == "Mean-Variance Optimization":
511
  st.markdown("""
512
  #### Concept:
513
 
514
- The Mean-Variance Optimization approach is based on the idea of creating a portfolio that provides the maximum expected return for a given level of risk or, equivalently, the minimum risk for a given level of expected return. This is achieved by selecting the proportions of various assets in the portfolio.
 
515
 
516
  #### Sharpe Ratio:
517
 
@@ -523,9 +527,9 @@ elif selected == "Mean-Variance Optimization":
523
 
524
  st.markdown("""
525
  Where:
526
- - \( \mathbb{E}[R_p] \) is the expected return of the portfolio.
527
- - \( R_f \) is the risk-free rate.
528
- - \( \sigma_p \) is the standard deviation of the portfolio returns.
529
 
530
  #### Mathematical Optimization Process:
531
 
@@ -539,9 +543,9 @@ elif selected == "Mean-Variance Optimization":
539
 
540
  st.markdown("""
541
  Where:
542
- - \( \mathbf{w} \) is the vector of portfolio weights.
543
- - \( \mathbf{\mu} \) is the vector of expected asset returns.
544
- - \( \Sigma \) is the covariance matrix of asset returns.
545
 
546
  **Constraints**:
547
  1. The sum of the portfolio weights must equal 1 (fully invested portfolio):
@@ -639,9 +643,9 @@ elif selected == "Black-Litterman Model":
639
 
640
  st.markdown("""
641
  Where:
642
- - \( \delta \) is the risk aversion coefficient.
643
- - \( \Sigma \) is the covariance matrix of asset returns.
644
- - \( w_{mkt} \) is the vector of market capitalization weights.
645
 
646
  #### Investor Views:
647
 
@@ -654,12 +658,12 @@ elif selected == "Black-Litterman Model":
654
  st.markdown("""
655
  Where:
656
  - \( P \) is the matrix that identifies the assets involved in each view.
657
- - \( \mu \) is the vector of expected returns.
658
  - \( Q \) is the vector of view returns.
659
 
660
  #### Adjusted Expected Returns:
661
 
662
- The adjusted expected returns, \( \mu \), are then calculated as:
663
  """)
664
  st.latex(r"""
665
  \mu = \left( \left( \tau \Sigma \right)^{-1} + P^T \Omega^{-1} P \right)^{-1} \left( \left( \tau \Sigma \right)^{-1} \Pi + P^T \Omega^{-1} Q \right)
@@ -667,8 +671,8 @@ elif selected == "Black-Litterman Model":
667
 
668
  st.markdown("""
669
  Where:
670
- - \( \tau \) is a scalar representing the uncertainty in the prior estimates.
671
- - \( \Omega \) is the diagonal covariance matrix of the error terms in the views.
672
 
673
  #### Optimization:
674
 
@@ -702,7 +706,7 @@ elif selected == "Black-Litterman Model":
702
  - **Stability**: Produces more stable and intuitive expected returns than traditional mean-variance optimization.
703
  - **Theoretical Foundation**: Combines the principles of modern portfolio theory with practical investor insights.
704
 
705
- The Black-Litterman Model is a strong tool for integrating subjective views with market data, providing a balanced approach to portfolio optimization.
706
  """)
707
 
708
  st.sidebar.header("Optimization Parameters")
@@ -777,7 +781,8 @@ elif selected == "Hierarchical Risk Parity":
777
  st.markdown("""
778
  ### Hierarchical Risk Parity (HRP)
779
 
780
- Hierarchical Risk Parity (HRP) is a method that groups assets into clusters based on their correlations and then allocates risk evenly among these clusters. This approach aims to improve diversification and reduce risk concentration in the portfolio.
 
781
  """)
782
 
783
  # Expander for Detailed Methodology and Formulas
@@ -806,7 +811,7 @@ elif selected == "Hierarchical Risk Parity":
806
 
807
  st.markdown("""
808
  Where:
809
- - \( \rho_{i,j} \) is the correlation coefficient between assets \( i \) and \( j \).
810
 
811
  #### Quasi-Diagonalization:
812
 
 
247
  st.markdown("""
248
  ### Multi-Objective Optimization
249
 
250
+ Multi-Objective Optimization in portfolio management allows investors to consider multiple objectives simultaneously.
251
+ This method aims to find the best portfolio by balancing various goals such as maximizing returns, minimizing risk, maximizing the Sharpe ratio, enhancing diversification, and more.
252
  """)
253
 
254
  # Expander for Methodology and Formulas
 
293
  st.markdown("""
294
  #### Mathematical Optimization Process
295
 
296
+ The optimization process involves solving a mathematical problem to find the portfolio weights \( wi \) that best meet the selected objectives. The optimization problem can be formulated as follows:
297
 
298
  **Objective Function**:
299
  Minimize or maximize a weighted sum of multiple objectives. The overall objective function can be expressed as:
 
304
 
305
  st.markdown("""
306
  where:
307
+ - \( \lambda_i \) are the weights assigned to each objective.
308
  - \( \mathbf{w} \) is the vector of portfolio weights.
309
 
310
  **Constraints**:
 
324
  st.markdown("""
325
  3. Additional constraints based on user preferences or regulatory requirements can also be included.
326
 
327
+ The optimization is performed using numerical methods, i.e. using the Sequential Least Squares Programming (SLSQP) algorithm. This algorithm iteratively adjusts the portfolio weights to find the optimal solution that satisfies the constraints and minimizes (or maximizes) the objective function.
328
 
329
  """)
330
 
 
390
  st.markdown("""
391
  ### Robust Optimization
392
 
393
+ Robust Optimization aims to create more stable portfolios by incorporating regularization techniques.
394
+ This method adjusts the covariance matrix to reduce the impact of estimation errors, noisy or uncertain data.
395
  """)
396
 
397
  # Expander for Detailed Methodology and Formulas
 
399
  st.markdown("""
400
  #### Concept:
401
 
402
+ The covariance matrix can be unstable due to limited data or market volatility.
403
+ Robust Optimization addresses this by applying techniques such as covariance shrinkage to produce a more stable covariance matrix.
404
 
405
  #### Regularization Technique:
406
 
407
+ One common approach in Robust Optimization is the Ledoit-Wolf shrinkage method, which adjusts the sample covariance matrix towards a more structured target, such as the identity matrix.
408
 
409
  **Covariance Shrinkage**:
410
  """)
 
414
 
415
  st.markdown("""
416
  Where:
417
+ - \( Σ shrink \) is the shrinkage estimator of the covariance matrix.
418
+ - \( λ \) is the shrinkage intensity (a value between 0 and 1).
419
  - \( T \) is the target covariance matrix (e.g., identity matrix).
420
  - \( S \) is the sample covariance matrix.
421
 
422
  #### Shrinkage Intensity:
423
 
424
+ The shrinkage intensity \( λ \) determines the balance between the sample covariance matrix and the target.
425
+ A higher \( λ \) places more weight on the target matrix, while a lower \( λ \) places more weight on the sample covariance matrix.
426
 
427
  #### Mathematical Optimization Process:
428
 
 
456
  - **Performance**: It can improve portfolio performance by avoiding extreme weights that might result from noisy data.
457
  - **Applicability**: Suitable for environments with high market volatility or limited historical data.
458
 
 
459
  """)
460
 
461
  st.sidebar.header("Optimization Parameters")
 
506
  st.markdown("""
507
  ### Mean-Variance Optimization
508
 
509
+ Mean-Variance Optimization, introduced by Harry Markowitz aims to balance return and risk by maximizing the Sharpe ratio, thereby finding the portfolio with the best risk-adjusted returns.
510
  """)
511
 
512
  # Expander for Detailed Methodology and Formulas
 
514
  st.markdown("""
515
  #### Concept:
516
 
517
+ The Mean-Variance Optimization approach is based on the idea of creating a portfolio that provides the maximum expected return for a given level of risk or, equivalently, the minimum risk for a given level of expected return.
518
+ This is achieved by selecting the proportions of various assets in the portfolio.
519
 
520
  #### Sharpe Ratio:
521
 
 
527
 
528
  st.markdown("""
529
  Where:
530
+ - \( E[Rp] \) is the expected return of the portfolio.
531
+ - \( Rf \) is the risk-free rate.
532
+ - \( σp \) is the standard deviation of the portfolio returns.
533
 
534
  #### Mathematical Optimization Process:
535
 
 
543
 
544
  st.markdown("""
545
  Where:
546
+ - \( w \) is the vector of portfolio weights.
547
+ - \( μ \) is the vector of expected asset returns.
548
+ - \( ∑ \) is the covariance matrix of asset returns.
549
 
550
  **Constraints**:
551
  1. The sum of the portfolio weights must equal 1 (fully invested portfolio):
 
643
 
644
  st.markdown("""
645
  Where:
646
+ - \( δ \) is the risk aversion coefficient.
647
+ - \( Σ \) is the covariance matrix of asset returns.
648
+ - \( wmkt \) is the vector of market capitalization weights.
649
 
650
  #### Investor Views:
651
 
 
658
  st.markdown("""
659
  Where:
660
  - \( P \) is the matrix that identifies the assets involved in each view.
661
+ - \( μ \) is the vector of expected returns.
662
  - \( Q \) is the vector of view returns.
663
 
664
  #### Adjusted Expected Returns:
665
 
666
+ The adjusted expected returns, \( μ \), are then calculated as:
667
  """)
668
  st.latex(r"""
669
  \mu = \left( \left( \tau \Sigma \right)^{-1} + P^T \Omega^{-1} P \right)^{-1} \left( \left( \tau \Sigma \right)^{-1} \Pi + P^T \Omega^{-1} Q \right)
 
671
 
672
  st.markdown("""
673
  Where:
674
+ - \( τ \) is a scalar representing the uncertainty in the prior estimates.
675
+ - \( Ω \) is the diagonal covariance matrix of the error terms in the views.
676
 
677
  #### Optimization:
678
 
 
706
  - **Stability**: Produces more stable and intuitive expected returns than traditional mean-variance optimization.
707
  - **Theoretical Foundation**: Combines the principles of modern portfolio theory with practical investor insights.
708
 
709
+ The Black-Litterman Model is a tool for integrating subjective views with market data.
710
  """)
711
 
712
  st.sidebar.header("Optimization Parameters")
 
781
  st.markdown("""
782
  ### Hierarchical Risk Parity (HRP)
783
 
784
+ Hierarchical Risk Parity (HRP) is a method that groups assets into clusters based on their correlations and then allocates risk evenly among these clusters.
785
+ This approach aims to improve diversification and reduce risk concentration in the portfolio.
786
  """)
787
 
788
  # Expander for Detailed Methodology and Formulas
 
811
 
812
  st.markdown("""
813
  Where:
814
+ - \( ρ_{i,j} \) is the correlation coefficient between assets \( i \) and \( j \).
815
 
816
  #### Quasi-Diagonalization:
817