PEF Portfolio Efficiency Front
- Yardımcı programlar
- Better Trader Every Day
- Sürüm: 1.0
- Etkinleştirmeler: 5
Methodology
PEF implements a portfolio optimization technique using the Pareto algorithm combined with bootstrap simulations. The goal is to compute the efficient frontier of a portfolio consisting of various financial instruments, allowing users to assess the trade-off between risk and return. The methodology involves generating random weight sets for the portfolio, calculating returns and risk metrics (CVaR), and identifying the optimal portfolios that lie on the Pareto front. The user will then select the portfolio weights from the front that satisfy his/her balance of risk aversion and return greed.
Theory
The efficient frontier is a key concept in modern portfolio theory, representing the set of optimal portfolios that offer the highest expected return for a given level of risk. PEF utilizes the following theoretical components:
- Risk: Measured using Conditional Value at Risk (CVaR), which quantifies the expected loss in the worst-case scenarios beyond a specified confidence level.
- Return: The expected return of the portfolio, calculated based on the weighted returns of the individual assets.
- Pareto Optimization: A method to identify portfolios that cannot be improved in one objective (return) without worsening another (risk).
- Bootstrap Simulations: A resampling technique used to estimate the distribution of returns, allowing for more robust risk assessments.
Input Variables
PEF requires the following input variables, which can be configured by the user:
Variable | Type | Description |
---|---|---|
InstrumentsList | String | List of financial instruments in the portfolio (comma-separated). |
historyBars | Integer | Number of historical bars to collect data. |
DataTimeFrame | ENUM_TIMEFRAMES | Time frame for each bar (e.g., daily, weekly). |
SimuDays | Double | Number of simulation days (e.g., 21.6 for one month). |
NumbRandWeightSets | Integer | Number of random weight sets to build the Pareto front. |
useBootstrap | Boolean | Use bootstrap method (true) or Monte Carlo with fixed data returns (false). |
NumberBootstrapTrials | Integer | Number of bootstrap trials to perform. |
InpBeta | Double | Confidence level for CVaR calculation (e.g., 0.95). |
addEqualWeightSet | Boolean | Include equal weight set result in output. |
printSepCovCorr | Boolean | Print covariance and correlation matrices separately. |
printCovCorr | Boolean | Print combined covariance and correlation matrices. |
saveCSVfile | Boolean | Save Pareto front results to a CSV file. |
AddCloud2CSVfile | Boolean | Include results for non-Pareto weight sets in the CSV file. |
ParetoCSVfilename | String | Name of the output CSV file for Pareto front results. |
Output Results
PEF generates the following output results (every thing is printed in the Expert tab of your MT5 terminal):
-
Pareto Front: A table displaying the portfolios on the efficient frontier, including:
- CVaR: Conditional Value at Risk percentage.
- Mean Return: Average return percentage.
- Weights: The allocation of each instrument in the portfolio.
-
Equal Weight Set: If enabled, PEF will also display the results for an equal weight portfolio, which is not necessarily on the Pareto front.
-
Covariance and Correlation Matrices: If enabled, PEF will print the covariance and correlation matrices, providing insights into the relationships between the assets in the portfolio.
-
CSV File: If enabled, the results will be saved to a CSV file, which includes the Pareto front data and optionally the non-Pareto weight sets.
Example Output Format
Portfolio Efficient Front - (Return vs Risk) Pareto for 21.6 trading days:
# CVaR_% Mean_Return_% XAUUSD USDJPY EURUSD
0 1.50 5.00 0.40 0.30 0.30
1 1.20 4.80 0.50 0.25 0.25
1.15 4.00 0.33 0.33 0.33 Equal Weight Case (not on Pareto front)
Notes
- Ensure that the input variables are set according to your portfolio and analysis requirements.
- PEF will print logs during execution, indicating the progress and any issues encountered.
- The output CSV file will be saved typically in the MQL5/Files folder.
A more detailed explanation of PEF input/output is found in this blog page.
*** The Pareto front image below was created inside the CSV file output by PEF using standard spreadsheet manual command, not automatically created by PEF.
All other output can be seen in the Expert tab of the MetaTrader5 terminal.