FTEC2101/ESTR2520 Optimization Methods Spring 2025
Project Specification – Portfolio Optimization using CVaR Risk
Last Updated: May 4, 2025, Deadline: May 12, 2025, 23:59 (HKT)
So far in FTEC2101/ESTR2520, we have learnt (or will learn) a number of concepts about optimization meth- ods, ranging from the simplex method for linear programming, modeling techniques for integer programming, convex optimization, gradient/Newton methods for unconstrained optimization, KKT conditions, SOCP for- mulation, etc. While they are important, it is important to remember that optimization methods are practical tools for solving real world problems. The aim of the current project is to highlight on such practical aspects of optimization.
This project implements practical solutions for portfolio optimization using Julia1. We will explore various aspects of portfolio design and more importantly, implement these ideas on a real-world dataset.
Dataset & Folder Setting In this project, we will use a dataset gathered from the NYSE market with stock prices of 485 stocks from the S&P500 index that were traded between 2018 and 2023. To prepare your working environment, please retrieve from Blackboard the notebook template ftec2101 project 2025.ipynb, a helper function reusablefunc.jl, and the dataset archives full data final.zip, group i.zip (where i ∈ {1, …, 7} – depending on your assigned subgroup).
As usual, it is a good habit to move the files to a working directory of your choice, and unzip the archives. Your working directory shall contain the following content:
The folders group i, full data final contain essentially the same content of the stock data of 20 stocks and 485 stocks, respectively. The latter contains the complete dataset that includes the former, which will be used
1As an alternative, you are welcomed to use Python with optimization modeling packages supporting SOCP and MI-NLP such as cvxpy. However, in the latter case, you have to notify the instructor about the choice and the plan on how you wish to accomplish the project on or before Apr 28, 2025, i.e., around two weeks before the deadline.
FTEC2101/ESTR2520 Project 2 in the second part of the project. Furthermore, for each stock, the dataset is split a training dataset and
testing dataset, as follows:
• For compulsory task, * train.csv – stock prices for training. • For compulsory task, * test.csv – stock prices for testing.
• For competitive task, * train.csv – stock prices for training. • For competitive task, * test.csv – stock prices for testing.
1.1 Compulsory Tasks (50%)
Consider n stocks in the market that can be invested. We first recall the standard Markowitz Mean-variance Portfolio Optimization problem:
i t i ij t i i j j i
min p⊤ Σp p∈Rn
s.t. 1⊤p = B,p⊤r ̄ = Rd,p ≥ 0,
where Rd > 0 is the desired expected return, B > 0 is a fixed budget, and 1 is an n-dimensional all-one vector.
We have defined the covariance matrix and expected return vector for each stock respectively as: ρρ···ρ r ̄
ρ21 ρ22 ρ2n r ̄2
Σ= . .. . , r ̄= . (1.2)
…. ρn1 ρn2 · · · ρnn r ̄n
such that for any i, j = 1, …, n, it holds
r ̄ =E[R(t)], ρ =E[(R(t)−r ̄)(R(t)−r ̄)], R(t)=closingpriceondayt−openingpriceondayt,
opening price on day t i.e., Ri(t) is the return of stock i on day t as they were defined during the lectures.
Task 1: (5%)
In this question, we first perform some basic analysis on the Portfolio Optimization problem.
(a) Derive the KKT conditions for (1.1).
(b) Consider the special case that n = 2 (only 2 stocks) with Rd = B > 0 and the covariance/expected return be given by
1 σ1 0 r ̄=1,Σ=01 where0<σ1≤1.
Denote the solution found in part (a) as p⋆ = (p⋆1, p⋆2). Find the optimal portfolio in terms of σ1 and discuss the behavior as σ1 → 0.
Notice that in (1.1), the risk has been taken as the variance of the return given by the portfolio. The variance equally measures the upside risk and downside risk2. In this way, minimizing the objective function shall penalize any deviation of the selected portfolio from the expected return.
2Upside risk is the sum of excessive actual return compared to the expected one; downside risk is the sum of insufficient actual return compared to the expected one. Usually, upside risk is not a risk as you actually make more profit than expected; see https://en.wikipedia.org/wiki/Upside_risk.
FTEC2101/ESTR2520 Project 3
Considering the above variance based risk measure may not be the most desirable as it equally penalizes the upside and downside risks. Towards this end, this project shall study an alternative risk measure given by the Conditional Value-at-Risk (CVaR) [Rockafellar et al., 2000]. For the portfolio optimization problem, the CVaR is defined as the conditional expected value of the loss exceeding a certain threshold, i.e.,
CVaRα(−p⊤Rt) = E[−p⊤Rt | − p⊤Rt ≥ VaRα], where VaRα is the Value-at-Risk at level α and
R1(t) R2(t)
Rt = . .
is the instantaneous return vector. The CVaR is a measure of the average loss of the portfolio when the loss exceeds the VaR level. The VaR is the α-quantile, α ∈ [0, 1), of the loss distribution, i.e., the maximum loss that can occur with a probability of at most α. In a nutshell, the CVaR risk measures is a conservative one which focuses on bounding the ‘tail’ risk of a portfolio.
Rockafellar et al. [2000] has proven the following equivalence:
⊤1⊤ CVaRα(−p Rt)=min β+ E[max{−p Rt−β,0}] ,
Since evaluating the expectation is still difficult, we can approximate the above using the sample average:
CVaR (−p⊤R)=min β+ max{−p⊤R −β,0} , (1.4)
\αtβ∈R1−αT t t=1
Now, complete the following task.
Task 2: (10%)
(a) Formulate the portfolio optimization problem to determine p ∈ Rn with the following requirements: • The objective is to minimize the approximate CVaR (c.f. (1.4)) associated with the portfolio,
β + 1 − α T
max{−p⊤Rt − β, 0}
• It is required that the expected return is above or equal a given threshold $Rd, i.e.,
p r ̄ ≥ R .
FTEC2101/ESTR2520 Project 4
• The sum of net change in portfolio value must be less than or equal to the budget $B, i.e., Pni=1 pi ≤ B.
• The portfolio must be non-negative, i.e.,
pi ≥ 0, i = 1, ..., n.
You may assume that for any t = 1, . . . , T , the historical return data Rt is given and the quantile α is a given parameter. Meanwhile, both β, p shall be the decision variables.
Furthermore, show that the above problem can be formulated as a Linear Program (LP) problem in standard form.
(b) Formulateamixed-integerlinearprogram(MILP)tosolvetheprobleminpart(a)withtheadditional constraint:
• The number of stocks to be invested is greater than or equal to m, where m ≤ n is an integer. Here, a stock is said to be invested if pi ≥ ξB, where ξ < 1 is a given constant.
(c) Additionally, consider the Markowitz mean-variance portfolio optimization problem (1.1) with the constraint:
• The number of stocks to be invested is greater than or equal to m, where m ≤ n is an integer. Here, a stock is said to be invested if pi ≥ ξB, where ξ < 1 is a given constant.
i.e., as in part (b). Formulate the problem as a mixed-integer nonlinear program (MINLP).
Computational The optimization problems formulated in Task 2 are MIPs/LPs which do not admit a closed form solution. We next focus on solving these portfolio optimization problems numerically on computers and evaluate their performance subsequently.
Data Preprocessing. The required data – expected return r ̄ , and covariance between stocks Σ = [ρ ] –
can be approximated from historical data as:
i T i ij T i T i j T j
symbolsr ̄ = 1 PT R(t)andΣ=[ρ ] . i T t=1 i ijn×n
In the following tasks, we focus on a small set of n = 20 stocks (from group i) as our first exploration:
Portfolio Optimization. In the following tasks, you will implement the different portfolio optimization for- mulations that you have completed in Task 2 as well as the standard Markowitz Portfolio Optimization formulation. They will be implemented into Julia and their performances will be evaluated.
R(t′) R(t)−
R(t′) , ∀i,j=1,...,n.
t=1 t=1 t′=1 t′=1
With a slight abuse of notations, we shall refer the approximated expected return and covariance by the same
Task 3: Warmup Exercise (2.5%)
(a) Inspect the dataset, e.g., by plotting the daily return over time of around 3-4 stocks of your choice. Remark: The program template has provided the relevant helper codes for this task.
FTEC2101/ESTR2520 Project 5 Suppose the given portfolio is wi = 1, i = 1, ..., n. We now implement the two formulations in Tasks 2, as well
as the original mean-variance Markowitz portfolio optimization.
Task 4: Optimization-based Formulation (20%)
(a) Implement an SOCP program for minimizing the risk 12p⊤Σp, i.e., the Markowitz mean-variance optimization, as in (1.1); check out Lecture Notes to see how to write the SOCP program. Use the following parameters:
B=10, Rd =0.01B You may use the solver ECOS in JuMP for the SOCP.
(b) Implement the LP from Task 2-a with the following parameters: B=10, Rd =0.01B, α=0.95
You may use the solver GLPK in JuMP for the LP.
(c) Implement the mixed-integer program from Task 2-b with the following parameters:
B=10, Rd =0.01B, α=0.95, ξ=0.01, m=5. You may use the solver GLPK in JuMP for the MI-LP.
(d) Implement the mixed-integer program from Task 2-c with the following parameters: B=10, Rd =0.01B, ξ=0.01, m=5.
You may use the solver Juniper in JuMP for the MI-NLP.
Next, we will compare and evaluate the performance of the portfolios found in the above tasks. A commonly used metric is the Sharpe ratio3 [Fabozzi et al., 2007]:
r ̄⊤ p test
notice that the expected return r ̄test and covariance Σtest shall be calculated using similar formula as (1.5) but with the testing data that are not seen during the portfolio optimization. An alternative measure that highlights on the tail-risk, the following measure which is akin to the Calmar ratio is counted
Sharpe ratio = pp⊤Σtestp (1.6)
R-R ratio = test , (1.7)
−mint∈Ttest Rt⊤p
note that the denominator evaluates the worst loss of the portfolio in the testing data.
If p = 0, then we define both ratios as zero. For your convenience, we have prepared a function that are included with the preloaded file reusablefunc.jl and it can be called as performance testdata(path, p), with the inputs as
• path – the relative path in which the testing data are stored. • p – the portfolio p.
3Assuming that the risk free asset has zero return.
FTEC2101/ESTR2520 Project 6 The function will report (i) the Sharpe ratio of the portfolio p, (ii) the return-risk ratio, (ii) the expected
return, (iii) the variance, and (iv) the total number of selected stocks.
Task 5: Comparing the performances of the portfolio found (5%)
(a) Plot and compare the portfolios, i.e., the budget allocated to each stock, found using the approaches above. Also compare the expected return and variance of each stock on the training data side-by- side with the portfolio. Comment on the differences between the portfolios obtained. Note: try to adjust the line widths, colors, etc., of the portfolios found to make the plot more presentable.
(b) Compare the portfolios found in Task 4 on the testing data under the given parameters, (i) the Sharpe ratio of the portfolio p, (ii) the expected return, (iii) the variance, and (iv) the total portfolio value. Comment on the differences in performance between the portfolios obtained.
Notice that the plot in part (a) of Task 5 may look like:
which shows the portfolio optimized for each stock, compared with the expected return and variance/risk. For part (b), you may also observe the following output using the helper code provided4:
4CAUTION: the performance metrics (e.g., Sharpe ratio) are calculated from a different set of stocks which is different from those used by the students.
FTEC2101/ESTR2520 Project 7 Note that the testing set contains data that have not been seen by the optimization problem. Don’t be
surprised if they display worse performance than you expected.
Pareto Optimality. A useful interpretation for the optimization-based portfolio strategies is that they attempt to find the best trade-off between expected return and risk. In particular, an optimized portfolio should be pareto optimal such that at any given desired return, there is no better portfolio with lower risk, and vice versa. To visualize this behavior, an intuitive way is to plot the Pareto front of the optimized portfolio, e.g.,
In the above, the blue curve is the Pareto front of an optimization-based portfolio strategy that visualizes the risk of the portfolio at each desired return, while the purple dots represents the the return/risk of investing in each individual stock considered by the portfolio. Observe that the optimized strategy always find a better tradeoff than investing in individual stock. The following task aims to visualize the Pareto front of the portfolios using different risk measures.
Task 6: Pareto Optimality (7.5%)
CAUTION: this task is slightly more challenging and requires some coding skills.
(a) Taking the risk measure as the variance over the training data. Plot the Pareto front of the portfolios found by (a) Markowitz Mean-Variance Portfolio Optimization (1.1), and (b) the CVaR formulation in Task 2-a. Note that we shall
fix B = 1 and consider the equality constraint of Pn p r ̄ = R . i=1ii d
Moreover, plot the return/risk of investing in each stock as dots on the same plot.
(b) Repeat part (a) while taking the risk measure as the CVaR over the training data with α = 0.95.
(c) Discuss the differences between the Pareto front of the portfolios found by Markowitz and CVaR optimization.
You may use the following procedures:
1. Write a for-loop to vary the expected return Rd from −1 to 1 with some steps, e.g., of 0.01. For
each Rd, solve the two optimization problems and record the risk of the portfolio found.
(Note: (i) when evaluating the CVaR risk for the portfolio found by Markowitz, you may need to
Programming Help
FTEC2101/ESTR2520 Project 8
solve an LP problem to find the CVaR risk., (ii) be careful that for some values of Rd, the CVaR / Markowitz optimization may become infeasible and these cases should be ignored.).
2. Plot the vectors of the expected return against the risk of the portfolios found.
3. Write a for-loop for each stock, and plot the return/risk of investing in each stock as dots on the same plot. (Note: you may need to solve an LP problem when evaluting the CVaR for each stock.)
An example output for the Pareto front plot w.r.t. variance risk measure is as follows:
1.2 Competitive Tasks (30%)
The goal of this competitive task is to implement your own (approximate) solver to the portfolio optimization problem, without relying on JuMP and its optimizers such as GLPK, ECOS. To motivate, we observe that while optimization packages such as JuMP are very convenient to use, yet these solvers are limited by their high complexity for large-scale problems when n, T ≫ 1.
To prepare for this task, we adopt two modifications on the CVaR portfolio optimization to search for a portfolio with the best performance and lowest cost, as follows:
• In Task 2-a, you should have formulated a portfolio optimization problem in the following form (before you transform the problem into a LP):
min β + max{−p⊤Rt − β, 0}
β,p∈Rn 1−αT
s.t. f1(p) ≤ 0, f2(p) ≤ 0, pi ≥ 0, i = 1, …, n,
where f1, f2 are some functions of the candidate portfolio p ∈ Rn. A heuristic for solving the above problem is to consider the following approximation:
min β + β,p∈Rn
max{−p⊤Rt − β, 0} + γf1(p) + υf2(p)
s.t. 0≤pi ≤1, i=1,…,n,
for some γ, υ > 0 as regularization parameters. Note we have included an upper bound on each pi.
FTEC2101/ESTR2520 Project 9
This method is called the penalty method which adds constraints to the objective function by imposing a cost to infeasible points [cf. similar idea was used in the Big-M simplex method]. For instance, since we desired that f1(p) ≤ 0 in the original formulation, the approximation shall impose a positive cost if f1(p) > 0 [recall that γ > 0]. Moreover, intuitively, increasing γ (resp. υ) ensures that the constraint f1(p) ≤ 0 (resp. f2(p) ≤ 0) is enforced.
• An issue with max{x, 0} function is that the latter is not differentiable at x = 0. Our second modification is to approximate the max function with the log-exponential function (see [Tong et al., 2010]), parameterized by δ > 0, as:
hδ(x) = δ log(1 + exp(x/δ)) and we now approximate the optimization problem (1.8) by
min β + β,p∈Rn
hδ(−p⊤Rt − β) + γf1(p) + υf2(p) s.t. 0≤pi ≤1, i=1,…,n.
Finally, observe that (1.8) is now an optimization problem with a ‘simple’ constraint: X ={p∈Rn :1≥pi ≥0, i=1,…,n},
where X is a convex set, and the projection into this set can be easily calculated. In other words, with a differentiable and convex f1,f2, it is easy to apply methods such as projected gradient, conditional gradient methods to solve (1.8); see Appendix A. This is the goal of the main task in this section:
Task 7: Customized Solver for Portfolio Optimization (30%)
Using the complete dataset with the training data from n = 485 stocks stored in /full data final/, recorded over T = 1000 days (roughly) between 2018 to 2022. Implement a projection-based iterative algorithm to tackle (1.8) with a choice of approximation (e.g., log-exp function (1.9)) approximating the CVaR risk minimization problem in Task 2. Notice that the budget constraint B and expected return goal Rd are irrelevant in this task as these additive constants in the constraints shall have no effects on (1.8). As a recommendation, you can apply the projected gradient descent method using a constant step size.
While we have provided some suggested values in the helper code. You may need to tune the parameters υ, γ, δ, α, as well as the step size, to achieve the best result.
For the iterative algorithm applied, you are required to initialize by p0 = 0 and the algorithm has to run for at least 1000 iterations (and at most 50000 iterations). You are encouraged to try more than one algorithm (which will be counted towards the ‘innovation’ section in the Report assessment).
Assessment You will receive a maximum of 7.5% for implementing at least one numerical algorithm (e.g., projected gradient) correctly, together with (i) plotting the trajectory of the algorithm is show that the objective value in (1.8) is decreasing and providing comments on the algorithm(s) implemented, (ii) showing the derivations on why the implemented algorithm can be used to solve/tackle (1.8).
We also have a testing data of 100 days of the same stocks taken in 2023. The remainder of your marks (i.e.,
程序代写 CS代考 加微信: cstutorcs
FTEC2101/ESTR2520 Project 10 22.5%) will be calculated according to the following formula:
Score = 5% × min{0.1, Your Sharpe Ratio (testing data)} min{0.1, Highest Sharpe Ratio (testing data)}
+ 7.5% × min{10, Your R-R Ratio (testing data)} min{10, max{Highest R-R Ratio (testing data)}}
+ 2.5% × × min{0.2, Your Sharpe Ratio (training data)} (1.11) min{0.2, max{Highest Sharpe Ratio (training data)}}
+ 2.5% × min{1000, Your R-R Ratio (training data)} min{1000, Highest R-R Ratio (training data)}
+ 5% × max{10, Lowest number of selected stocks} . max{10, Your number of selected stocks}
Note that the score can be negative if the return of your portfolio (on testing/training data) is negative. For the R-R ratio on test data (resp. training data), if your portfolio is non-zero and achieves no loss in the given stock return data in Ttest (resp. Ttrain), then the respective R-R ratio will be counted as +∞.
If you have tried more than one algorithm and/or more than one set of parameters, you can select only one set of portfolio for the competition. Please indicate which set of portfolio is selected in your report and include that in the submission of your program files. Moreover, please observe the following rule:
• You are not allowed to directly optimize on the testing set data. In other words, your iterative algorithm should not ‘touch’ any data file with the suffix test.csv as you are not supposed to see the ‘future’ when investing. Your score in (1.11) will be set to zero if we detect such ‘cheating’ behavior. However, you can use the function performance testdata and performance traindata to evaluate your portfolio as many times as you like.
• Your selected algorithm for the competition must be deterministic. In other words, you may not use stochastic algorithm such as stochastic gradient descent (SGD) for the competition. That being said, you are still encouraged to try such algorithms as an additional task which may be counted towards the ‘innovation’ section.
If you have questions about the rules, please do not hesitate to consult the instructor at or the TA or ask questions on Piazza.
1.3 Report (20%)
You are required to compile a project report with detailed answers, in your own language, to the questions posed in Task 1 to Task 7. Please keep in mind that you’re writing a report instead of an assignment’s solution, whose intended readers are students who have learnt similar knowledge as you do. You may structure the report according to the order of the tasks, for instance:
1. Background and Introduction — In this section, you can briefly introduce the problem, e.g., explain- ing the goal of portfolio design, discussing the role of optimization methods in portfolio design.
FTEC2101/ESTR2520 Project 11
2. Model and Theory — In this section, you can discuss how the portfolio design problem is modeled as
optimization problems. More specifically,
– You shall begin by discussing the formulation (1.1) and then answer the questions in Task 1. – Next, you can describe the optimization models and then answer Tasks 2.
3. Experiments — In this section, you describe the experiments conducted to test your formulation, i.e., – You shall first describe the dataset by answering Task 3. In addition, it is helpful to describe a few
meta-data regarding the dataset, e.g., from when to when the stock price data is collected.
– Then, you can describe the experiments for each of the 4 formulations, by answering Tasks 4. – Finally, you can compare the formulations by answering Task 5 and Task 6.
4. Competitive Task — In this section, you describe the custom solver you built to solve the large-scale portfolio design problem, i.e.,
– You shall first describe the approximation technique as laid out in the discussion of (1.8), (1.9).
– Then, you shall describe the iterative algorithm you have derived in Task 7.
– Apply the iterative algorithm on the complete training dataset and show the objective value vs. iteration number. Discuss whether the algorithm converges and report on the performance of the designed portfolio (e.g., the Sharpe ratio, etc..).
5. Conclusions — In this section, you shall summarize the findings in the project, and discuss various aspects that can be improved with the formulation, etc..
Throughout the report, please feel free to write your answer which involves equations (e.g., Task 1-2) on a paper and scan it to your Word/PDF report as a figure. For Task 3 to 7, please include all the plots and comments as requested. For Task 7, please indicate the required metrics in the scoring formula (1.11) of the selected solution.
The program code has to be submitted separately. You may use excerpts from the program codes only if you find it helpful for explaining some of the concepts.
Lastly, you are welcomed to use online resources when preparing the project. However, you must give proper references for every sources that are not your original creation.
Assessment Here is a breakdown of the assessment metric for the report writing component.
• (10%) Report Writing: A project report shall be readable to a person with knowledge in optimization (e.g., your classmates in FTEC2101/ESTR2520). Make sure that your report is written with clarity, and more importantly, using your own language!
• (10%) Innovation: You can get innovation marks if you include extra experiments, presentations, etc.. that are relevant to the project (with sufficient explanations); see Appendix A for some recom- mendations.
Computer Science Tutoring
FTEC2101/ESTR2520 Project 12 1.4 Submission
This is an individual project. While discussions regarding how to solve the problems is encouraged, students should answer the problems on their own (just like your HWs). The deadline of submission is May 12, 2025, 23:59 (HK time). Please submit a single zip file with the following content:
• Your Project Report in PDF format to GradeScope.
• Your Program Codes [either in Jupyter notebook (.ipynb), or Julia code (.jl)] to Blackboard.
In addition, all project reports shall be submitted to VeriGuide for plagiarism check. (The submission to VeriGuide needs not follow the strict deadline of the main submission, e.g., it can be done within a reasonable amount of time, e.g., on or before May 15, 2025.)
A On the Use of Generative AI Tools
We are following Approach 3 as listed in the University’s Guideline on the matter: https://www.aqs. cuhk.edu.hk/documents/A-guide-for-students_use-of-AI-tools.pdf — Use of AI tools is allowed with explicit acknowledgement and proper citation. In short, you are allowed to use generative AI tools to assist you, provided that you give explicit acknowledgement to the use of such tools, e.g., you may include:
The following section has been completed with the aid of ChatGPT.
Failure to do so will constitute act of academic dishonesty and may result in failure of the course and/or other penalties; see https://www.cuhk.edu.hk/policy/academichonesty/. Below we list a number of advices for the do’s and don’ts using AI tools:
• DO’s: You may use AI tools for polishing your writeups, e.g., to correct grammatical mistakes, typos, or summarizing long/complicated paragraphs, etc. The results are usually quite robust especially for improving the writings from less experienced writers. Of course, you are responsible for the integrity of the edited writing, e.g., check if the AI tools have distorted the meaning of your original writeups or not.
• DON’Ts: You should not ask AI tools to solve mathematical questions. Not only this will spoil the purpose of learning, AI tools do a notoriously bad job for tasks involving facts and mathematical/logical reasoning. Worst still, they tend to produce solutions that sound legit but are completely wrong.
• DON’Ts: You should not ask AI tools to write the entire project (report) for you. Likewise, AI tools are notoriously bad at creating (technical and logical) content. They tend to produce writings that sound legit but are completely illogical.
We believe that when properly used, these generative AI tools can be helpful in improving students’ learning experience. In fact, you are even encouraged to try them out during your learning. Nevertheless, we emphasize again that you have to provide explicit acknowledgement in your submission if you have used any generative AI tools to assist you in this course.
FTEC2101/ESTR2520 Project 13 B Additional Information
Several tips or suggestions for implementing the problems in Task 3-7 have been included with the program template. However, be reminded that it is strictly not necessary to follow these tips or suggestions.
Suggestions for Extensions — The below are only suggestions for the extensions. As usual, you are required to understand these suggestions before implementing them into your project. You are more than welcomed to try out new ideas in your project.
• Formulation Aspect – For task 7, recall that one of the metric is to reduce the number of selected stocks. One common trick in optimization is to add a sigmoid penalty term to the objective function to enforce sparsity. For instance, you can add a penalty term to the objective function in (1.8) as follows:
γXn 1 , i=1 1 + exp(−λpi)
for some λ, γ > 0 which are tunable parameters.
• Evaluation Aspect – An extra dataset can be found in the archive full data extra.zip which contains the stock data mostly from 2022. You may use this dataset to further test the performance of your portfolio. The helper functions performance extradata can be used for assessing this dataset.
• Algorithm Aspect – For Task 7, with the constraint structure given, the recommended algorithms are projected gradient descent (PGD) method and conditional gradient (CG) method, which are described as follows. For solving a general optimization:
min F(x) s.t. li ≤ xi ≤ ui, i = 1,…,n. (1.12) x∈Rn
Let X = {x ∈ Rn : li ≤ xi ≤ ui, i = 1,…,n}, these algorithms can be described as
Input: x(0) ∈Rn withli ≤x(0) ≤ui foralli,con- Input: x(0) ∈ Rn with li ≤ x(0) ≤ ui for all i, ii
stant step size γ > 0, max. iteration number Kmax. For k = 0, …, Kmax
x(k+1) = ProjX x(k) − γ∇F (x(k)) End For
PGD Method
max. iteration number Kmax. For k = 1, …, Kmax
a(k) = arg mina∈X a⊤∇F (x(k))
x(k+1) = (1− End For
2 )x(k) + 2 a(k) k+1 k+1
Moreover, the projection/CG operators can be easily computed: for any g ∈ Rn, we have
gi, ifgi∈[li,ui], gPG = ProjX(g), where [gPG]i = li, if gi < li,
ui, ifgi>ui.
(ui, if gi < 0, a∈X li, if gi ≥ 0.
gCG = arg min a⊤g, where [gCG]i =
It should not be very hard to program the above into a Julia function. Nevertheless, you are more than welcomed to explore the use of other iterative algorithms for solving the optimization at hand.
FTEC2101/ESTR2520 Project 14 References
F. J. Fabozzi, P. N. Kolm, D. A. Pachamanova, and S. M. Focardi. Robust portfolio optimization and man- agement. John Wiley & Sons, 2007.