From 7f0f9e27c6f8e86698e958f97c824db156a63f45 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Tue, 13 Jun 2017 10:37:12 +0800 Subject: [PATCH] sync vnpy1.6.2 --- vnpy/trader/app/__init__.py | 0 vnpy/trader/app/ctaStrategy/__init__.py | 0 .../trader}/app/ctaStrategy/cache/README.md | 0 .../trader}/app/ctaStrategy/ctaBacktesting.py | 10 +- .../trader}/app/ctaStrategy/ctaBase.py | 0 .../trader}/app/ctaStrategy/ctaEngine.py | 15 +- .../trader}/app/ctaStrategy/ctaGridTrade.py | 2 +- .../trader}/app/ctaStrategy/ctaHistoryData.py | 4 +- .../trader}/app/ctaStrategy/ctaLineBar.py | 4 +- .../trader}/app/ctaStrategy/ctaPolicy.py | 4 +- .../trader}/app/ctaStrategy/ctaPosition.py | 7 +- .../trader}/app/ctaStrategy/ctaTemplate.py | 2 +- .../trader}/app/ctaStrategy/data/README.md | 0 .../trader}/app/ctaStrategy/datayes.json | 0 .../trader}/app/ctaStrategy/datayesClient.py | 0 .../app/ctaStrategy/language/__init__.py | 2 +- .../ctaStrategy/language/chinese/__init__.py | 0 .../app/ctaStrategy/language/chinese/text.py | 0 .../ctaStrategy/language/english/__init__.py | 0 .../app/ctaStrategy/language/english/text.py | 0 .../app/ctaStrategy/strategy/__init__.py | 0 .../ctaStrategy/strategy/strategyAtrRsi.py | 4 +- .../trader}/app/ctaStrategy/tools/README.md | 0 vnpy/trader/app/ctaStrategy/tools/__init__.py | 0 .../app/ctaStrategy/tools/ctaLineBar.py | 0 .../Screen Shot 2016-11-08 at 9.08.47 PM.png | Bin .../tools/multiTimeFrame/__init__.py | 0 .../multiTimeFrame/ctaBacktestMultiTF.py | 0 .../multiTimeFrame/ctaStrategyMultiTF.py | 0 .../tools/multiTimeFrame/strategyBreakOut.py | 0 .../trader}/app/ctaStrategy/uiCtaWidget.py | 6 +- .../app/ctaStrategy/utilArbTickLoader.py | 0 .../trader}/app/dataRecorder/DR_setting.json | 0 vnpy/trader/app/dataRecorder/__init__.py | 0 .../trader}/app/dataRecorder/drBase.py | 2 +- .../trader}/app/dataRecorder/drEngine.py | 6 +- .../trader}/app/dataRecorder/uiDrWidget.py | 4 +- .../trader}/app/riskManager/RM_setting.json | 0 vnpy/trader/app/riskManager/__init__.py | 0 .../trader}/app/riskManager/rmEngine.py | 6 +- .../trader}/app/riskManager/uiRmWidget.py | 4 +- {trader => vnpy/trader}/logs/README.md | 0 vnpy/trader/vtObject.py | 327 ++++++++++++++++++ 43 files changed, 366 insertions(+), 43 deletions(-) create mode 100644 vnpy/trader/app/__init__.py create mode 100644 vnpy/trader/app/ctaStrategy/__init__.py rename {trader => vnpy/trader}/app/ctaStrategy/cache/README.md (100%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaBacktesting.py (99%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaBase.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaEngine.py (99%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaGridTrade.py (99%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaHistoryData.py (99%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaLineBar.py (99%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaPolicy.py (97%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaPosition.py (98%) rename {trader => vnpy/trader}/app/ctaStrategy/ctaTemplate.py (99%) rename {trader => vnpy/trader}/app/ctaStrategy/data/README.md (100%) rename {trader => vnpy/trader}/app/ctaStrategy/datayes.json (100%) rename {trader => vnpy/trader}/app/ctaStrategy/datayesClient.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/language/__init__.py (80%) create mode 100644 vnpy/trader/app/ctaStrategy/language/chinese/__init__.py rename {trader => vnpy/trader}/app/ctaStrategy/language/chinese/text.py (100%) create mode 100644 vnpy/trader/app/ctaStrategy/language/english/__init__.py rename {trader => vnpy/trader}/app/ctaStrategy/language/english/text.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/strategy/__init__.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/strategy/strategyAtrRsi.py (99%) rename {trader => vnpy/trader}/app/ctaStrategy/tools/README.md (100%) create mode 100644 vnpy/trader/app/ctaStrategy/tools/__init__.py rename {trader => vnpy/trader}/app/ctaStrategy/tools/ctaLineBar.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/tools/multiTimeFrame/Screen Shot 2016-11-08 at 9.08.47 PM.png (100%) create mode 100644 vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/__init__.py rename {trader => vnpy/trader}/app/ctaStrategy/tools/multiTimeFrame/ctaBacktestMultiTF.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/tools/multiTimeFrame/ctaStrategyMultiTF.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/tools/multiTimeFrame/strategyBreakOut.py (100%) rename {trader => vnpy/trader}/app/ctaStrategy/uiCtaWidget.py (98%) rename {trader => vnpy/trader}/app/ctaStrategy/utilArbTickLoader.py (100%) rename {trader => vnpy/trader}/app/dataRecorder/DR_setting.json (100%) create mode 100644 vnpy/trader/app/dataRecorder/__init__.py rename {trader => vnpy/trader}/app/dataRecorder/drBase.py (97%) rename {trader => vnpy/trader}/app/dataRecorder/drEngine.py (98%) rename {trader => vnpy/trader}/app/dataRecorder/uiDrWidget.py (98%) rename {trader => vnpy/trader}/app/riskManager/RM_setting.json (100%) create mode 100644 vnpy/trader/app/riskManager/__init__.py rename {trader => vnpy/trader}/app/riskManager/rmEngine.py (99%) rename {trader => vnpy/trader}/app/riskManager/uiRmWidget.py (98%) rename {trader => vnpy/trader}/logs/README.md (100%) create mode 100644 vnpy/trader/vtObject.py diff --git a/vnpy/trader/app/__init__.py b/vnpy/trader/app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/vnpy/trader/app/ctaStrategy/__init__.py b/vnpy/trader/app/ctaStrategy/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trader/app/ctaStrategy/cache/README.md b/vnpy/trader/app/ctaStrategy/cache/README.md similarity index 100% rename from trader/app/ctaStrategy/cache/README.md rename to vnpy/trader/app/ctaStrategy/cache/README.md diff --git a/trader/app/ctaStrategy/ctaBacktesting.py b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py similarity index 99% rename from trader/app/ctaStrategy/ctaBacktesting.py rename to vnpy/trader/app/ctaStrategy/ctaBacktesting.py index cc8b6feb..9cc3c73c 100644 --- a/trader/app/ctaStrategy/ctaBacktesting.py +++ b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py @@ -26,11 +26,11 @@ import pandas as pd import re -from ctaBase import * -from trader.vtConstant import * -from trader.vtGateway import VtOrderData, VtTradeData -from trader.vtFunction import loadMongoSetting -from trader.eventEngine import * +from vnpy.trader.app.ctaStrategy.ctaBase import * +from vnpy.trader.vtConstant import * +from vnpy.trader.vtGateway import VtOrderData, VtTradeData +from vnpy.trader.vtFunction import loadMongoSetting +from vnpy.trader.vtEvent import * ######################################################################## diff --git a/trader/app/ctaStrategy/ctaBase.py b/vnpy/trader/app/ctaStrategy/ctaBase.py similarity index 100% rename from trader/app/ctaStrategy/ctaBase.py rename to vnpy/trader/app/ctaStrategy/ctaBase.py diff --git a/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py similarity index 99% rename from trader/app/ctaStrategy/ctaEngine.py rename to vnpy/trader/app/ctaStrategy/ctaEngine.py index c4255249..f87b1787 100644 --- a/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -31,10 +31,10 @@ import re from ctaBase import * from strategy import STRATEGY_CLASS -from trader.eventEngine import * -from trader.vtConstant import * -from trader.vtGateway import VtSubscribeReq, VtOrderReq, VtCancelOrderReq, VtLogData -from trader.vtFunction import todayDate +from vnpy.trader.vtEvent import * +from vnpy.trader.vtConstant import * +from vnpy.trader.vtGateway import VtSubscribeReq, VtOrderReq, VtCancelOrderReq, VtLogData +from vnpy.trader.vtFunction import todayDate ######################################################################## @@ -658,9 +658,8 @@ class CtaEngine(object): if contract: # 获取合约的缩写号 s = self.getShortSymbol(symbol) - if s == symbol: # 合约缩写提取失败 - continue - + #if s == symbol: # 合约缩写提取失败 + # continue dt = datetime.now() # 若为中金所的合约,白天才提交订阅请求 if s in MARKET_ZJ and not(8 < dt.hour < 16): @@ -847,7 +846,7 @@ class CtaEngine(object): for d in posData: strategy.pos = d['pos'] except: - self.writeCtaLog(u'loadPosition Exception') + self.writeCtaLog(u'loadPosition Exception from Mongodb') # ---------------------------------------------------------------------- def roundToPriceTick(self, priceTick, price): """取整价格到合约最小价格变动""" diff --git a/trader/app/ctaStrategy/ctaGridTrade.py b/vnpy/trader/app/ctaStrategy/ctaGridTrade.py similarity index 99% rename from trader/app/ctaStrategy/ctaGridTrade.py rename to vnpy/trader/app/ctaStrategy/ctaGridTrade.py index 6377345f..1f82d62a 100644 --- a/trader/app/ctaStrategy/ctaGridTrade.py +++ b/vnpy/trader/app/ctaStrategy/ctaGridTrade.py @@ -6,7 +6,7 @@ from datetime import datetime import json from ctaBase import * -from trader.vtConstant import * +from vnpy.trader.vtConstant import * DEBUGCTALOG = True diff --git a/trader/app/ctaStrategy/ctaHistoryData.py b/vnpy/trader/app/ctaStrategy/ctaHistoryData.py similarity index 99% rename from trader/app/ctaStrategy/ctaHistoryData.py rename to vnpy/trader/app/ctaStrategy/ctaHistoryData.py index 04a00e19..dd6b47ca 100644 --- a/trader/app/ctaStrategy/ctaHistoryData.py +++ b/vnpy/trader/app/ctaStrategy/ctaHistoryData.py @@ -19,8 +19,8 @@ import pandas as pd from ctaBase import * from datayesClient import DatayesClient -from trader.vtConstant import * -from trader.vtFunction import loadMongoSetting +from vnpy.trader.vtConstant import * +from vnpy.trader.vtFunction import loadMongoSetting diff --git a/trader/app/ctaStrategy/ctaLineBar.py b/vnpy/trader/app/ctaStrategy/ctaLineBar.py similarity index 99% rename from trader/app/ctaStrategy/ctaLineBar.py rename to vnpy/trader/app/ctaStrategy/ctaLineBar.py index ae676d32..d287b748 100644 --- a/trader/app/ctaStrategy/ctaLineBar.py +++ b/vnpy/trader/app/ctaStrategy/ctaLineBar.py @@ -10,8 +10,8 @@ import numpy import copy,csv from pykalman import KalmanFilter -from ctaBase import * -from trader.vtConstant import * +from vnpy.trader.app.ctaStrategy.ctaBase import * +from vnpy.trader.vtConstant import * DEBUGCTALOG = True diff --git a/trader/app/ctaStrategy/ctaPolicy.py b/vnpy/trader/app/ctaStrategy/ctaPolicy.py similarity index 97% rename from trader/app/ctaStrategy/ctaPolicy.py rename to vnpy/trader/app/ctaStrategy/ctaPolicy.py index 53a9d2b8..c8dbc1fd 100644 --- a/trader/app/ctaStrategy/ctaPolicy.py +++ b/vnpy/trader/app/ctaStrategy/ctaPolicy.py @@ -1,7 +1,7 @@ # encoding: UTF-8 -from ctaBase import * -from trader.vtConstant import * +from vnpy.trader.app.ctaStrategy.ctaBase import * +from vnpy.trader.vtConstant import * DEBUGCTALOG = True diff --git a/trader/app/ctaStrategy/ctaPosition.py b/vnpy/trader/app/ctaStrategy/ctaPosition.py similarity index 98% rename from trader/app/ctaStrategy/ctaPosition.py rename to vnpy/trader/app/ctaStrategy/ctaPosition.py index 1374f3f1..6fbff749 100644 --- a/trader/app/ctaStrategy/ctaPosition.py +++ b/vnpy/trader/app/ctaStrategy/ctaPosition.py @@ -1,12 +1,9 @@ # encoding: UTF-8 - - from datetime import datetime -import talib as ta -from ctaBase import * -from trader.vtConstant import * +from vnpy.trader.app.ctaStrategy.ctaBase import * +from vnpy.trader.vtConstant import * DEBUGCTALOG = True diff --git a/trader/app/ctaStrategy/ctaTemplate.py b/vnpy/trader/app/ctaStrategy/ctaTemplate.py similarity index 99% rename from trader/app/ctaStrategy/ctaTemplate.py rename to vnpy/trader/app/ctaStrategy/ctaTemplate.py index 059e9b70..e50513b0 100644 --- a/trader/app/ctaStrategy/ctaTemplate.py +++ b/vnpy/trader/app/ctaStrategy/ctaTemplate.py @@ -7,7 +7,7 @@ from datetime import datetime from ctaBase import * -from trader.vtConstant import * +from vnpy.trader.vtConstant import * ######################################################################## diff --git a/trader/app/ctaStrategy/data/README.md b/vnpy/trader/app/ctaStrategy/data/README.md similarity index 100% rename from trader/app/ctaStrategy/data/README.md rename to vnpy/trader/app/ctaStrategy/data/README.md diff --git a/trader/app/ctaStrategy/datayes.json b/vnpy/trader/app/ctaStrategy/datayes.json similarity index 100% rename from trader/app/ctaStrategy/datayes.json rename to vnpy/trader/app/ctaStrategy/datayes.json diff --git a/trader/app/ctaStrategy/datayesClient.py b/vnpy/trader/app/ctaStrategy/datayesClient.py similarity index 100% rename from trader/app/ctaStrategy/datayesClient.py rename to vnpy/trader/app/ctaStrategy/datayesClient.py diff --git a/trader/app/ctaStrategy/language/__init__.py b/vnpy/trader/app/ctaStrategy/language/__init__.py similarity index 80% rename from trader/app/ctaStrategy/language/__init__.py rename to vnpy/trader/app/ctaStrategy/language/__init__.py index 00567784..ecf72358 100644 --- a/trader/app/ctaStrategy/language/__init__.py +++ b/vnpy/trader/app/ctaStrategy/language/__init__.py @@ -8,6 +8,6 @@ import traceback from chinese import text # 是否要使用英文 -from trader.vtGlobal import globalSetting +from vnpy.trader.vtGlobal import globalSetting if globalSetting['language'] == 'english': from english import text \ No newline at end of file diff --git a/vnpy/trader/app/ctaStrategy/language/chinese/__init__.py b/vnpy/trader/app/ctaStrategy/language/chinese/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trader/app/ctaStrategy/language/chinese/text.py b/vnpy/trader/app/ctaStrategy/language/chinese/text.py similarity index 100% rename from trader/app/ctaStrategy/language/chinese/text.py rename to vnpy/trader/app/ctaStrategy/language/chinese/text.py diff --git a/vnpy/trader/app/ctaStrategy/language/english/__init__.py b/vnpy/trader/app/ctaStrategy/language/english/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trader/app/ctaStrategy/language/english/text.py b/vnpy/trader/app/ctaStrategy/language/english/text.py similarity index 100% rename from trader/app/ctaStrategy/language/english/text.py rename to vnpy/trader/app/ctaStrategy/language/english/text.py diff --git a/trader/app/ctaStrategy/strategy/__init__.py b/vnpy/trader/app/ctaStrategy/strategy/__init__.py similarity index 100% rename from trader/app/ctaStrategy/strategy/__init__.py rename to vnpy/trader/app/ctaStrategy/strategy/__init__.py diff --git a/trader/app/ctaStrategy/strategy/strategyAtrRsi.py b/vnpy/trader/app/ctaStrategy/strategy/strategyAtrRsi.py similarity index 99% rename from trader/app/ctaStrategy/strategy/strategyAtrRsi.py rename to vnpy/trader/app/ctaStrategy/strategy/strategyAtrRsi.py index 7afe49c2..7e5d0bd1 100644 --- a/trader/app/ctaStrategy/strategy/strategyAtrRsi.py +++ b/vnpy/trader/app/ctaStrategy/strategy/strategyAtrRsi.py @@ -16,8 +16,8 @@ import sys import talib import numpy as np -from trader.app.ctaStrategy.ctaBase import * -from trader.app.ctaStrategy.ctaTemplate import CtaTemplate +from vnpy.trader.app.ctaStrategy.ctaBase import * +from vnpy.trader.app.ctaStrategy.ctaTemplate import CtaTemplate ######################################################################## diff --git a/trader/app/ctaStrategy/tools/README.md b/vnpy/trader/app/ctaStrategy/tools/README.md similarity index 100% rename from trader/app/ctaStrategy/tools/README.md rename to vnpy/trader/app/ctaStrategy/tools/README.md diff --git a/vnpy/trader/app/ctaStrategy/tools/__init__.py b/vnpy/trader/app/ctaStrategy/tools/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trader/app/ctaStrategy/tools/ctaLineBar.py b/vnpy/trader/app/ctaStrategy/tools/ctaLineBar.py similarity index 100% rename from trader/app/ctaStrategy/tools/ctaLineBar.py rename to vnpy/trader/app/ctaStrategy/tools/ctaLineBar.py diff --git a/trader/app/ctaStrategy/tools/multiTimeFrame/Screen Shot 2016-11-08 at 9.08.47 PM.png b/vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/Screen Shot 2016-11-08 at 9.08.47 PM.png similarity index 100% rename from trader/app/ctaStrategy/tools/multiTimeFrame/Screen Shot 2016-11-08 at 9.08.47 PM.png rename to vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/Screen Shot 2016-11-08 at 9.08.47 PM.png diff --git a/vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/__init__.py b/vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trader/app/ctaStrategy/tools/multiTimeFrame/ctaBacktestMultiTF.py b/vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/ctaBacktestMultiTF.py similarity index 100% rename from trader/app/ctaStrategy/tools/multiTimeFrame/ctaBacktestMultiTF.py rename to vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/ctaBacktestMultiTF.py diff --git a/trader/app/ctaStrategy/tools/multiTimeFrame/ctaStrategyMultiTF.py b/vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/ctaStrategyMultiTF.py similarity index 100% rename from trader/app/ctaStrategy/tools/multiTimeFrame/ctaStrategyMultiTF.py rename to vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/ctaStrategyMultiTF.py diff --git a/trader/app/ctaStrategy/tools/multiTimeFrame/strategyBreakOut.py b/vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/strategyBreakOut.py similarity index 100% rename from trader/app/ctaStrategy/tools/multiTimeFrame/strategyBreakOut.py rename to vnpy/trader/app/ctaStrategy/tools/multiTimeFrame/strategyBreakOut.py diff --git a/trader/app/ctaStrategy/uiCtaWidget.py b/vnpy/trader/app/ctaStrategy/uiCtaWidget.py similarity index 98% rename from trader/app/ctaStrategy/uiCtaWidget.py rename to vnpy/trader/app/ctaStrategy/uiCtaWidget.py index af018b73..238a28d4 100644 --- a/trader/app/ctaStrategy/uiCtaWidget.py +++ b/vnpy/trader/app/ctaStrategy/uiCtaWidget.py @@ -8,9 +8,9 @@ CTA模块相关的GUI控制组件 import os from time import sleep -from language import text -from trader.uiBasicWidget import QtGui, QtCore -from trader.eventEngine import * +from vnpy.trader.app.ctaStrategy.language import text +from vnpy.trader.uiBasicWidget import QtGui, QtCore +from vnpy.trader.vtEvent import * ######################################################################## class CtaValueMonitor(QtGui.QTableWidget): diff --git a/trader/app/ctaStrategy/utilArbTickLoader.py b/vnpy/trader/app/ctaStrategy/utilArbTickLoader.py similarity index 100% rename from trader/app/ctaStrategy/utilArbTickLoader.py rename to vnpy/trader/app/ctaStrategy/utilArbTickLoader.py diff --git a/trader/app/dataRecorder/DR_setting.json b/vnpy/trader/app/dataRecorder/DR_setting.json similarity index 100% rename from trader/app/dataRecorder/DR_setting.json rename to vnpy/trader/app/dataRecorder/DR_setting.json diff --git a/vnpy/trader/app/dataRecorder/__init__.py b/vnpy/trader/app/dataRecorder/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trader/app/dataRecorder/drBase.py b/vnpy/trader/app/dataRecorder/drBase.py similarity index 97% rename from trader/app/dataRecorder/drBase.py rename to vnpy/trader/app/dataRecorder/drBase.py index b19fa71f..9e16799e 100644 --- a/trader/app/dataRecorder/drBase.py +++ b/vnpy/trader/app/dataRecorder/drBase.py @@ -17,7 +17,7 @@ MINUTE_DB_NAME = 'VnTrader_1Min_Db' # CTA引擎中涉及的数据类定义 -from trader.vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT +from vnpy.trader.vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT ######################################################################## diff --git a/trader/app/dataRecorder/drEngine.py b/vnpy/trader/app/dataRecorder/drEngine.py similarity index 98% rename from trader/app/dataRecorder/drEngine.py rename to vnpy/trader/app/dataRecorder/drEngine.py index e391b771..19ed5cd5 100644 --- a/trader/app/dataRecorder/drEngine.py +++ b/vnpy/trader/app/dataRecorder/drEngine.py @@ -14,9 +14,9 @@ from datetime import datetime, timedelta from Queue import Queue from threading import Thread -from trader.eventEngine import * -from trader.vtGateway import VtSubscribeReq, VtLogData -from trader.vtFunction import todayDate +from vnpy.trader.vtEvent import * +from vnpy.trader.vtGateway import VtSubscribeReq, VtLogData +from vnpy.trader.vtFunction import todayDate from drBase import * diff --git a/trader/app/dataRecorder/uiDrWidget.py b/vnpy/trader/app/dataRecorder/uiDrWidget.py similarity index 98% rename from trader/app/dataRecorder/uiDrWidget.py rename to vnpy/trader/app/dataRecorder/uiDrWidget.py index c4a7e41b..7385b796 100644 --- a/trader/app/dataRecorder/uiDrWidget.py +++ b/vnpy/trader/app/dataRecorder/uiDrWidget.py @@ -6,8 +6,8 @@ import json -from trader.uiBasicWidget import QtGui, QtCore -from trader.eventEngine import * +from vnpy.trader.uiBasicWidget import QtGui, QtCore +from vnpy.trader.vtEvent import * ######################################################################## diff --git a/trader/app/riskManager/RM_setting.json b/vnpy/trader/app/riskManager/RM_setting.json similarity index 100% rename from trader/app/riskManager/RM_setting.json rename to vnpy/trader/app/riskManager/RM_setting.json diff --git a/vnpy/trader/app/riskManager/__init__.py b/vnpy/trader/app/riskManager/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/trader/app/riskManager/rmEngine.py b/vnpy/trader/app/riskManager/rmEngine.py similarity index 99% rename from trader/app/riskManager/rmEngine.py rename to vnpy/trader/app/riskManager/rmEngine.py index 77919d93..787b8d1b 100644 --- a/trader/app/riskManager/rmEngine.py +++ b/vnpy/trader/app/riskManager/rmEngine.py @@ -15,9 +15,9 @@ import os import platform from datetime import datetime -from trader.eventEngine import * -from trader.vtConstant import * -from trader.vtGateway import VtLogData +from vnpy.trader.vtEvent import * +from vnpy.trader.vtConstant import * +from vnpy.trader.vtGateway import VtLogData ######################################################################## diff --git a/trader/app/riskManager/uiRmWidget.py b/vnpy/trader/app/riskManager/uiRmWidget.py similarity index 98% rename from trader/app/riskManager/uiRmWidget.py rename to vnpy/trader/app/riskManager/uiRmWidget.py index 5b82440b..bac3fff8 100644 --- a/trader/app/riskManager/uiRmWidget.py +++ b/vnpy/trader/app/riskManager/uiRmWidget.py @@ -5,8 +5,8 @@ ''' -from trader.uiBasicWidget import QtGui, QtCore -from trader.eventEngine import * +from vnpy.trader.uiBasicWidget import QtGui, QtCore +from vnpy.trader.vtEvent import * ######################################################################## diff --git a/trader/logs/README.md b/vnpy/trader/logs/README.md similarity index 100% rename from trader/logs/README.md rename to vnpy/trader/logs/README.md diff --git a/vnpy/trader/vtObject.py b/vnpy/trader/vtObject.py new file mode 100644 index 00000000..e35c8ea1 --- /dev/null +++ b/vnpy/trader/vtObject.py @@ -0,0 +1,327 @@ +# encoding: UTF-8 + +import time +from datetime import datetime + + +from vnpy.trader.vtConstant import (EMPTY_STRING, EMPTY_UNICODE, + EMPTY_FLOAT, EMPTY_INT) + + +######################################################################## +class VtBaseData(object): + """回调函数推送数据的基础类,其他数据类继承于此""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + self.gatewayName = EMPTY_STRING # Gateway名称 + self.rawData = None # 原始数据 + + +######################################################################## +class VtTickData(VtBaseData): + """Tick行情数据类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtTickData, self).__init__() + + # 代码相关 + self.symbol = EMPTY_STRING # 合约代码 + self.exchange = EMPTY_STRING # 交易所代码 + self.vtSymbol = EMPTY_STRING # 合约在vt系统中的唯一代码,通常是 合约代码.交易所代码 + + # 成交数据 + self.lastPrice = EMPTY_FLOAT # 最新成交价 + self.lastVolume = EMPTY_INT # 最新成交量 + self.volume = EMPTY_INT # 今天总成交量 + self.preOpenInterest = EMPTY_INT # 昨持仓量 + self.openInterest = EMPTY_INT # 持仓量 + self.time = EMPTY_STRING # 时间 11:20:56.5 + self.date = EMPTY_STRING # 日期 20151009 + self.tradingDay = EMPTY_STRING # 交易日期 + + # 常规行情 + self.openPrice = EMPTY_FLOAT # 今日开盘价 + self.highPrice = EMPTY_FLOAT # 今日最高价 + self.lowPrice = EMPTY_FLOAT # 今日最低价 + self.preClosePrice = EMPTY_FLOAT # 昨收盘价 + + self.upperLimit = EMPTY_FLOAT # 涨停价 + self.lowerLimit = EMPTY_FLOAT # 跌停价 + + # 五档行情 + self.bidPrice1 = EMPTY_FLOAT + self.bidPrice2 = EMPTY_FLOAT + self.bidPrice3 = EMPTY_FLOAT + self.bidPrice4 = EMPTY_FLOAT + self.bidPrice5 = EMPTY_FLOAT + + self.askPrice1 = EMPTY_FLOAT + self.askPrice2 = EMPTY_FLOAT + self.askPrice3 = EMPTY_FLOAT + self.askPrice4 = EMPTY_FLOAT + self.askPrice5 = EMPTY_FLOAT + + self.bidVolume1 = EMPTY_INT + self.bidVolume2 = EMPTY_INT + self.bidVolume3 = EMPTY_INT + self.bidVolume4 = EMPTY_INT + self.bidVolume5 = EMPTY_INT + + self.askVolume1 = EMPTY_INT + self.askVolume2 = EMPTY_INT + self.askVolume3 = EMPTY_INT + self.askVolume4 = EMPTY_INT + self.askVolume5 = EMPTY_INT + + +######################################################################## +class VtBarData(VtBaseData): + """K线数据""" + + #---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtBarData, self).__init__() + + self.vtSymbol = EMPTY_STRING # vt系统代码 + self.symbol = EMPTY_STRING # 代码 + self.exchange = EMPTY_STRING # 交易所 + + self.open = EMPTY_FLOAT # OHLC + self.high = EMPTY_FLOAT + self.low = EMPTY_FLOAT + self.close = EMPTY_FLOAT + + self.date = EMPTY_STRING # bar开始的时间,日期 + self.time = EMPTY_STRING # 时间 + self.datetime = None # python的datetime时间对象 + + self.volume = EMPTY_INT # 成交量 + self.openInterest = EMPTY_INT # 持仓量 + + +class VtTradeData(VtBaseData): + """成交数据类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtTradeData, self).__init__() + + # 代码编号相关 + self.symbol = EMPTY_STRING # 合约代码 + self.exchange = EMPTY_STRING # 交易所代码 + self.vtSymbol = EMPTY_STRING # 合约在vt系统中的唯一代码,通常是 合约代码.交易所代码 + + self.tradeID = EMPTY_STRING # 成交编号 + self.vtTradeID = EMPTY_STRING # 成交在vt系统中的唯一编号,通常是 Gateway名.成交编号 + + self.orderID = EMPTY_STRING # 订单编号 + self.vtOrderID = EMPTY_STRING # 订单在vt系统中的唯一编号,通常是 Gateway名.订单编号 + + # 成交相关 + self.direction = EMPTY_UNICODE # 成交方向 + self.offset = EMPTY_UNICODE # 成交开平仓 + self.price = EMPTY_FLOAT # 成交价格 + self.volume = EMPTY_INT # 成交数量 + self.tradeTime = EMPTY_STRING # 成交时间 + + +######################################################################## +class VtOrderData(VtBaseData): + """订单数据类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtOrderData, self).__init__() + + # 代码编号相关 + self.symbol = EMPTY_STRING # 合约代码 + self.exchange = EMPTY_STRING # 交易所代码 + self.vtSymbol = EMPTY_STRING # 合约在vt系统中的唯一代码,通常是 合约代码.交易所代码 + + self.orderID = EMPTY_STRING # 订单编号 + self.vtOrderID = EMPTY_STRING # 订单在vt系统中的唯一编号,通常是 Gateway名.订单编号 + + # 报单相关 + self.direction = EMPTY_UNICODE # 报单方向 + self.offset = EMPTY_UNICODE # 报单开平仓 + self.price = EMPTY_FLOAT # 报单价格 + self.totalVolume = EMPTY_INT # 报单总数量 + self.tradedVolume = EMPTY_INT # 报单成交数量 + self.status = EMPTY_UNICODE # 报单状态 + + self.orderTime = EMPTY_STRING # 发单时间 + self.updateTime = EMPTY_STRING # 最后更新时间 + self.cancelTime = EMPTY_STRING # 撤单时间 + + # CTP/LTS相关 + self.frontID = EMPTY_INT # 前置机编号 + self.sessionID = EMPTY_INT # 连接编号 + + +######################################################################## +class VtPositionData(VtBaseData): + """持仓数据类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtPositionData, self).__init__() + + # 代码编号相关 + self.symbol = EMPTY_STRING # 合约代码 + self.exchange = EMPTY_STRING # 交易所代码 + self.vtSymbol = EMPTY_STRING # 合约在vt系统中的唯一代码,合约代码.交易所代码 + + # 持仓相关 + self.direction = EMPTY_STRING # 持仓方向 + self.position = EMPTY_INT # 持仓量 + self.frozen = EMPTY_INT # 冻结数量 + self.price = EMPTY_FLOAT # 持仓均价 + self.vtPositionName = EMPTY_STRING # 持仓在vt系统中的唯一代码,通常是vtSymbol.方向 + self.ydPosition = EMPTY_INT # 昨持仓 + self.positionProfit = EMPTY_FLOAT # 持仓盈亏 + + +######################################################################## +class VtAccountData(VtBaseData): + """账户数据类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtAccountData, self).__init__() + + # 账号代码相关 + self.accountID = EMPTY_STRING # 账户代码 + self.vtAccountID = EMPTY_STRING # 账户在vt中的唯一代码,通常是 Gateway名.账户代码 + + # 数值相关 + self.preBalance = EMPTY_FLOAT # 昨日账户结算净值 + self.balance = EMPTY_FLOAT # 账户净值 + self.available = EMPTY_FLOAT # 可用资金 + self.commission = EMPTY_FLOAT # 今日手续费 + self.margin = EMPTY_FLOAT # 保证金占用 + self.closeProfit = EMPTY_FLOAT # 平仓盈亏 + self.positionProfit = EMPTY_FLOAT # 持仓盈亏 + + +######################################################################## +class VtErrorData(VtBaseData): + """错误数据类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtErrorData, self).__init__() + + self.errorID = EMPTY_STRING # 错误代码 + self.errorMsg = EMPTY_UNICODE # 错误信息 + self.additionalInfo = EMPTY_UNICODE # 补充信息 + + self.errorTime = time.strftime('%X', time.localtime()) # 错误生成时间 + + +######################################################################## +class VtLogData(VtBaseData): + """日志数据类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtLogData, self).__init__() + + # self.logTime = time.strftime('%X:%f', time.localtime()) # 日志生成时间 + self.logTime = datetime.now().strftime('%X:%f') + self.logContent = EMPTY_UNICODE # 日志信息 + + +######################################################################## +class VtContractData(VtBaseData): + """合约详细信息类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + super(VtContractData, self).__init__() + + self.symbol = EMPTY_STRING # 代码 + self.exchange = EMPTY_STRING # 交易所代码 + self.vtSymbol = EMPTY_STRING # 合约在vt系统中的唯一代码,通常是 合约代码.交易所代码 + self.name = EMPTY_UNICODE # 合约中文名 + + self.productClass = EMPTY_UNICODE # 合约类型 + self.size = EMPTY_INT # 合约大小 + self.priceTick = EMPTY_FLOAT # 合约最小价格TICK + + # 期权相关 + self.strikePrice = EMPTY_FLOAT # 期权行权价 + self.underlyingSymbol = EMPTY_STRING # 标的物合约代码 + self.optionType = EMPTY_UNICODE # 期权类型 + + +######################################################################## +class VtSubscribeReq(object): + """订阅行情时传入的对象类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + self.symbol = EMPTY_STRING # 代码 + self.exchange = EMPTY_STRING # 交易所 + + # 以下为IB相关 + self.productClass = EMPTY_UNICODE # 合约类型 + self.currency = EMPTY_STRING # 合约货币 + self.expiry = EMPTY_STRING # 到期日 + self.strikePrice = EMPTY_FLOAT # 行权价 + self.optionType = EMPTY_UNICODE # 期权类型 + + +######################################################################## +class VtOrderReq(object): + """发单时传入的对象类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + self.symbol = EMPTY_STRING # 代码 + self.exchange = EMPTY_STRING # 交易所 + self.price = EMPTY_FLOAT # 价格 + self.volume = EMPTY_INT # 数量 + + self.priceType = EMPTY_STRING # 价格类型 + self.direction = EMPTY_STRING # 买卖 + self.offset = EMPTY_STRING # 开平 + + # 以下为IB相关 + self.productClass = EMPTY_UNICODE # 合约类型 + self.currency = EMPTY_STRING # 合约货币 + self.expiry = EMPTY_STRING # 到期日 + self.strikePrice = EMPTY_FLOAT # 行权价 + self.optionType = EMPTY_UNICODE # 期权类型 + self.lastTradeDateOrContractMonth = EMPTY_STRING # 合约月,IB专用 + self.multiplier = EMPTY_STRING # 乘数,IB专用 + + +######################################################################## +class VtCancelOrderReq(object): + """撤单时传入的对象类""" + + # ---------------------------------------------------------------------- + def __init__(self): + """Constructor""" + self.symbol = EMPTY_STRING # 代码 + self.exchange = EMPTY_STRING # 交易所 + + # 以下字段主要和CTP、LTS类接口相关 + self.orderID = EMPTY_STRING # 报单号 + self.frontID = EMPTY_STRING # 前置机号 + self.sessionID = EMPTY_STRING # 会话号 +