You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
see the '' signal = data > sma '' in example, but if i have a indicator, when indicator < 10, i buy it; indicator > 50, sold it.
how to implement this example.
The text was updated successfully, but these errors were encountered:
## download some data & calc SMAsdata=bt.get('spy', start='2010-01-01')
sma50=data.rolling(50).mean()
sma200=data.rolling(200).mean()
## now we need to calculate our target weight DataFrame# first we will copy the sma200 DataFrame since our weights will have the same strucutretw=sma200.copy()
# set appropriate target weightstw[sma50>sma200] =1.0tw[sma50<=sma200] =-1.0# here we will set the weight to 0 - this is because the sma200 needs 200 data points before# calculating its first point. Therefore, it will start with a bunch of nulls (NaNs).tw[sma200.isnull()] =0.0
see the '' signal = data > sma '' in example, but if i have a indicator, when indicator < 10, i buy it; indicator > 50, sold it.
how to implement this example.
The text was updated successfully, but these errors were encountered: