[Mod]BarManager改名为BarGenerator,close #607

This commit is contained in:
vn.py 2017-12-15 20:19:50 +08:00
parent 1abb73c7ab
commit 527d4bf779
10 changed files with 31 additions and 33 deletions

View File

@ -16,8 +16,7 @@ from vnpy.trader.uiQt import createQApp
from vnpy.trader.uiMainWindow import MainWindow
# 加载底层接口
from vnpy.trader.gateway import (ctpGateway, oandaGateway, ibGateway,
tkproGateway)
from vnpy.trader.gateway import (ctpGateway, oandaGateway, ibGateway)
if system == 'Windows':
from vnpy.trader.gateway import (femasGateway, xspeedGateway,
@ -44,7 +43,6 @@ def main():
# 添加交易接口
me.addGateway(ctpGateway)
me.addGateway(tkproGateway)
me.addGateway(oandaGateway)
me.addGateway(ibGateway)

View File

@ -323,7 +323,7 @@ class TargetPosTemplate(CtaTemplate):
########################################################################
class BarManager(object):
class BarGenerator(object):
"""
K线合成器支持
1. 基于Tick合成1分钟K线

View File

@ -13,7 +13,7 @@
from vnpy.trader.vtObject import VtBarData
from vnpy.trader.vtConstant import EMPTY_STRING
from vnpy.trader.app.ctaStrategy.ctaTemplate import (CtaTemplate,
BarManager,
BarGenerator,
ArrayManager)
@ -73,7 +73,7 @@ class AtrRsiStrategy(CtaTemplate):
super(AtrRsiStrategy, self).__init__(ctaEngine, setting)
# 创建K线合成器对象
self.bm = BarManager(self.onBar)
self.bg = BarGenerator(self.onBar)
self.am = ArrayManager()
# 注意策略类中的可变对象属性通常是list和dict等在策略初始化时需要重新创建
@ -112,7 +112,7 @@ class AtrRsiStrategy(CtaTemplate):
#----------------------------------------------------------------------
def onTick(self, tick):
"""收到行情TICK推送必须由用户继承实现"""
self.bm.updateTick(tick)
self.bg.updateTick(tick)
#----------------------------------------------------------------------
def onBar(self, bar):

View File

@ -21,7 +21,7 @@ from __future__ import division
from vnpy.trader.vtObject import VtBarData
from vnpy.trader.vtConstant import EMPTY_STRING
from vnpy.trader.app.ctaStrategy.ctaTemplate import (CtaTemplate,
BarManager,
BarGenerator,
ArrayManager)
@ -87,8 +87,8 @@ class BollChannelStrategy(CtaTemplate):
"""Constructor"""
super(BollChannelStrategy, self).__init__(ctaEngine, setting)
self.bm = BarManager(self.onBar, 15, self.onXminBar) # 创建K线合成器对象
self.bm30 = BarManager(self.onBar, 30, self.on30minBar)
self.bg = BarGenerator(self.onBar, 15, self.onXminBar) # 创建K线合成器对象
self.bg30 = BarGenerator(self.onBar, 30, self.on30minBar)
self.am = ArrayManager()
#----------------------------------------------------------------------
@ -123,12 +123,12 @@ class BollChannelStrategy(CtaTemplate):
#----------------------------------------------------------------------
def onTick(self, tick):
"""收到行情TICK推送必须由用户继承实现"""
self.bm.updateTick(tick)
self.bg.updateTick(tick)
#----------------------------------------------------------------------
def onBar(self, bar):
"""收到Bar推送必须由用户继承实现"""
self.bm.updateBar(bar)
self.bg.updateBar(bar)
#----------------------------------------------------------------------
def onXminBar(self, bar):

View File

@ -15,7 +15,7 @@ from __future__ import division
from vnpy.trader.vtConstant import EMPTY_STRING, EMPTY_FLOAT
from vnpy.trader.app.ctaStrategy.ctaTemplate import (CtaTemplate,
BarManager,
BarGenerator,
ArrayManager)
@ -62,7 +62,7 @@ class DoubleMaStrategy(CtaTemplate):
"""Constructor"""
super(DoubleMaStrategy, self).__init__(ctaEngine, setting)
self.bm = BarManager(self.onBar)
self.bg = BarGenerator(self.onBar)
self.am = ArrayManager()
# 注意策略类中的可变对象属性通常是list和dict等在策略初始化时需要重新创建
@ -96,7 +96,7 @@ class DoubleMaStrategy(CtaTemplate):
#----------------------------------------------------------------------
def onTick(self, tick):
"""收到行情TICK推送必须由用户继承实现"""
self.bm.updateTick(tick)
self.bg.updateTick(tick)
#----------------------------------------------------------------------
def onBar(self, bar):

View File

@ -8,7 +8,7 @@ from datetime import time
from vnpy.trader.vtObject import VtBarData
from vnpy.trader.vtConstant import EMPTY_STRING
from vnpy.trader.app.ctaStrategy.ctaTemplate import CtaTemplate, BarManager
from vnpy.trader.app.ctaStrategy.ctaTemplate import CtaTemplate, BarGenerator
########################################################################
@ -64,7 +64,7 @@ class DualThrustStrategy(CtaTemplate):
"""Constructor"""
super(DualThrustStrategy, self).__init__(ctaEngine, setting)
self.bm = BarManager(self.onBar)
self.bg = BarGenerator(self.onBar)
self.barList = []
#----------------------------------------------------------------------
@ -94,7 +94,7 @@ class DualThrustStrategy(CtaTemplate):
#----------------------------------------------------------------------
def onTick(self, tick):
"""收到行情TICK推送必须由用户继承实现"""
self.bm.updateTick(tick)
self.bg.updateTick(tick)
#----------------------------------------------------------------------
def onBar(self, bar):

View File

@ -15,7 +15,7 @@ from __future__ import division
from vnpy.trader.vtObject import VtBarData
from vnpy.trader.vtConstant import EMPTY_STRING
from vnpy.trader.app.ctaStrategy.ctaTemplate import (CtaTemplate,
BarManager,
BarGenerator,
ArrayManager)
@ -67,7 +67,7 @@ class KkStrategy(CtaTemplate):
"""Constructor"""
super(KkStrategy, self).__init__(ctaEngine, setting)
self.bm = BarManager(self.onBar, 5, self.onFiveBar) # 创建K线合成器对象
self.bg = BarGenerator(self.onBar, 5, self.onFiveBar) # 创建K线合成器对象
self.am = ArrayManager()
self.buyOrderIDList = []
@ -101,12 +101,12 @@ class KkStrategy(CtaTemplate):
#----------------------------------------------------------------------
def onTick(self, tick):
"""收到行情TICK推送必须由用户继承实现"""
self.bm.updateTick(tick)
self.bg.updateTick(tick)
#----------------------------------------------------------------------
def onBar(self, bar):
"""收到Bar推送必须由用户继承实现"""
self.bm.updateBar(bar)
self.bg.updateBar(bar)
#----------------------------------------------------------------------
def onFiveBar(self, bar):

View File

@ -7,7 +7,7 @@
from vnpy.trader.vtObject import VtBarData
from vnpy.trader.vtConstant import EMPTY_STRING
from vnpy.trader.app.ctaStrategy.ctaTemplate import (CtaTemplate,
BarManager,
BarGenerator,
ArrayManager)
@ -67,10 +67,10 @@ class MultiTimeframeStrategy(CtaTemplate):
self.rsiShort = 50 - self.rsiSignal
# 创建K线合成器对象
self.bm5 = BarManager(self.onBar, 5, self.on5MinBar)
self.bg5 = BarGenerator(self.onBar, 5, self.on5MinBar)
self.am5 = ArrayManager()
self.bm15 = BarManager(self.onBar, 15, self.on15MinBar)
self.bg15 = BarGenerator(self.onBar, 15, self.on15MinBar)
self.am15 = ArrayManager()
#----------------------------------------------------------------------
@ -101,16 +101,16 @@ class MultiTimeframeStrategy(CtaTemplate):
def onTick(self, tick):
"""收到行情TICK推送必须由用户继承实现"""
# 只需要要在一个BM中合成1分钟K线
self.bm5.updateTick(tick)
self.bg5.updateTick(tick)
#----------------------------------------------------------------------
def onBar(self, bar):
"""收到Bar推送必须由用户继承实现"""
# 基于15分钟判断趋势过滤因此先更新
self.bm15.updateBar(bar)
self.bg15.updateBar(bar)
# 基于5分钟判断
self.bm5.updateBar(bar)
self.bg5.updateBar(bar)
#----------------------------------------------------------------------
def on5MinBar(self, bar):

View File

@ -19,7 +19,7 @@ from vnpy.event import Event
from vnpy.trader.vtEvent import *
from vnpy.trader.vtFunction import todayDate, getJsonPath
from vnpy.trader.vtObject import VtSubscribeReq, VtLogData, VtBarData, VtTickData
from vnpy.trader.app.ctaStrategy.ctaTemplate import BarManager
from vnpy.trader.app.ctaStrategy.ctaTemplate import BarGenerator
from .drBase import *
from .language import text
@ -48,7 +48,7 @@ class DrEngine(object):
self.tickSymbolSet = set()
# K线合成器字典
self.bmDict = {}
self.bgDict = {}
# 配置字典
self.settingDict = OrderedDict()
@ -153,7 +153,7 @@ class DrEngine(object):
d['bar'] = True
# 创建BarManager对象
self.bmDict[vtSymbol] = BarManager(self.onBar)
self.bgDict[vtSymbol] = BarGenerator(self.onBar)
# 主力合约记录配置
if 'active' in drSetting:
@ -177,7 +177,7 @@ class DrEngine(object):
self.onTick(tick)
bm = self.bmDict.get(vtSymbol, None)
bm = self.bgDict.get(vtSymbol, None)
if bm:
bm.updateTick(tick)

View File

@ -7,4 +7,4 @@ appName = 'RtdService'
appDisplayName = u'RTD服务'
appEngine = RtdEngine
appWidget = RtdManager
appIco = 'rtd.ico'
appIco = 'rtd.ico'