Research approach
From daily market data to a long/short portfolio
My goal is to deliver steady returns and maximize the Sortino ratio while keeping maximum drawdown below 10%.
1Check the data
I pull daily open, high, low, close, and volume data from Yahoo Finance using yfinance. Before training, I check for anomalies such as unusual price spikes that could distort the results.
2Define the asset universe
I define which assets are eligible for each experiment so I can compare algorithms on the same universe.
3Rank the universe each day
Each algorithm ranks the eligible assets by expected return. I train on earlier data, test the rankings on the next unseen period, then move the window forward and repeat. I also test whether combining models improves the rankings.
4Decide how far to lean long or short
I use the ranking to find candidates for the long and short sides. At each timestep, a separately trained model chooses one of five net exposures for the book: strongly short, slightly short, neutral, slightly long, or strongly long.
5Adjust position weights for risk
I use volatility and how assets move together to size positions. I also cap individual weights and overall exposure. The goal is to improve risk-adjusted returns while keeping drawdowns manageable.
6Trade toward the target portfolio
I calculate a target portfolio and compare it with the positions already held. I move toward the target when the expected benefit justifies the cost of trading. If the improvement is small, keeping some positions as they are can be the better choice.
