Difference between revisions of "MC1-Project-2"
(Created page with "==Overview== In this project you will use what you learned about optimizers to optimize a portfolio. That means that you will find how much of a portfolio's funds should be...") |
m (Minor edits) |
||
Line 7: | Line 7: | ||
==Task== | ==Task== | ||
− | Write a Python function named <TT>optimize_portfolio()</TT> that can find the optimal allocations | + | Write a Python function named <TT>optimize_portfolio()</TT> that can find the optimal allocations for a given stock portfolio. You should optimize for Sharpe ratio. |
Inputs to the function include: | Inputs to the function include: | ||
* Start date | * Start date | ||
* End date | * End date | ||
− | * Symbols | + | * Symbols for equities (e.g., GOOG, AAPL, GLD, XOM) |
The function should return: | The function should return: | ||
Line 21: | Line 21: | ||
allocations = optimize_portfolio(startdate, enddate, ['GOOG','AAPL','GLD','XOM']) | allocations = optimize_portfolio(startdate, enddate, ['GOOG','AAPL','GLD','XOM']) | ||
− | Also, create a chart that illustrates the value of your portfolio over the year and compares it to SPY. | + | Also, create a chart that illustrates the value of your portfolio over the year and compares it to SPY. The portfolio and SPY should be normalized to 1.0 at the beginning of the period. |
− | + | TODO: include example chart here | |
==Suggestions== | ==Suggestions== |
Revision as of 18:36, 15 June 2015
Overview
In this project you will use what you learned about optimizers to optimize a portfolio. That means that you will find how much of a portfolio's funds should be allocated to each stock so as to optimize it's performance. In this case we define "optimal" as maximum Sharpe ratio.
You will leverage the function you created in the last project that assessed the value of a portfolio with a given set of allocations.
Task
Write a Python function named optimize_portfolio() that can find the optimal allocations for a given stock portfolio. You should optimize for Sharpe ratio.
Inputs to the function include:
- Start date
- End date
- Symbols for equities (e.g., GOOG, AAPL, GLD, XOM)
The function should return:
- A list of floats that represents the allocations to each of the equities.
An example of how the function would be called:
allocations = optimize_portfolio(startdate, enddate, ['GOOG','AAPL','GLD','XOM'])
Also, create a chart that illustrates the value of your portfolio over the year and compares it to SPY. The portfolio and SPY should be normalized to 1.0 at the beginning of the period.
TODO: include example chart here
Suggestions
None yet.
Make sure your optimize_portfolio() function gives correct output. Check it against the examples below.
Example output
Here's an example output for your function. These are actual correct examples that you can use to check your work.
todo:example 1
todo:example 2
Minor differences in float values may arise due to different implementations.
What to turn in
Via t-square turn in attachments only:
- Your code as submission.py
- Your chart as chart.pdf