[Add] oes: added order_type to OrderData.

This commit is contained in:
nanoric 2019-03-22 04:12:19 -04:00
parent 9e91df57d4
commit 6ceacc94c1
2 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,6 @@
# encoding: UTF-8 # encoding: UTF-8
""" """
Author: nanoric
""" """
import hashlib import hashlib
import os import os

View File

@ -18,7 +18,6 @@ from vnpy.api.oes.vnoes import OesApiClientEnvT, OesApiSubscribeInfoT, OesApi_De
OesRspMsgBodyT, OesStockBaseInfoT, OesTrdCnfmT, SGeneralClientChannelT, SMSG_PROTO_BINARY, \ OesRspMsgBodyT, OesStockBaseInfoT, OesTrdCnfmT, SGeneralClientChannelT, SMSG_PROTO_BINARY, \
SMsgHeadT, cast, eOesBuySellTypeT, eOesMarketIdT, eOesMsgTypeT, \ SMsgHeadT, cast, eOesBuySellTypeT, eOesMarketIdT, eOesMsgTypeT, \
eOesOrdStatusT, eOesOrdTypeShT, eOesOrdTypeSzT, eOesSubscribeReportTypeT eOesOrdStatusT, eOesOrdTypeShT, eOesOrdTypeSzT, eOesSubscribeReportTypeT
from vnpy.gateway.oes.error_code import error_to_str from vnpy.gateway.oes.error_code import error_to_str
from vnpy.gateway.oes.utils import create_remote_config, is_disconnected from vnpy.gateway.oes.utils import create_remote_config, is_disconnected
from vnpy.trader.constant import Direction, Exchange, Offset, OrderType, Product, Status from vnpy.trader.constant import Direction, Exchange, Offset, OrderType, Product, Status
@ -44,6 +43,10 @@ ORDER_TYPE_VT2OES = {
(Exchange.SSE, OrderType.LIMIT): eOesOrdTypeShT.OES_ORD_TYPE_SH_LMT, (Exchange.SSE, OrderType.LIMIT): eOesOrdTypeShT.OES_ORD_TYPE_SH_LMT,
(Exchange.SZSE, OrderType.LIMIT): eOesOrdTypeSzT.OES_ORD_TYPE_SZ_LMT, (Exchange.SZSE, OrderType.LIMIT): eOesOrdTypeSzT.OES_ORD_TYPE_SZ_LMT,
} }
ORDER_TYPE_OES2VT = {
(eOesMarketIdT.OES_MKT_SH_ASHARE, eOesOrdTypeShT.OES_ORD_TYPE_SH_LMT): OrderType.LIMIT,
(eOesMarketIdT.OES_MKT_SZ_ASHARE, eOesOrdTypeSzT.OES_ORD_TYPE_SZ_LMT): OrderType.LIMIT,
}
BUY_SELL_TYPE_VT2OES = { BUY_SELL_TYPE_VT2OES = {
(Exchange.SSE, Offset.OPEN, Direction.LONG): eOesBuySellTypeT.OES_BS_TYPE_BUY, (Exchange.SSE, Offset.OPEN, Direction.LONG): eOesBuySellTypeT.OES_BS_TYPE_BUY,
@ -737,12 +740,14 @@ class OesTdApi:
symbol=data.securityId, symbol=data.securityId,
exchange=EXCHANGE_OES2VT[data.mktId], exchange=EXCHANGE_OES2VT[data.mktId],
orderid=str(order_id if order_id else data.origClSeqNo), # generated id orderid=str(order_id if order_id else data.origClSeqNo), # generated id
type=ORDER_TYPE_OES2VT[(data.mktId, data.ordType)],
direction=Direction.NET, direction=Direction.NET,
offset=offset, offset=offset,
price=data.ordPrice / 10000, price=data.ordPrice / 10000,
volume=data.ordQty - data.canceledQty, volume=data.ordQty - data.canceledQty,
traded=data.cumQty, traded=data.cumQty,
status=STATUS_OES2VT[data.ordStatus], status=STATUS_OES2VT[
data.ordStatus],
# this time should be generated automatically or by a static function # this time should be generated automatically or by a static function
time=datetime.utcnow().isoformat(), time=datetime.utcnow().isoformat(),