[Add]新增历史数据相关类和函数
This commit is contained in:
parent
23a14a7a19
commit
0a2d54e826
@ -110,4 +110,14 @@ GATEWAYTYPE_EQUITY = 'equity' # 股票、ETF、债券
|
||||
GATEWAYTYPE_FUTURES = 'futures' # 期货、期权、贵金属
|
||||
GATEWAYTYPE_INTERNATIONAL = 'international' # 外盘
|
||||
GATEWAYTYPE_BTC = 'btc' # 比特币
|
||||
GATEWAYTYPE_DATA = 'data' # 数据(非交易)
|
||||
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'周线'
|
@ -106,4 +106,15 @@ GATEWAYTYPE_EQUITY = 'equity' # 股票、ETF、债券
|
||||
GATEWAYTYPE_FUTURES = 'futures' # 期货、期权、贵金属
|
||||
GATEWAYTYPE_INTERNATIONAL = 'international' # 外盘
|
||||
GATEWAYTYPE_BTC = 'btc' # 比特币
|
||||
GATEWAYTYPE_DATA = 'data' # 数据(非交易)
|
||||
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'
|
@ -17,4 +17,5 @@ EVENT_ORDER = 'eOrder.' # 报单回报事件
|
||||
EVENT_POSITION = 'ePosition.' # 持仓回报事件
|
||||
EVENT_ACCOUNT = 'eAccount.' # 账户回报事件
|
||||
EVENT_CONTRACT = 'eContract.' # 合约基础信息回报事件
|
||||
EVENT_ERROR = 'eError.' # 错误回报事件
|
||||
EVENT_ERROR = 'eError.' # 错误回报事件
|
||||
EVENT_HISTORY = 'eHistory.' # K线数据查询回报事件
|
@ -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):
|
||||
"""关闭"""
|
||||
|
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user