Back to Community
How to select the Top 4 performers out of a list

I would like to run a simple backtest. Any advice on Alg structure?
10 securities
Lookback 3 months
find and select the top 4 performers
Rebalance every month (once a month)
Thanks all!

1 response

Logging the top 4 profit-n-loss each day here. You could schedule looping through c.pnl_top.index to do something with them.
Clear c.pnls each time to avoid those from the past (now closed): c.pnls = pd.Series({})
I added a header line here

                                                   Sym    PnL   Position  
2016-10-10 05:45 before_trading_start:123 INFO    AMAT   26886  shrs 4971  
2016-10-10 05:45 before_trading_start:123 INFO    FEYE   26008  shrs -10424  
2016-10-10 05:45 before_trading_start:123 INFO     ATW   20421  shrs 0  
2016-10-10 05:45 before_trading_start:123 INFO     BAC   16400  shrs 0  
2016-10-11 05:45 before_trading_start:120 INFO .  
2016-10-11 05:45 before_trading_start:123 INFO    FEYE   25278  shrs -10424  
2016-10-11 05:45 before_trading_start:123 INFO    AMAT   25047  shrs 4971  
2016-10-11 05:45 before_trading_start:123 INFO     ATW   20421  shrs 0  
2016-10-11 05:45 before_trading_start:123 INFO     BAC   16400  shrs 0  
Clone Algorithm
55
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: 5a166d74096f104177f2a693
There was a runtime error.