Back to Community
Simple Question - Sorting and Rebalancing

I'm a rookie and am trying to build a simple algorithm.

I'm looking to build an algorithm that:
- Sorts the S&P 500 stocks by the 14 period RSI
- Shorts the top 10 and longs the bottom 10
- Rebalances daily

Can anyone point me in the right direction? I'm a complete rookie to python. Any examples out there of sorting by indicator that I could copy?

2 responses

This should do what you like. You can easily modify it and experiment

Clone Algorithm
4
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 58e6bb50083df364cf98a280
There was a runtime error.

Thank you so much!