# vnpy_ctp **Repository Path**: marketmaking/vnpy_ctp ## Basic Information - **Project Name**: vnpy_ctp - **Description**: vn.py框架的CTP交易接口 - **Primary Language**: C++ - **License**: MIT - **Default Branch**: main - **Homepage**: https://www.vnpy.com - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 60 - **Created**: 2022-10-13 - **Last Updated**: 2022-10-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # VeighNa框架的CTP底层接口 修改版本 ctp_gateway 修改函数 支持了timestamp 不同数据类型的情况 ```python def onRtnOrder(self, data: dict) -> None: """委托更新推送""" if not self.contract_inited: self.order_data.append(data) return symbol: str = data["InstrumentID"] contract: ContractData = symbol_contract_map[symbol] frontid: int = data["FrontID"] sessionid: int = data["SessionID"] order_ref: str = data["OrderRef"] orderid: str = f"{frontid}_{sessionid}_{order_ref}" timestamp: str = f"{data['InsertDate']} {data['InsertTime']}" # print(timestamp) # dt: datetime = datetime.strptime(timestamp, "%Y%m%d %H:%M:%S") # dt: datetime = CHINA_TZ.localize(dt) if len(str(int(timestamp))) == 8: print(timestamp[:4], timestamp[4:6], timestamp[6:8]) year = int(timestamp[:4]) month = int(timestamp[4:6]) day = int(timestamp[6:8]) now = date(year, month, day) dt: datetime = now.strftime("%Y%m%d %H:%M:%S") # dt: datetime = dt.replace(tzinfo=CHINA_TZ) print(dt) else: dt: datetime = datetime.strptime(timestamp, "%Y%m%d %H:%M:%S") dt: datetime = dt.replace(tzinfo=CHINA_TZ) tp: tuple = (data["OrderPriceType"], data["TimeCondition"], data["VolumeCondition"]) order: OrderData = OrderData( symbol=symbol, exchange=contract.exchange, orderid=orderid, type=ORDERTYPE_CTP2VT[tp], direction=DIRECTION_CTP2VT[data["Direction"]], offset=OFFSET_CTP2VT[data["CombOffsetFlag"]], price=data["LimitPrice"], volume=data["VolumeTotalOriginal"], traded=data["VolumeTraded"], status=STATUS_CTP2VT[data["OrderStatus"]], datetime=dt, gateway_name=self.gateway_name ) self.gateway.on_order(order) self.sysid_orderid_map[data["OrderSysID"]] = orderid ```