260 views
0

您好,执行代码时出现以下问题:

Exception: 下单方式(price) <function WorkerThread.run.<locals>.get_price at 0x0000020D19108790> 错误, 请检查 price 参数是否填写正确

请问原因是什么?谢谢。代码如下:

quote = self.api.get_quote(self.symbol)
         # 在 BUY 时使用买一价加一档价格,SELL 时使用卖一价减一档价格
        def get_price(direction):
            if direction == "BUY":
                price = quote.bid_price1 + 2 * quote.price_tick
            else:
                price = quote.ask_price1 - 2 * quote.price_tick
            # 如果 price 价格是 nan,使用最新价报单
            if price != price:
                price = quote.last_price
            return price
         target_pos = TargetPosTask(self.api, self.symbol, price=get_price)

Answered question
0

代码里你自己定义的func,get_price没有导入参数,肯定就输出错误了,建议再调试下代码

Answered question