elif (data_price['position'][i] == 1) & (data_price['sma'][i - 1] > data_price['lma'][i - 1]) & (
data_price['sma'][i] < data_price['lma'][i]):
data_price.loc[data_price.list[i], 'flag'] = -1
data_price.loc[i + 1, 'position'] = 0
date_out = data_price.index[i]
price_out = data_price.loc[i, 'close']
Sell.append([date_out, price_out, '死叉卖出'])
# 其他情形:保持之前的仓位不变
else:
data_price.loc[i + 1, 'position'] = data_price.loc[i, 'position']
源代码的ix,我改成了loc,但是开始了报错,从网上找了很多资料也解决不了。
报错如下: