| | |
| | | return limit_up_price |
| | | |
| | | |
| | | def get_limit_up_price_cache(code): |
| | | if code in __limit_up_price_dict: |
| | | return __limit_up_price_dict[code] |
| | | return None |
| | | |
| | | |
| | | def get_limit_up_price_by_preprice(price): |
| | | if price is None: |
| | | return None |
| | |
| | | shadow_cancel_order_ref = shadow_order_ref + 1 |
| | | self.cancel_buy(code, f"s_c_{shadow_order_ref}", order_sys_id=None, |
| | | order_ref=shadow_order_ref, |
| | | order_action_ref=shadow_cancel_order_ref, delay_s=0.05) |
| | | order_action_ref=None, delay_s=0.05) |
| | | |
| | | return ret |
| | | |
| | |
| | | limitPrice = data.get("limitPrice") |
| | | volume = data.get("volume") |
| | | |
| | | order = HuaxinOrderEntity(code, orderStatus, orderRef, accountID, orderSysID, |
| | | insertTime=insertTime, acceptTime=acceptTime, |
| | | insertDate=insertDate, direction=direction) |
| | | TradeResultProcessor.process_order(order) |
| | | |
| | | is_shadow_order = False |
| | | # 获取涨停价 |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | |
| | | if limit_up_price and volume == huaxin_client_constant.SHADOW_ORDER_VOLUME and abs( |
| | | float(limitPrice) - float(limit_up_price)) < 0.01: |
| | | # 影子订单变化 |
| | | # 如果是影子订单就不应该更新 |
| | | pass |
| | | else: |
| | | is_shadow_order = True |
| | | |
| | | order = HuaxinOrderEntity(code, orderStatus, orderRef, accountID, orderSysID, |
| | | insertTime=insertTime, acceptTime=acceptTime, |
| | | insertDate=insertDate, direction=direction, |
| | | is_shadow_order=is_shadow_order) |
| | | TradeResultProcessor.process_order(order) |
| | | |
| | | if not is_shadow_order: |
| | | # 订单相关回调 |
| | | # 重新请求委托列表与资金 |
| | | huaxin_trade_data_update.add_delegate_list("来自交易管道") |
| | |
| | | import threading |
| | | import time |
| | | |
| | | from l2 import cancel_buy_strategy |
| | | from l2.l2_data_manager import TradePointManager |
| | | from code_attribute import gpcode_manager |
| | | from huaxin_client import constant as huaxin_client_constant |
| | | from log_module import async_log_util |
| | | from log_module.log import hx_logger_trade_debug, logger_system |
| | | from trade import trade_huaxin, trade_manager |
| | | from trade import trade_manager |
| | | from trade.huaxin import huaxin_trade_api, huaxin_trade_record_manager |
| | | from trade.huaxin.huaxin_trade_record_manager import TradeOrderIdManager |
| | | from trade.huaxin.huaxin_trade_order_processor import CancelOrderManager, HuaxinOrderEntity, TradeResultProcessor |
| | | from trade.huaxin.huaxin_trade_order_processor import HuaxinOrderEntity, TradeResultProcessor |
| | | from utils import huaxin_util |
| | | |
| | | trade_data_request_queue = queue.Queue() |
| | |
| | | acceptTime = d.get('acceptTime') |
| | | insertDate = d.get('insertDate') |
| | | direction = d.get("direction") |
| | | |
| | | limitPrice = d.get("limitPrice") |
| | | volume = d.get("volume") |
| | | # 获取涨停价 |
| | | is_shadow_order = False |
| | | limit_up_price = gpcode_manager.get_limit_up_price_cache(code) |
| | | if limit_up_price and volume == huaxin_client_constant.SHADOW_ORDER_VOLUME and abs( |
| | | float(limitPrice) - float(limit_up_price)) < 0.01: |
| | | is_shadow_order = True |
| | | order = HuaxinOrderEntity(code, orderStatus, orderRef, accountID, orderSysID, |
| | | insertTime=insertTime, acceptTime=acceptTime, |
| | | insertDate=insertDate, direction=direction) |
| | | insertDate=insertDate, direction=direction, |
| | | is_shadow_order=is_shadow_order) |
| | | TradeResultProcessor.process_order(order) |
| | | if huaxin_util.is_can_cancel(orderStatus): |
| | | if not is_shadow_order and huaxin_util.is_can_cancel(orderStatus): |
| | | codes.append(code) |
| | | if codes: |
| | | try: |
| | |
| | | class HuaxinOrderEntity: |
| | | def __init__(self, code, orderStatus, orderRef, accountID, orderSysID, direction=None, insertDate=None, |
| | | insertTime=None, |
| | | acceptTime=None): |
| | | acceptTime=None, is_shadow_order=False): |
| | | self.code = code |
| | | self.orderStatus = orderStatus |
| | | self.orderRef = orderRef |
| | |
| | | self.insertDate = insertDate |
| | | self.acceptTime = acceptTime |
| | | self.direction = direction |
| | | self.is_shadow_order = is_shadow_order |
| | | |
| | | |
| | | class CancelOrderManager: |
| | |
| | | if order.direction != str(huaxin_util.TORA_TSTP_D_Buy): |
| | | return |
| | | |
| | | # 只处理正式订单,不处理影子订单 |
| | | if order.is_shadow_order: |
| | | return |
| | | |
| | | # 同一订单号只有状态变化了才需要处理 |
| | | key = f"{order.insertDate}_{order.code}_{order.orderSysID}_{order.orderStatus}" |
| | | if key in cls.__processed_keys: |