VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 27
声望: 1

使用脚本模式,结算信息确认成功后,一直也未输出“合约信息查询成功”,也没有任何提示。发送交易订单也没有任何输出。
偶尔会出现这种情况,我想加一个判断,如果未查询成功就断开重连一次,否则没有任何提示也不知道出问题了。

请问各位大神这个怎么处理呢?
我在CTPgateway中找到了输出合约信息查询成功的onRspQryInstrument()回报函数,但是在vnpy文件夹下没有找到任何这个函数的调用,不知道从何加起,
希望有大神指点一下。

   def onRspQryInstrument(self, data: dict, error: dict, reqid: int, last: bool):
        """
        Callback of instrument query.
        """
        product = PRODUCT_CTP2VT.get(data["ProductClass"], None)
        if product:
            contract = ContractData(
                symbol=data["InstrumentID"],
                exchange=EXCHANGE_CTP2VT[data["ExchangeID"]],
                name=data["InstrumentName"],
                product=product,
                size=data["VolumeMultiple"],
                pricetick=data["PriceTick"],
                gateway_name=self.gateway_name,
                long_margin_ratio = data["LongMarginRatio"],
                short_margin_ratio = data["ShortMarginRatio"],
            )

            # For option only
            if contract.product == Product.OPTION:
                # Remove C/P suffix of CZCE option product name
                if contract.exchange == Exchange.CZCE:
                    contract.option_portfolio = data["ProductID"][:-1]
                else:
                    contract.option_portfolio = data["ProductID"]

                contract.option_underlying = data["UnderlyingInstrID"]
                contract.option_type = OPTIONTYPE_CTP2VT.get(data["OptionsType"], None)
                contract.option_strike = data["StrikePrice"]
                contract.option_index = str(data["StrikePrice"])
                contract.option_expiry = datetime.strptime(data["ExpireDate"], "%Y%m%d")

            self.gateway.on_contract(contract)

            symbol_exchange_map[contract.symbol] = contract.exchange
            symbol_name_map[contract.symbol] = contract.name
            symbol_size_map[contract.symbol] = contract.size

        if last:
            self.gateway.write_log("合约信息查询成功")

            for data in self.order_data:
                self.onRtnOrder(data)
            self.order_data.clear()

            for data in self.trade_data:
                self.onRtnTrade(data)
            self.trade_data.clear()
Member
avatar
加入于:
帖子: 716
声望: 62

on开头的时回调函数,是由交易所调用的,不需要主动调用。

Member
avatar
加入于:
帖子: 27
声望: 1

郭易燔 wrote:

on开头的时回调函数,是由交易所调用的,不需要主动调用。

这样啊,谢谢大神,能方便再指导一下VNPY接收回调信息的部分代码在哪个文件下么,没找到啊

Member
avatar
加入于:
帖子: 716
声望: 62

你贴的这个就是

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】