Administrator
2024-05-24 46a1eacf98aa129150cef99568bdcdcddc32a0b7
bug修复
2个文件已修改
20 ■■■■ 已修改文件
main.py 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin_sell_util.py 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py
@@ -97,6 +97,11 @@
                            send_response({"code": 0, "data": {"orderRef": order_ref}}, client_id, request_id)
                        else:
                            raise e
                    finally:
                        huaxin_trade_data_update.add_position_list()
                        huaxin_trade_data_update.add_money_list()
                        huaxin_trade_data_update.add_deal_list()
                else:
                    if not price:
                        limit_down_price = target_codes_manager.get_limit_down_price(code)
@@ -116,6 +121,9 @@
                        result = huaxin_trade_api.order(direction, code, volume, price,
                                                        sinfo=sinfo,
                                                        blocking=True, request_id=request_id)
                    huaxin_trade_data_update.add_position_list()
                    huaxin_trade_data_update.add_money_list()
                    huaxin_trade_data_update.add_deal_list()
                    send_response({"code": 0, "data": result}, client_id, request_id)
        except Exception as e:
            logger_debug.exception(e)
@@ -203,6 +211,9 @@
                    result = huaxin_trade_api.order(1, cb_code, 20, round(float(limit_up_price), 3), blocking=True)
                    __deal_codes.add(code)
                    async_log_util.info(logger_trade, f"可转债下单结果:{result}")
                    huaxin_trade_data_update.add_position_list()
                    huaxin_trade_data_update.add_money_list()
                    huaxin_trade_data_update.add_deal_list()
        except Exception as e:
            logger_debug.exception(e)
            time.sleep(1)
trade/huaxin_sell_util.py
@@ -1,5 +1,5 @@
# 撤卖单
import threading
import time
from log_module import async_log_util
@@ -13,6 +13,7 @@
def __cancel_sell_order(code, order_ref):
    time.sleep(2)
    try:
        result = huaxin_trade_api.cancel_order(2, code, None, orderRef=order_ref)
    except Exception as e:
@@ -21,7 +22,7 @@
# 开始撤单
def start_sell(code, volume, price_type, limit_up_price, limit_down_price, current_price, blocking=False,
               request_id=None,order_ref=None):
               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("价格获取出错")
@@ -30,4 +31,6 @@
        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
    # 2S不成交就撤单
    threading.Thread(target=lambda: __cancel_sell_order(code, order_ref), daemon=True).start()
    return result