| | |
| | | from huaxin_client import socket_util, l1_subscript_codes_manager |
| | | import xmdapi |
| | | from huaxin_client import tool, constant |
| | | from log_module.log import logger_system, logger_local_huaxin_l1, logger_l2_codes_subscript |
| | | from log_module.log import logger_system, logger_local_huaxin_l1, logger_l2_codes_subscript, logger_debug |
| | | from utils import tool as out_tool |
| | | |
| | | ################B类################## |
| | |
| | | if out_tool.get_limit_up_rate(pMarketDataField.SecurityID) > 1.1001: |
| | | # 涨停板20%以上的打折 |
| | | rate = rate / 2 |
| | | # (代码, 现价, 涨幅, 量, 当前时间, 买1价, 买1量, 买2价, 买2量, 更新时间) |
| | | level1_data_dict[pMarketDataField.SecurityID] = ( |
| | | pMarketDataField.SecurityID, pMarketDataField.LastPrice, rate, pMarketDataField.Volume, time.time(), |
| | | pMarketDataField.BidPrice1, pMarketDataField.BidVolume1) |
| | | pMarketDataField.BidPrice1, pMarketDataField.BidVolume1, pMarketDataField.BidPrice2, pMarketDataField.BidVolume2, pMarketDataField.UpdateTime) |
| | | |
| | | |
| | | __latest_subscript_codes = set() |
| | |
| | | time.sleep(3) |
| | | |
| | | |
| | | def run(queue_l1_w_strategy_r, queue_l1_r_strategy_w): |
| | | def run(queue_l1_w_strategy_r, queue_l1_r_strategy_w, fixed_codes=None): |
| | | """ |
| | | 运行l1订阅任务 |
| | | @param queue_l1_w_strategy_r: L1方写,策略方读 |
| | | @param queue_l1_r_strategy_w: L1方读,策略方写 |
| | | @param fixed_codes: 固定要返回数据的代码 |
| | | @return: |
| | | """ |
| | | if fixed_codes is None: |
| | | fixed_codes = set() |
| | | logger_local_huaxin_l1.info("运行l1订阅服务") |
| | | codes_sh = [] |
| | | codes_sz = [] |
| | |
| | | threshold_rate = constant.L1_MIN_RATE_PRE if now_time_int < int( |
| | | "094000") else constant.L1_MIN_RATE |
| | | for d in list_: |
| | | if d[2] >= threshold_rate: |
| | | if d[2] >= threshold_rate or d[0] in fixed_codes: |
| | | # 涨幅小于5%的需要删除 |
| | | flist.append(d) |
| | | flist.sort(key=lambda x: x[2], reverse=True) |
| | | # 将固定代码的排在最前 |
| | | for code in fixed_codes: |
| | | if code in level1_data_dict: |
| | | flist.insert(0, level1_data_dict[code]) |
| | | # 正式交易之前先处理比较少的数据,不然处理时间久造成数据拥堵 |
| | | MAX_COUNT = 500 |
| | | if now_time_int < int("092600"): |
| | |
| | | __upload_codes_info(queue_l1_w_strategy_r, datas) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | logger_debug.exception(e) |
| | | finally: |
| | | time.sleep(3) |
| | | |