| | |
| | | results = order(2, code, volume, price) |
| | | async_log_util.info(hx_logger_trade_debug, f"自动卖出可转债结果:{results}") |
| | | |
| | | def __re_sell(code, volume, price): |
| | | order(2, code, volume, price) |
| | | |
| | | def __process_order(data): |
| | | code = data["securityID"] |
| | | accountID = data["accountID"] |
| | |
| | | limitPrice = data.get("limitPrice") |
| | | volume = data.get("volume") |
| | | sinfo = data.get("sinfo") |
| | | cancelTime = data.get("cancelTime") |
| | | |
| | | order = HuaxinOrderEntity(code, orderStatus, orderRef, accountID, orderSysID, |
| | | insertTime=insertTime, acceptTime=acceptTime, |
| | | insertDate=insertDate, direction=direction) |
| | | orderEntity = HuaxinOrderEntity(code, orderStatus, orderRef, accountID, orderSysID, |
| | | insertTime=insertTime, acceptTime=acceptTime, |
| | | insertDate=insertDate, direction=direction) |
| | | try: |
| | | if str(order.direction) == str(huaxin_util.TORA_TSTP_D_Sell): |
| | | if str(orderEntity.direction) == str(huaxin_util.TORA_TSTP_D_Sell): |
| | | try: |
| | | if huaxin_util.is_can_cancel(order.orderStatus): |
| | | if huaxin_util.is_can_cancel(orderEntity.orderStatus): |
| | | DelegateSellOrderManager.add_delegate_sell_order( |
| | | (order.orderSysID, order.code, order.insertTime, limitPrice)) |
| | | elif huaxin_util.is_canceled(order.orderStatus): |
| | | DelegateSellOrderManager.cancel_delegate_sell_order(order.orderSysID) |
| | | elif order.orderStatus == huaxin_util.TORA_TSTP_OST_AllTraded: |
| | | DelegateSellOrderManager.deal_delegate_sell_order(order.orderSysID) |
| | | (orderEntity.orderSysID, orderEntity.code, orderEntity.insertTime, limitPrice)) |
| | | elif huaxin_util.is_canceled(orderEntity.orderStatus): |
| | | # 9:30之前下的单需要重新下单 |
| | | if cancelTime and int(cancelTime.replace(":", "")) >= int("093000"): |
| | | delegate_data = DelegateSellOrderManager.get_delegate_sell_order_by_order_sys_id(orderSysID) |
| | | if delegate_data and int(delegate_data[2].replace(":", "")) < int("093000"): |
| | | # TODO需要重新下单 |
| | | deal_price = L2DataProcessor.get_deal_price(code) |
| | | if deal_price: |
| | | sell_price = tool.get_buy_min_price(deal_price) |
| | | __re_sell(code, volume, sell_price) |
| | | |
| | | DelegateSellOrderManager.cancel_delegate_sell_order(orderEntity.orderSysID) |
| | | elif orderEntity.orderStatus == huaxin_util.TORA_TSTP_OST_AllTraded: |
| | | DelegateSellOrderManager.deal_delegate_sell_order(orderEntity.orderSysID) |
| | | except Exception as e: |
| | | hx_logger_trade_debug.exception(e) |
| | | # 刷新持仓列表 |
| | | huaxin_trade_data_update.add_position_list() |
| | | if huaxin_util.is_deal(order.orderStatus): |
| | | if huaxin_util.is_deal(orderEntity.orderStatus): |
| | | # 如果成交了需要刷新委托列表 |
| | | huaxin_trade_data_update.add_delegate_list("卖成交") |
| | | else: |
| | |
| | | # 卖出可转债 |
| | | __sell_cb_code(code, volume) |
| | | # TradeResultProcessor.process_buy_order(order) |
| | | need_watch_cancel = TradeResultProcessor.process_sell_order(order) |
| | | need_watch_cancel = TradeResultProcessor.process_sell_order(orderEntity) |
| | | if need_watch_cancel: |
| | | threading.Thread(target=lambda: __cancel_order(order.code, order.orderRef), daemon=True).start() |
| | | threading.Thread(target=lambda: __cancel_order(orderEntity.code, orderEntity.orderRef), |
| | | daemon=True).start() |
| | | finally: |
| | | try: |
| | | # 加入2次,增大加入成功率 |