Administrator
2024-05-08 21e83381e67058d9e017ac431690eafc95d7a98c
可转债正股代码订阅
2个文件已修改
56 ■■■■ 已修改文件
cb_main.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client_for_cb.py 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cb_main.py
@@ -2,6 +2,8 @@
可转债入口函数
"""
from huaxin_client import l2_client_for_cb
from utils import middle_api_protocol
if __name__ == '__main__':
    middle_api_protocol.SERVER_PORT = 10008
    l2_client_for_cb.run()
huaxin_client/l2_client_for_cb.py
@@ -170,10 +170,6 @@
            print("----L2行情登录成功----")
            self.is_login = True
            logger_system.info(f"L2行情登录成功")
            # 初始设置值
            threading.Thread(
                target=lambda: self.__process_codes_data(self.__get_latest_datas(), from_cache=True, delay=6.0),
                daemon=True).start()
    def OnRspSubTransaction(self, pSpecificSecurity, pRspInfo, nRequestID, bIsLast):
        async_log_util.info(logger_local_huaxin_l2_subscript,
@@ -299,50 +295,6 @@
pipe_strategy = None
def test_add_codes(queue_r):
    time.sleep(10)
    # if value:
    #     if type(value) == bytes:
    #         value = value.decode("utf-8")
    #     data = json.loads(value)
    #     _type = data["type"]
    #     if _type == "listen_volume":
    #         volume = data["data"]["volume"]
    #         code = data["data"]["code"]
    #         spi.set_code_special_watch_volume(code, volume)
    #     elif _type == "l2_cmd":
    #         l2CommandManager.process_command(command_manager.CLIENT_TYPE_CMD_L2, None, data)
    time.sleep(2)
    demo_datas = ["603002",
                  "002654",
                  "603701",
                  "002908"]
    queue_r.put_nowait(json.dumps({"type": "l2_cmd", "data": demo_datas}))
    time.sleep(10)
    while True:
        try:
            spi.l2_data_upload_manager.add_l2_order_detail(
                {'SecurityID': '603002', 'Price': 6.35, 'Volume': 275000, 'Side': "1", 'OrderType': '0',
                 'OrderTime': '13000015',
                 'MainSeq': 2, 'SubSeq': 6739147, 'OrderNO': 5512466, 'OrderStatus': 'D'}, 0)
            spi.l2_data_upload_manager.add_l2_order_detail(
                {'SecurityID': '603002', 'Price': 6.35, 'Volume': 200, 'Side': "1", 'OrderType': '0',
                 'OrderTime': '13000015',
                 'MainSeq': 2, 'SubSeq': 6739148, 'OrderNO': 5512467, 'OrderStatus': 'D'}, 0)
            # queue_r.put_nowait(json.dumps({"type": "listen_volume", "data": {"code": "603002", "volume": 100}}))
            time.sleep(0.1)
            spi.l2_data_upload_manager.add_l2_order_detail(
                {'SecurityID': '603002', 'Price': 6.35, 'Volume': 100, 'Side': "1", 'OrderType': '0',
                 'OrderTime': '13000015',
                 'MainSeq': 2, 'SubSeq': 6739148, 'OrderNO': 5512467, 'OrderStatus': 'D'}, 0)
        except Exception as e:
            logging.exception(e)
        finally:
            time.sleep(10)
def get_subscript_codes():
    """
    获取需要订阅的代码
@@ -383,7 +335,8 @@
            codes = get_subscript_codes()
            if codes:
                break
        except:
        except Exception as e:
            logger_system.exception(e)
            time.sleep(5)
    logger_system.info(f'可转债正股数量:{len(codes)}')
    if codes:
@@ -396,7 +349,8 @@
                pre_price_dict = get_pre_price(codes)
                if pre_price_dict:
                    break
            except:
            except Exception as e:
                logger_system.exception(e)
                time.sleep(5)
        logger_system.info(f'可转债正股昨日收盘价数量:{len(codes)}')
        if pre_price_dict: