| | |
| | | def get_limit_up_price_cache(code): |
| | | if code in __limit_up_price_dict: |
| | | return __limit_up_price_dict[code] |
| | | |
| | | |
| | | return None |
| | | |
| | | |
| | |
| | | from log_module import async_log_util |
| | | from log_module.log import hx_logger_trade_debug, hx_logger_trade_loop, hx_logger_trade_callback, logger_trade, \ |
| | | logger_system |
| | | from trade.huaxin import huaxin_trade_data_update |
| | | from trade.huaxin import huaxin_trade_data_update, 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 utils import socket_util, huaxin_util, tool |
| | |
| | | is_shadow_order=is_shadow_order) |
| | | TradeResultProcessor.process_order(order) |
| | | |
| | | try: |
| | | huaxin_trade_record_manager.DelegateRecordManager.add_one(data) |
| | | except: |
| | | pass |
| | | if not is_shadow_order: |
| | | # 订单相关回调 |
| | | # 重新请求委托列表与资金 |
| | |
| | | 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 |
| | | if is_shadow_order: |
| | | continue |
| | | |
| | | 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 and huaxin_util.is_can_cancel(orderStatus): |
| | | if huaxin_util.is_can_cancel(orderStatus): |
| | | codes.append(code) |
| | | if codes: |
| | | try: |
| | |
| | | |
| | | # 委托列表 |
| | | class DelegateRecordManager: |
| | | mysqldb = mysql_data.Mysqldb() |
| | | |
| | | @classmethod |
| | | def add(cls, datas): |
| | | mysqldb = mysql_data.Mysqldb() |
| | | try: |
| | | if datas: |
| | | for d in datas: |
| | | cls.add_one(d) |
| | | finally: |
| | | pass |
| | | |
| | | @classmethod |
| | | def add_one(cls, d): |
| | | # 查询是否有数据 |
| | | _id = f"{d['insertDate']}-{d['orderLocalID']}" |
| | | result = mysqldb.select_one( |
| | | result = cls.mysqldb.select_one( |
| | | f"select * from hx_trade_delegate_record where id='{_id}'") |
| | | if not result: |
| | | # 新增数据 |
| | | nameDict = HistoryKDatasUtils.get_gp_codes_names([d['securityID']]) |
| | | name = nameDict.get(d['securityID']) |
| | | mysqldb.execute( |
| | | cls.mysqldb.execute( |
| | | "insert into hx_trade_delegate_record values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % ( |
| | | _id, d["orderLocalID"], d["securityID"], name, d["direction"], |
| | | d["orderSysID"], d["insertTime"], d["insertDate"], d["acceptTime"], d["cancelTime"], |
| | |
| | | where_list.append(f"{k}='{updateDict[k]}'") |
| | | else: |
| | | where_list.append(f"{k}={updateDict[k]}") |
| | | mysqldb.execute( |
| | | cls.mysqldb.execute( |
| | | f"update hx_trade_delegate_record set {','.join(where_list)} where id='{result[0]}'") |
| | | finally: |
| | | pass |
| | | |
| | | @classmethod |
| | | def list_by_day(cls, day, min_update_time, orderStatus=[]): |
| | |
| | | results, update_time = DelegateRecordManager.list_by_day( |
| | | tool.get_now_date_str("%Y%m%d"), update_time) |
| | | print(results) |
| | | |