Skip to content

Commit

Permalink
全部改为绝对引用
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy-dev-01 committed May 15, 2017
1 parent 7353c40 commit 426f92c
Show file tree
Hide file tree
Showing 53 changed files with 99 additions and 212 deletions.
3 changes: 2 additions & 1 deletion vnpy/trader/ctaStrategy/ctaBacktesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
import pymongo

from vnpy.trader.vtGlobal import globalSetting
from ctaBase import *
from vnpy.trader.vtConstant import *
from vnpy.trader.vtGateway import VtOrderData, VtTradeData

from vnpy.trader.ctaStrategy.ctaBase import *


########################################################################
class BacktestingEngine(object):
Expand Down
6 changes: 0 additions & 6 deletions vnpy/trader/ctaStrategy/ctaBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

from __future__ import division


# 把vn.trader根目录添加到python环境变量中
import sys
sys.path.append('..')


# 常量定义
# CTA引擎中涉及到的交易方向类型
CTAORDER_BUY = u'买开'
Expand Down
13 changes: 7 additions & 6 deletions vnpy/trader/ctaStrategy/ctaEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
from collections import OrderedDict
from datetime import datetime, timedelta

from ctaBase import *
from strategy import STRATEGY_CLASS
from vnpy.event import *
from vnpy.event import Event
from vnpy.trader.vtEvent import *
from vtConstant import *
from vtGateway import VtSubscribeReq, VtOrderReq, VtCancelOrderReq, VtLogData
from vtFunction import todayDate
from vnpy.trader.vtConstant import *
from vnpy.trader.vtGateway import VtSubscribeReq, VtOrderReq, VtCancelOrderReq, VtLogData
from vnpy.trader.vtFunction import todayDate

from vnpy.trader.ctaStrategy.ctaBase import *
from vnpy.trader.ctaStrategy.strategy import STRATEGY_CLASS


########################################################################
Expand Down
10 changes: 6 additions & 4 deletions vnpy/trader/ctaStrategy/ctaHistoryData.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
"""

from datetime import datetime, timedelta
import pymongo
from time import time
from multiprocessing.pool import ThreadPool

import pymongo

from vnpy.trader.vtGlobal import globalSetting
from ctaBase import *
from vtConstant import *
from datayesClient import DatayesClient
from vnpy.trader.vtConstant import *

from vnpy.trader.ctaStrategy.ctaBase import *
from vnpy.trader.ctaStrategy.datayesClient import DatayesClient


# 以下为vn.trader和通联数据规定的交易所代码映射
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/ctaStrategy/ctaTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
本文件包含了CTA引擎中的策略开发用模板,开发策略时需要继承CtaTemplate类。
'''

from ctaBase import *
from vnpy.trader.vtConstant import *

from vnpy.trader.ctaStrategy.ctaBase import *

########################################################################
class CtaTemplate(object):
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/ctaStrategy/strategy/strategyAtrRsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def onTrade(self, trade):
if __name__ == '__main__':
# 提供直接双击回测的功能
# 导入PyQt4的包是为了保证matplotlib使用PyQt4而不是PySide,防止初始化出错
from ctaBacktesting import *
from vnpy.trader.ctaStrategy.ctaBacktesting import *
from PyQt4 import QtCore, QtGui

# 创建回测引擎
Expand Down
5 changes: 3 additions & 2 deletions vnpy/trader/ctaStrategy/uiCtaWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@


from vnpy.event import Event
from uiBasicWidget import QtGui, QtCore, QtWidgets, BasicCell
from language import text
from vnpy.trader.uiBasicWidget import QtGui, QtCore, QtWidgets, BasicCell

from vnpy.trader.ctaStrategy.language import text


########################################################################
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/dataRecorder/drBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


# CTA引擎中涉及的数据类定义
from vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT
from vnpy.trader.vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT


########################################################################
Expand Down
11 changes: 6 additions & 5 deletions vnpy/trader/dataRecorder/drEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
from Queue import Queue
from threading import Thread

from vnpy.event import *
from vnpy.event import Event
from vnpy.trader.vtEvent import *
from vtGateway import VtSubscribeReq, VtLogData
from drBase import *
from vtFunction import todayDate
from language import text
from vnpy.trader.vtFunction import todayDate
from vnpy.trader.vtGateway import VtSubscribeReq, VtLogData

from vnpy.trader.dataRecorder.drBase import *
from vnpy.trader.dataRecorder.language import text


########################################################################
Expand Down
6 changes: 3 additions & 3 deletions vnpy/trader/dataRecorder/uiDrWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import json

from uiBasicWidget import QtWidgets, QtGui, QtCore
from vnpy.event import *
from language import text
from vnpy.event import Event
from vnpy.trader.uiBasicWidget import QtWidgets, QtGui, QtCore
from vnpy.trader.dataRecorder.language import text


########################################################################
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/cshshlpGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from cshshlpGateway import CshshlpGateway as gateway

gatewayName = 'CSHSHLP'
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/ctpGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from ctpGateway import CtpGateway as gateway

gatewayName = 'CTP'
Expand Down
28 changes: 1 addition & 27 deletions vnpy/trader/gateway/ctpGateway/ctpGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from vnpy.api.ctp import MdApi, TdApi, defineDict
from vnpy.trader.vtGateway import *
from language import text
from vnpy.trader.gateway.ctpGateway.language import text


# 以下为一些VT类型和CTP类型的映射字典
Expand Down Expand Up @@ -1458,29 +1458,3 @@ def writeLog(self, content):
log.gatewayName = self.gatewayName
log.logContent = content
self.gateway.onLog(log)


#----------------------------------------------------------------------
def test():
"""测试"""
from PyQt4 import QtCore
import sys

def print_log(event):
log = event.dict_['data']
print ':'.join([log.logTime, log.logContent])

app = QtCore.QCoreApplication(sys.argv)

eventEngine = EventEngine()
eventEngine.register(EVENT_LOG, print_log)
eventEngine.start()

gateway = CtpGateway(eventEngine)
gateway.connect()

sys.exit(app.exec_())


if __name__ == '__main__':
test()
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/femasGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from femasGateway import FemasGateway as gateway

gatewayName = 'FEMAS'
Expand Down
35 changes: 2 additions & 33 deletions vnpy/trader/gateway/femasGateway/femasGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import json

from vnpy.api.femas import MdApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *

# 以下为一些VT类型和CTP类型的映射字典
# 价格类型映射
Expand Down Expand Up @@ -947,35 +947,4 @@ def onRspQryInvestorFee(self, data, error, n, last):
#----------------------------------------------------------------------
def onRspQryInvestorMargin(self, data, error, n, last):
""""""
pass


#----------------------------------------------------------------------
def test():
"""测试"""
from PyQt4 import QtCore
import sys

def print_log(event):
log = event.dict_['data']
print ':'.join([log.logTime, log.logContent])

app = QtCore.QCoreApplication(sys.argv)

eventEngine = EventEngine()
eventEngine.register(EVENT_LOG, print_log)
eventEngine.start()

gateway = FemasGateway(eventEngine)
gateway.connect()

sys.exit(app.exec_())

#----------------------------------------------------------------------
def generateStrLocalID(localID):
"""把整数的本地委托号转化为字符串"""
return str(localID).rjust(12, '0')


if __name__ == '__main__':
test()
pass
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/huobiGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from huobiGateway import HuobiGateway as gateway

gatewayName = 'HUOBI'
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/huobiGateway/huobiGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from threading import Thread

from vnpy.api.huobi import vnhuobi
from vtGateway import *
from vnpy.trader.vtGateway import *


SYMBOL_BTCCNY = 'BTCCNY'
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/ibGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from ibGateway import IbGateway as gateway

gatewayName = 'IB'
Expand Down
4 changes: 2 additions & 2 deletions vnpy/trader/gateway/ibGateway/ibGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from copy import copy

from vnpy.api.ib import *
from vtGateway import *
from language import text
from vnpy.trader.vtGateway import *
from vnpy.trader.gateway.ibGateway.language import text


# 以下为一些VT类型和CTP类型的映射字典
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/ksgoldGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from ksgoldGateway import KsgoldGateway as gateway

gatewayName = 'KSGOLD'
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import time

from vnpy.api.ksgold import TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *

# 以下类型映射参考的是原生API里的Constant.h

Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/ksotpGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from ksotpGateway import KsotpGateway as gateway

gatewayName = 'KSOTP'
Expand Down
31 changes: 1 addition & 30 deletions vnpy/trader/gateway/ksotpGateway/ksotpGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import json

from vnpy.api.ksotp import MdApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *

# 以下为一些VT类型和CTP类型的映射字典
# 价格类型映射
Expand Down Expand Up @@ -1810,32 +1810,3 @@ def onRtnCombAction(self, data) :
""""""
pass






#----------------------------------------------------------------------
def test():
"""测试"""
from PyQt4 import QtCore
import sys

def print_log(event):
log = event.dict_['data']
print ':'.join([log.logTime, log.logContent])

app = QtCore.QCoreApplication(sys.argv)

eventEngine = EventEngine()
eventEngine.register(EVENT_LOG, print_log)
eventEngine.start()

gateway = KsotpGateway(eventEngine)
gateway.connect()

sys.exit(app.exec_())


if __name__ == '__main__':
test()
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/lhangGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from lhangGateway import LhangGateway as gateway

gatewayName = 'LHANG'
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/lhangGateway/lhangGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from time import sleep

from vnpy.api.lhang import LhangApi
from vtGateway import *
from vnpy.trader.vtGateway import *


SYMBOL_BTCCNY = 'BTCCNY'
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/ltsGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from ltsGateway import LtsGateway as gateway

gatewayName = 'LTS'
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/ltsGateway/ltsGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import json

from vnpy.api.lts import MdApi, QryApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *


# 以下为一些VT类型和LTS类型的映射字典
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/gateway/oandaGateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: UTF-8

import vtConstant
from vnpy.trader import vtConstant
from oandaGateway import OandaGateway as gateway

gatewayName = 'OANDA'
Expand Down
Loading

0 comments on commit 426f92c

Please sign in to comment.