| | |
| | | import xmdapi |
| | | from huaxin_client import tool, constant |
| | | from log_module.log import logger_system, logger_local_huaxin_l1, logger_l2_codes_subscript, logger_debug |
| | | from third_data import custom_block_in_money_manager |
| | | from utils import tool as out_tool |
| | | |
| | | ################B类################## |
| | |
| | | # (代码, 现价, 涨幅, 量, 当前时间, 买1价, 买1量, 买2价, 买2量, 更新时间) |
| | | level1_data_dict[pMarketDataField.SecurityID] = ( |
| | | pMarketDataField.SecurityID, pMarketDataField.LastPrice, rate, pMarketDataField.Volume, time.time(), |
| | | pMarketDataField.BidPrice1, pMarketDataField.BidVolume1, pMarketDataField.BidPrice2, pMarketDataField.BidVolume2, pMarketDataField.UpdateTime) |
| | | pMarketDataField.BidPrice1, pMarketDataField.BidVolume1, pMarketDataField.BidPrice2, |
| | | pMarketDataField.BidVolume2, pMarketDataField.UpdateTime) |
| | | |
| | | |
| | | __latest_subscript_codes = set() |
| | |
| | | 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: 固定要返回数据的代码 |
| | |
| | | """ |
| | | if fixed_codes is None: |
| | | fixed_codes = set() |
| | | logger_local_huaxin_l1.info("运行l1订阅服务") |
| | | logger_local_huaxin_l1.info(f"运行l1订阅服务,固定代码:{fixed_codes}") |
| | | codes_sh = [] |
| | | codes_sz = [] |
| | | for i in range(15): |
| | |
| | | |
| | | # 等待程序结束 |
| | | while True: |
| | | print("数量", len(level1_data_dict)) |
| | | # print("数量", len(level1_data_dict)) |
| | | try: |
| | | if len(level1_data_dict) < 1: |
| | | continue |
| | |
| | | list_ = [level1_data_dict[k] for k in level1_data_dict] |
| | | flist = [] |
| | | now_time_int = int(tool.get_now_time_str().replace(":", "")) |
| | | threshold_rate = constant.L1_MIN_RATE_PRE if now_time_int < int( |
| | | "094000") else constant.L1_MIN_RATE |
| | | threshold_rate = constant.L1_MIN_RATE |
| | | for d in list_: |
| | | if d[2] >= threshold_rate or d[0] in fixed_codes: |
| | | # 涨幅小于5%的需要删除 |
| | | # 涨幅小于3%的需要删除 |
| | | flist.append(d) |
| | | flist.sort(key=lambda x: x[2], reverse=True) |
| | | # 将固定代码的排在最前 |