我收到“ ValueError:DataFrame的真值不明确。请使用a.empty,a.bool(),a.item(),a.any()或a.all()。”错误。我试图通过提供括号和花括号来修复它。但这并没有解决。
def RENKO_TRIMA(company_data):
global ohlc_final_1min, RENKO_Final, final_position, order_quantity, RENKO, RENKO_temp
try:
if len(RENKO_Final) > 0:
if RENKO_Final.iloc[-1, 6] != 0:
if (RENKO_Final.iloc[-1, 3] == "SELL") & (RENKO_Final.iloc[-1, 1] < RENKO_Final.iloc[-1, 6]) & (RENKO_Final.iloc[-1, 2] < RENKO_Final.iloc[-1, 6]):
if (positions(company_data['instrument_token'])) > 0:
self.place_order(variety="regular", exchange=self.EXCHANGE_NSE, tradingsymbol="SBIN",
transaction_type=self.TRANSACTION_TYPE_SELL,
quantity=abs(positions(company_data['instrument_token'])),
order_type=self.ORDER_TYPE_MARKET, product=self.PRODUCT_MIS)
if positions(company_data['instrument_token']) == 0:
self.place_order(variety="regular", exchange=self.EXCHANGE_NSE, tradingsymbol="SBIN",
transaction_type=self.TRANSACTION_TYPE_SELL,
quantity=quantity(company_data['last_price']),
order_type=self.ORDER_TYPE_MARKET, product=self.PRODUCT_MIS)
#RENKO[company_data['instrument_token']][4] = "SHORT"
elif (RENKO_Final.iloc[-1, 3] == "BUY") & (RENKO_Final.iloc[-1, 1] > RENKO_Final.iloc[-1, 6]) & (RENKO_Final.iloc[-1, 2] > RENKO_Final.iloc[-1, 6]):
if (positions(company_data['instrument_token'])) < 0:
self.place_order(variety="regular", exchange=self.EXCHANGE_NSE, tradingsymbol="SBIN",
transaction_type=self.TRANSACTION_TYPE_BUY,
quantity=abs(positions(company_data['instrument_token'])),
order_type=self.ORDER_TYPE_MARKET, product=self.PRODUCT_MIS)
if positions(company_data['instrument_token']) == 0:
self.place_order(variety="regular", exchange=self.EXCHANGE_NSE, tradingsymbol="SBIN",
transaction_type=self.TRANSACTION_TYPE_BUY, quantity=quantity(company_data['last_price']),
order_type=self.ORDER_TYPE_MARKET, product=self.PRODUCT_MIS)
#RENKO[company_data['instrument_token']][4] = "LONG"
except Exception as e:
traceback.print_exc()