Administrator
2023-10-20 1772431bd0578e706d91a4c92ecbab78bda55dfb
huaxin_client/trade_client.py
@@ -92,7 +92,7 @@
        cls.__front_id = front_id
    # sinfo char(32)
    def buy(self, code, count, price, sinfo, order_ref, need_shadedow_order = True):
    def buy(self, code, count, price, sinfo, order_ref, shadow_price = None):
        if not ENABLE_ORDER:
            return
        if sinfo in self.__buy_sinfo_set:
@@ -158,6 +158,7 @@
        ret = api.ReqOrderInsert(req_field, self.req_id)
        if ret != 0:
            raise Exception('ReqOrderInsert fail, ret[%d]' % ret)
        if queue_trade_w_l2_r is not None:
            queue_trade_w_l2_r.put_nowait(
                json.dumps({"type": "listen_volume", "data": {"code": code,
@@ -165,12 +166,11 @@
                    'utf-8'))
        async_log_util.info(logger_trade, f"{code}华鑫本地真实下单结束")
        # --------------------------------影子订单--------------------------------
        if need_shadedow_order:
        if shadow_price:
            if order_ref:
                # 下一个影子订单
                shadow_order_ref = order_ref + 1
                shadow_sinfo = f"s_b_{order_ref}"
                shadow_price = tool.get_buy_min_price(price)
                req_field.LimitPrice = shadow_price
                req_field.SInfo = shadow_sinfo
                req_field.OrderRef = shadow_order_ref
@@ -873,6 +873,7 @@
            price = data["price"]
            sinfo = data["sinfo"]
            order_ref = data.get("order_ref")
            shadow_price = data.get("shadow_price")
            if direction == 1:
                async_log_util.info(logger_trade, f"{code}华鑫本地开始下单")
@@ -881,7 +882,7 @@
                    req_rid_dict[sinfo] = (client_id, request_id, sk, order_ref)
                    # threading.Thread(target=lambda: self.__tradeSimpleApi.buy(code, volume, price, sinfo, order_ref),
                    #                  daemon=True).start()
                    self.trade_thread_pool.submit(self.__tradeSimpleApi.buy, code, volume, price, sinfo, order_ref)
                    self.trade_thread_pool.submit(self.__tradeSimpleApi.buy, code, volume, price, sinfo, order_ref, shadow_price)
                    async_log_util.info(logger_trade, f"{code}华鑫本地下单线程结束")
                except Exception as e: