| | |
| | | |
| | | # 买入的大单订单号 |
| | | |
| | | def __init__(self, api, ): |
| | | def __init__(self, api, codes): |
| | | lev2mdapi.CTORATstpLev2MdSpi.__init__(self) |
| | | self.__api = api |
| | | self.is_login = False |
| | | self.codes = codes |
| | | |
| | | def __split_codes(self, codes): |
| | | szse_codes = [] |
| | |
| | | print("----L2行情登录成功----") |
| | | self.is_login = True |
| | | logger_system.info(f"L2行情登录成功") |
| | | self.set_codes_data(self.codes) |
| | | |
| | | def OnRspSubTransaction(self, pSpecificSecurity, pRspInfo, nRequestID, bIsLast): |
| | | logger_local_huaxin_l2_subscript.info(f"订阅:{pSpecificSecurity['SecurityID']}") |
| | |
| | | logging.exception(e) |
| | | |
| | | |
| | | def __init_l2(): |
| | | def __init_l2(codes): |
| | | print(lev2mdapi.CTORATstpLev2MdApi_GetApiVersion()) |
| | | # case 1: Tcp方式 |
| | | # g_SubMode=lev2mdapi.TORA_TSTP_MST_TCP |
| | |
| | | # case 2非缓存模式 |
| | | # api = lev2mdapi.CTORATstpLev2MdApi_CreateTstpLev2MdApi(g_SubMode, False) |
| | | global spi |
| | | spi = Lev2MdSpi(api) |
| | | spi = Lev2MdSpi(api,codes) |
| | | api.RegisterSpi(spi) |
| | | # -------------------正式模式------------------------------------- |
| | | if g_SubMode != lev2mdapi.TORA_TSTP_MST_MCAST: |
| | |
| | | else: |
| | | limit_up_price = tool.to_price(decimal.Decimal(str(pre_price_dict[k])) * decimal.Decimal("1.2")) |
| | | Lev2MdSpi.limit_up_price_dict[k] = round(float(limit_up_price), 2) |
| | | return codes |
| | | |
| | | |
| | | def run() -> None: |
| | |
| | | try: |
| | | log.close_print() |
| | | # 初始化 |
| | | __init_l2() |
| | | __init_data() |
| | | codes = __init_data() |
| | | __init_l2(codes) |
| | | |
| | | |
| | | threading.Thread(target=huaxin_l2_log.run_sync, daemon=True).start() |
| | | # TODO 测试 |