Administrator
2025-06-12 4e5eed2226fae6a057c454155565211dbc9349e9
trade/huaxin_sell_util.py
@@ -1,4 +1,5 @@
# 撤卖单
import threading
import time
from log_module import async_log_util
@@ -25,15 +26,23 @@
        logger_trade.exception(e)
__sell_lock = threading.RLock()
# 开始撤单
def start_sell(code, volume, price_type, limit_up_price, limit_down_price, current_price, blocking=False,
               request_id=None, order_ref=None):
    price = sell_util.get_sell_price(price_type, limit_up_price, limit_down_price, current_price)
    if not price:
        raise Exception("价格获取出错")
    async_log_util.info(logger_trade, f"API卖:  单价-{price}")
    if not order_ref:
        order_ref = huaxin_util.create_order_ref()
    result = huaxin_trade_api.order(2, code, volume, price, order_ref=order_ref,
                                    blocking=blocking, request_id=request_id)
    return result
    # 线程锁
    __sell_lock.acquire()
    try:
        price = sell_util.get_sell_price(price_type, limit_up_price, limit_down_price, current_price)
        if not price:
            raise Exception("价格获取出错")
        async_log_util.info(logger_trade, f"API卖:  单价-{price}")
        if not order_ref:
            order_ref = huaxin_util.create_order_ref()
        result = huaxin_trade_api.order(2, code, volume, price, order_ref=order_ref,
                                        blocking=blocking, request_id=request_id)
        return result
    finally:
        __sell_lock.release()