Due date: 2024/10/22 23:59:59
Trading Strategies Using Technical Indicators
In this homework, you need to design a stock trading strategy to maximize the return over a given period of time.
Your design flowchart should be like this:
- Determine the TI you want to use, or any indicators designed by yourself.
- Define the trading strategy using the indicators, with some modifiable parameters for optimizing the return.
- Optimzie the return using the historical price data.
- Use the obtained parameters for trading over a longer period of time.
For instance, in the the example code of bestParamViaExhaustiveSearch.py, we use MA (moving average) as the TI, with the parameters of window size, alpha, beta. Then we maximize the return rate on "price3000open.csv" by exhaustive search with the command:
python bestParamByExhaustiveSearch.py price3000open.csv
It will take a while to obtain the best settings with the maximum return rate:
Best settings: windowSize=19, alpha=1, beta=2 ==> returnRate=2.540205
Then you can put these best parameters into the program myStrategy.py ", and try the trading strategy on the same dataset by typing
python rrEstimate.py price3000open.csv
The result is as expected:
rr=254.020465%
Other notes:
- Each call to myStrategy() should last no more than 0.01 sec, otherwise it will be killed and the output of the function is 0 by default.
- You can try other complicated TIs (such as deep neural networks), but you should keep in mind that complex models do not necessarily perform well on test data. You always need to strike a balance between model complexity and data size.
- Scoring is based on your ranking of the final return rate based on a future period of time, which is slightly more than 1,000 days.