老师只是看了profit 对比,但是cum_profit是有问题的
before:data = data[data['signal'] != 0]
data['profit_pct'] = (data['close'] - data['close'].shift(1)) / data['close'].shift(1)
After:data.loc[data['signal'] != 0, 'profit_pct'] = (data['close'] - data['close'].shift(1)) / data['close'].shift(1)