diff --git a/vn.oanda/vnoanda.py b/vn.oanda/vnoanda.py index a53eafe9..6272b651 100644 --- a/vn.oanda/vnoanda.py +++ b/vn.oanda/vnoanda.py @@ -9,7 +9,7 @@ from threading import Thread API_SETTING = {} API_SETTING['practice'] = {'rest': 'https://api-fxpractice.oanda.com', 'stream': 'https://stream-fxpractice.oanda.com'} -API_SETTING['trade'] = {'rest': 'https://api-fxpractice.oanda.com', +API_SETTING['trade'] = {'rest': 'https://api-fxtrade.oanda.com', 'stream': 'https://stream-fxtrade.oanda.com/'} diff --git a/vn.trader/ctaAlgo/ctaDemo.py b/vn.trader/ctaAlgo/ctaDemo.py index 32612a4a..660c6667 100644 --- a/vn.trader/ctaAlgo/ctaDemo.py +++ b/vn.trader/ctaAlgo/ctaDemo.py @@ -181,15 +181,13 @@ class DoubleEmaDemo(CtaTemplate): ######################################################################################## -## 基于tick级别细粒度撤单追单测试demo - class OrderManagementDemo(CtaTemplate): - """追撤单策略Demo""" + """基于tick级别细粒度撤单追单测试demo""" + className = 'OrderManagementDemo' author = u'用Python的交易员' # 策略参数 - initDays = 10 # 初始化数据所用的天数 # 策略变量 @@ -212,10 +210,10 @@ class OrderManagementDemo(CtaTemplate): def __init__(self, ctaEngine, setting): """Constructor""" super(OrderManagementDemo, self).__init__(ctaEngine, setting) - - self.lastOrder = None + + self.lastOrder = None self.orderType = '' - + #---------------------------------------------------------------------- def onInit(self): """初始化策略(必须由用户继承实现)""" @@ -243,11 +241,11 @@ class OrderManagementDemo(CtaTemplate): def onTick(self, tick): """收到行情TICK推送(必须由用户继承实现)""" - # 建立不成交买单测试单 - if self.lastOrder == None: - self.buy(tick.lastprice - 10.0, 1) + # 建立不成交买单测试单 + if self.lastOrder == None: + self.buy(tick.lastprice - 10.0, 1) - # CTA委托类型映射 + # CTA委托类型映射 if self.lastOrder != None and self.lastOrder.direction == u'多' and self.lastOrder.offset == u'开仓': self.orderType = u'买开' @@ -259,21 +257,22 @@ class OrderManagementDemo(CtaTemplate): elif self.lastOrder != None and self.lastOrder.direction == u'空' and self.lastOrder.offset == u'平仓': self.orderType = u'卖平' - - # 不成交,即撤单,并追单 + + # 不成交,即撤单,并追单 if self.lastOrder != None and self.lastOrder.status == u'未成交': self.cancelOrder(self.lastOrder.vtOrderID) self.lastOrder = None elif self.lastOrder != None and self.lastOrder.status == u'已撤销': - # 追单并设置为不能成交 + # 追单并设置为不能成交 self.sendOrder(self.orderType, self.tick.lastprice - 10, 1) self.lastOrder = None + #---------------------------------------------------------------------- def onBar(self, bar): """收到Bar推送(必须由用户继承实现)""" - pass + pass #---------------------------------------------------------------------- def onOrder(self, order): diff --git a/vn.trader/oandaGateway/vnoanda.py b/vn.trader/oandaGateway/vnoanda.py index 570d3f73..62f29609 100644 --- a/vn.trader/oandaGateway/vnoanda.py +++ b/vn.trader/oandaGateway/vnoanda.py @@ -9,7 +9,7 @@ from threading import Thread API_SETTING = {} API_SETTING['practice'] = {'rest': 'https://api-fxpractice.oanda.com', 'stream': 'https://stream-fxpractice.oanda.com'} -API_SETTING['trade'] = {'rest': 'https://api-fxpractice.oanda.com', +API_SETTING['trade'] = {'rest': 'https://api-fxtrade.oanda.com', 'stream': 'https://stream-fxtrade.oanda.com/'}