我使用了VMA策略。
signals = pd.DataFrame(index=dt.index)
signals['Close']=dt['Close']
signals['percent change']=dt['Percent_Change']
signals['vol'] = dt['Volume']
signals['100 MA'] =
dt['Close'].rolling(window=100,center=False).mean()
signals['10 MA'] = dt['Close'].rolling(window=10,
center=False).mean()
signals['vol avg']=dt['Volume'].mean()
signals['Criteria1'] = (signals['10 MA']< signals['100 MA'])
signals['Criteria2'] = signals['vol'] <= signals['vol avg']
signals['BUY OR SELL'] = signals['Criteria1'] & signals['Criteria2']
signals.tail()
signals['Criteria 3'] = signals['10 MA']> signals['100 MA'] * 0.1
signals['buy']=signals['Criteria 3']
signals.tail()
signals['buy'].value_counts()
def tradebuy():
signals['value'] = signals['BUY OR SELL']
if signals['BUY OR SELL'] == True:
if signals['Criteria 3'] == True:
print("BUY")
输出:具有(利润/亏损百分比,亏损百分比,交易数量,参数值..)的元组