diff --git a/vnpy/trader/language/chinese/constant.py b/vnpy/trader/language/chinese/constant.py index 08743346..5d14ada9 100644 --- a/vnpy/trader/language/chinese/constant.py +++ b/vnpy/trader/language/chinese/constant.py @@ -110,4 +110,14 @@ GATEWAYTYPE_EQUITY = 'equity' # 股票、ETF、债券 GATEWAYTYPE_FUTURES = 'futures' # 期货、期权、贵金属 GATEWAYTYPE_INTERNATIONAL = 'international' # 外盘 GATEWAYTYPE_BTC = 'btc' # 比特币 -GATEWAYTYPE_DATA = 'data' # 数据(非交易) \ No newline at end of file +GATEWAYTYPE_DATA = 'data' # 数据(非交易) + +# K线周期类型 +INTERVAL_1M = u'1分钟' +INTERVAL_5M = u'5分钟' +INTERVAL_15M = u'15分钟' +INTERVAL_30M = u'30分钟' +INTERVAL_1H = u'1小时' +INTERVAL_4H = u'4小时' +INTERVAL_DAILY = u'日线' +INTERVAL_WEEKLY = u'周线' \ No newline at end of file diff --git a/vnpy/trader/language/english/constant.py b/vnpy/trader/language/english/constant.py index b5caeabe..27c01542 100644 --- a/vnpy/trader/language/english/constant.py +++ b/vnpy/trader/language/english/constant.py @@ -106,4 +106,15 @@ GATEWAYTYPE_EQUITY = 'equity' # 股票、ETF、债券 GATEWAYTYPE_FUTURES = 'futures' # 期货、期权、贵金属 GATEWAYTYPE_INTERNATIONAL = 'international' # 外盘 GATEWAYTYPE_BTC = 'btc' # 比特币 -GATEWAYTYPE_DATA = 'data' # 数据(非交易) \ No newline at end of file +GATEWAYTYPE_DATA = 'data' # 数据(非交易) + + +# K线周期类型 +INTERVAL_1M = u'1-Minute' +INTERVAL_5M = u'5-Minute' +INTERVAL_15M = u'15-Minute' +INTERVAL_30M = u'30-Minute' +INTERVAL_1H = u'1-Hour' +INTERVAL_4H = u'4-Hour' +INTERVAL_DAILY = u'Daily' +INTERVAL_WEEKLY = u'Weekly' \ No newline at end of file diff --git a/vnpy/trader/vtEvent.py b/vnpy/trader/vtEvent.py index 4c5c67ef..14ea8178 100644 --- a/vnpy/trader/vtEvent.py +++ b/vnpy/trader/vtEvent.py @@ -17,4 +17,5 @@ EVENT_ORDER = 'eOrder.' # 报单回报事件 EVENT_POSITION = 'ePosition.' # 持仓回报事件 EVENT_ACCOUNT = 'eAccount.' # 账户回报事件 EVENT_CONTRACT = 'eContract.' # 合约基础信息回报事件 -EVENT_ERROR = 'eError.' # 错误回报事件 \ No newline at end of file +EVENT_ERROR = 'eError.' # 错误回报事件 +EVENT_HISTORY = 'eHistory.' # K线数据查询回报事件 \ No newline at end of file diff --git a/vnpy/trader/vtGateway.py b/vnpy/trader/vtGateway.py index 5e63cc67..0df2366d 100644 --- a/vnpy/trader/vtGateway.py +++ b/vnpy/trader/vtGateway.py @@ -108,6 +108,13 @@ class VtGateway(object): event1.dict_['data'] = contract self.eventEngine.put(event1) + #---------------------------------------------------------------------- + def onHistory(self, history): + """历史数据推送""" + event = Event(EVENT_HISTORY) + event.dict_['data'] = history + self.eventEngine.put(event) + #---------------------------------------------------------------------- def connect(self): """连接""" @@ -138,6 +145,11 @@ class VtGateway(object): """查询持仓""" pass + #---------------------------------------------------------------------- + def qryHistory(self, historyReq): + """查询历史""" + pass + #---------------------------------------------------------------------- def close(self): """关闭""" diff --git a/vnpy/trader/vtObject.py b/vnpy/trader/vtObject.py index 2a3a4cb9..966be5fe 100644 --- a/vnpy/trader/vtObject.py +++ b/vnpy/trader/vtObject.py @@ -265,6 +265,22 @@ class VtContractData(VtBaseData): self.expiryDate = EMPTY_STRING # 到期日 +######################################################################## +class VtHistoryData(object): + """K线时间序列数据""" + + #---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + self.vtSymbol = EMPTY_STRING # vt系统代码 + self.symbol = EMPTY_STRING # 代码 + self.exchange = EMPTY_STRING # 交易所 + + self.interval = EMPTY_UNICODE # K线时间周期 + self.queryID = EMPTY_STRING # 查询号 + self.barList = [] # VtBarData列表 + + ######################################################################## class VtSubscribeReq(object): """订阅行情时传入的对象类""" @@ -327,6 +343,22 @@ class VtCancelOrderReq(object): self.sessionID = EMPTY_STRING # 会话号 +######################################################################## +class VtHistoryReq(object): + """查询历史数据时传入的对象类""" + + #---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + self.symbol = EMPTY_STRING # 代码 + self.exchange = EMPTY_STRING # 交易所 + self.vtSymbol = EMPTY_STRING # VT合约代码 + + self.interval = EMPTY_UNICODE # K线周期 + self.start = None # 起始时间datetime对象 + self.end = None # 结束时间datetime对象 + + ######################################################################## class VtSingleton(type): """