I wonder if the asymmetry is due to this line
filtered_uni = context.output[context.output['high_to_open_returns'] < context.output['std']]
Generally yesterday's high will be greater than today's open, so high_to_open_returns will generally be negative, and therefore always be below the standard deviation.
Using the last (corrected version) and changing the entry time to 10 minutes after the open and the exit time to 10 minutes before the close,
(they were 0 and 30 minutes) the results are quite bad. It makes me worry when results are really sensitive to small changes like this. It does seem to be selling everything at the end of day.
|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|
I would like to add an adjustable volume filter and a price filter. I’ve come up with the following code, but do not know how to implement it within the existing code so that the algo filters out the securities that do not meet these multiple minimum criteria. Can someone please help with this?
twodayvol = data.history(context.security_list, ‘price’, 20, ‘1m’)
yesterday_vol = twodayvol[-20:-11].mean()
today_vol = twodayvol[-9:-1].mean()
vol_jump = yesterday_vol *2
context.output[‘todayvol’] = today_vol.values
context.output[‘voljump’] = vol_jump.values
filtered_vol = context.output[‘todayvol’] > context.output[‘voljump’]
filtered_price = context.output[‘open’] > 30.0