top of page

Portfolio Strategy Selection Tools Using Python and Machine Learning

Capstone Trading


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.

 
 
 

1 Comment


Givenson Piard
Mar 20, 2024

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?


Like

EXCLUSIVE MARKET AND STRATEGY UPDATES

 Capstone Trading Systems © 2025. All Rights Reserved.

U.S. Government Required Disclaimer - Commodity Futures Trading Commission. Futures and options trading has large potential rewards, but also large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This website is neither a solicitation nor an offer to Buy/Sell futures or options. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this website. The past performance of any trading system or methodology is not necessarily indicative of future results.

CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY, SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.

bottom of page