From 28627b1cd45221a8ff0b455947231ce25df74c41 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 12 May 2018 17:40:51 +0800 Subject: [PATCH] =?UTF-8?q?[Add]CTA=E6=A8=A1=E5=9D=97=E6=96=B0=E5=A2=9Eget?= =?UTF-8?q?PriceTick=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/ctaStrategy/ctaBacktesting.py | 8 ++++++-- vnpy/trader/app/ctaStrategy/ctaEngine.py | 9 +++++++++ vnpy/trader/app/ctaStrategy/ctaTemplate.py | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py index a7818450..c0bb5c6d 100644 --- a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py +++ b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py @@ -568,8 +568,12 @@ class BacktestingEngine(object): def saveSyncData(self, strategy): """保存同步数据(无效)""" pass - - + + #---------------------------------------------------------------------- + def getPriceTick(self, strategy): + """获取最小价格变动""" + return self.priceTick + #------------------------------------------------ # 结果计算相关 #------------------------------------------------ diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index 1e575e21..ba25d273 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -643,3 +643,12 @@ class CtaEngine(object): else: self.cancelOrder(orderID) + #---------------------------------------------------------------------- + def getPriceTick(self, strategy): + """获取最小价格变动""" + contract = self.mainEngine.getContract(strategy.vtSymbol) + if contract: + return contract.priceTick + return 0 + + \ No newline at end of file diff --git a/vnpy/trader/app/ctaStrategy/ctaTemplate.py b/vnpy/trader/app/ctaStrategy/ctaTemplate.py index e050f4d0..5f829d0f 100644 --- a/vnpy/trader/app/ctaStrategy/ctaTemplate.py +++ b/vnpy/trader/app/ctaStrategy/ctaTemplate.py @@ -195,6 +195,12 @@ class CtaTemplate(object): if self.trading: self.ctaEngine.saveSyncData(self) + #---------------------------------------------------------------------- + def getPriceTick(self): + """查询最小价格变动""" + return self.ctaEngine.getPriceTick(self) + + ######################################################################## class TargetPosTemplate(CtaTemplate):