我写了一种在熊猫中构造数据框(RENKO)的方法。之后,我正在从该数据帧调用/引用某些值以进行一些计算,但是结果是-1,并且没有错误消息。有人可以帮忙吗?请忽略我的编码水平,因为我最近通过python学习了开发。
def on_ticks(ws, ticks): # retrive continius ticks in JSON format
global ohlc_final_1min, RENKO_Final
try:
for company_data in ticks:
calculate_ohlc_one_minute(company_data);
if len(RENKO_Final) > 0:
if (company_data['last_price'] < RENKO_Final.loc[-1, 1]) and
RENKO_Final.loc[-1, 3] == "Sell":
print("Sell at " + company_data['last_price'])
elif (company_data['last_price'] > RENKO_Final.loc[-1, 1]) and
RENKO_Final.loc[-1, 3] == "Buy":
print("Buy at " + company_data['last_price'])
except Exception as e:
print(e);