top of page

Portfolio Strategy Selection Tools Using Python and Machine Learning

I am working on some tools to speed up and improve strategies for Portfolio selection. We have always exported the data to Microsoft Excel. The Portfolio Calculator is a great tool!

I wanted to work on converting this tool to Python to customize and speed up some of the processes as well and take advantage of the machine learning tools in python such as Hidden Markov Models. 

In this video, we show how the tool was built and how:

1.) Each equity curve can by generated and viewed quickly.

2.) The combined equity and drawdown curve

3.) A portfolio selection of the top 10 strategies based on a Sharpe Ratio ranking.

4.) Trading only the strategies whose last 100 equity curve changes are greater than the last 200 equity curve changes.

The 100 vs 200 period equity curve change moving average improves the performance.

For the data, we are measuring the results of 257 trading systems. We are looking at the combined end of day daily profit and loss going back to 2008. We are not looking at individual trade data but we are looking at the results of day equity curve analysis with round turn slippage and commission calculations from the Tradestation platform. Sometimes there is more than one trade per day and sometimes there are no trades for many days on any individual trading system.

When I first set this up, some strategies may not trade for more than 20 days so I was using 10 and 20 day moving averages that were flat. It is important to make moving average measurements based on the changes so there is a moving average based on a "closed trades on end of day basis" equity curve so that flat line periods are not averaged.

This is just the beginning as the possibility for metrics related to this setup are numerous.

52 views1 comment

1 Comment

Very interesting! Once strategies are selected, would you manually activate them in TradeStation (or wherever) or is there plan to autotrade them without manual intervention?

bottom of page