全部改为绝对引用

This commit is contained in:
vn.py 2017-05-15 10:36:01 +08:00
parent 7353c407e6
commit 426f92caac
53 changed files with 99 additions and 212 deletions

View File

@ -13,10 +13,11 @@ import multiprocessing
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):

View File

@ -6,12 +6,6 @@
from __future__ import division
# 把vn.trader根目录添加到python环境变量中
import sys
sys.path.append('..')
# 常量定义
# CTA引擎中涉及到的交易方向类型
CTAORDER_BUY = u'买开'

View File

@ -24,13 +24,14 @@ import traceback
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
########################################################################

View File

@ -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和通联数据规定的交易所代码映射

View File

@ -4,9 +4,9 @@
本文件包含了CTA引擎中的策略开发用模板开发策略时需要继承CtaTemplate类
'''
from ctaBase import *
from vnpy.trader.vtConstant import *
from vnpy.trader.ctaStrategy.ctaBase import *
########################################################################
class CtaTemplate(object):

View File

@ -239,7 +239,7 @@ class AtrRsiStrategy(CtaTemplate):
if __name__ == '__main__':
# 提供直接双击回测的功能
# 导入PyQt4的包是为了保证matplotlib使用PyQt4而不是PySide防止初始化出错
from ctaBacktesting import *
from vnpy.trader.ctaStrategy.ctaBacktesting import *
from PyQt4 import QtCore, QtGui
# 创建回测引擎

View File

@ -6,8 +6,9 @@ CTA模块相关的GUI控制组件
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
########################################################################

View File

@ -20,7 +20,7 @@ MINUTE_DB_NAME = 'VnTrader_1Min_Db'
# 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
########################################################################

View File

@ -14,12 +14,13 @@ from datetime import datetime, timedelta
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
########################################################################

View File

@ -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
########################################################################

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from cshshlpGateway import CshshlpGateway as gateway
gatewayName = 'CSHSHLP'

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from ctpGateway import CtpGateway as gateway
gatewayName = 'CTP'

View File

@ -15,7 +15,7 @@ from datetime import datetime
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类型的映射字典
@ -1458,29 +1458,3 @@ class CtpTdApi(TdApi):
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()

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from femasGateway import FemasGateway as gateway
gatewayName = 'FEMAS'

View File

@ -11,7 +11,7 @@ import os
import json
from vnpy.api.femas import MdApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下为一些VT类型和CTP类型的映射字典
# 价格类型映射
@ -947,35 +947,4 @@ class FemasTdApi(TdApi):
#----------------------------------------------------------------------
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

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from huobiGateway import HuobiGateway as gateway
gatewayName = 'HUOBI'

View File

@ -14,7 +14,7 @@ from Queue import Queue
from threading import Thread
from vnpy.api.huobi import vnhuobi
from vtGateway import *
from vnpy.trader.vtGateway import *
SYMBOL_BTCCNY = 'BTCCNY'

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from ibGateway import IbGateway as gateway
gatewayName = 'IB'

View File

@ -18,8 +18,8 @@ from datetime import datetime, timedelta
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类型的映射字典

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from ksgoldGateway import KsgoldGateway as gateway
gatewayName = 'KSGOLD'

View File

@ -12,7 +12,7 @@ import json
import time
from vnpy.api.ksgold import TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下类型映射参考的是原生API里的Constant.h

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from ksotpGateway import KsotpGateway as gateway
gatewayName = 'KSOTP'

View File

@ -9,7 +9,7 @@ import os
import json
from vnpy.api.ksotp import MdApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下为一些VT类型和CTP类型的映射字典
# 价格类型映射
@ -1810,32 +1810,3 @@ class KsotpTdApi(TdApi):
""""""
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()

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from lhangGateway import LhangGateway as gateway
gatewayName = 'LHANG'

View File

@ -11,7 +11,7 @@ from datetime import datetime
from time import sleep
from vnpy.api.lhang import LhangApi
from vtGateway import *
from vnpy.trader.vtGateway import *
SYMBOL_BTCCNY = 'BTCCNY'

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from ltsGateway import LtsGateway as gateway
gatewayName = 'LTS'

View File

@ -8,7 +8,7 @@ import os
import json
from vnpy.api.lts import MdApi, QryApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下为一些VT类型和LTS类型的映射字典

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from oandaGateway import OandaGateway as gateway
gatewayName = 'OANDA'

View File

@ -25,7 +25,7 @@ import json
import datetime
from vnpy.api.oanda import OandaApi
from vtGateway import *
from vnpy.trader.vtGateway import *
# 价格类型映射
priceTypeMap = {}

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from okcoinGateway import OkcoinGateway as gateway
gatewayName = 'OKCOIN'

View File

@ -17,7 +17,7 @@ from Queue import Queue
from threading import Thread
from vnpy.api.okcoin import vnokcoin
from vtGateway import *
from vnpy.trader.vtGateway import *
# 价格类型映射
priceTypeMap = {}

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from qdpGateway import QdpGateway as gateway
gatewayName = 'QDP'

View File

@ -14,7 +14,7 @@ import datetime
from copy import copy
from vnpy.api.qdp import MdApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下为一些VT类型和QDP类型的映射字典

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from sgitGateway import SgitGateway as gateway
gatewayName = 'SGIT'

View File

@ -14,7 +14,7 @@ from copy import copy
from datetime import datetime
from vnpy.api.sgit import MdApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下为一些VT类型和SGIT类型的映射字典
@ -1410,30 +1410,4 @@ class PositionBuffer(object):
#----------------------------------------------------------------------
def getPos(self):
"""获取当前的持仓数据"""
return copy(self.pos)
#----------------------------------------------------------------------
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 = SgitGateway(eventEngine)
gateway.connect()
sys.exit(app.exec_())
if __name__ == '__main__':
test()
return copy(self.pos)

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from shzdGateway import ShzdGateway as gateway
gatewayName = 'SHZD'

View File

@ -16,7 +16,7 @@ from copy import copy
from datetime import datetime
from vnpy.api.shzd import ShzdApi
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下为一些VT类型和SHZD类型的映射字典

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from windGateway import WindGateway as gateway
gatewayName = 'WIND'

View File

@ -11,7 +11,7 @@ try:
except ImportError:
print u'请先安装WindPy接口'
from vtGateway import *
from vnpy.trader.vtGateway import *
# 交易所类型映射
exchangeMap = {}

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
import vtConstant
from vnpy.trader import vtConstant
from xspeedGateway import XspeedGateway as gateway
gatewayName = 'XSPEED'

View File

@ -10,7 +10,7 @@ import time
from copy import copy
from vnpy.api.xspeed import MdApi, TdApi, defineDict
from vtGateway import *
from vnpy.trader.vtGateway import *
# 以下为一些VT类型和XSPEED类型的映射字典
# 价格类型映射

View File

@ -11,10 +11,10 @@ import json
import os
import platform
from vnpy.event import *
from vnpy.event import Event
from vnpy.trader.vtEvent import *
from vtConstant import *
from vtGateway import VtLogData
from vnpy.trader.vtConstant import *
from vnpy.trader.vtGateway import VtLogData
########################################################################

View File

@ -5,9 +5,10 @@
'''
from uiBasicWidget import QtGui, QtWidgets, QtCore
from vnpy.event import *
from language import text
from vnpy.event import Event
from vnpy.trader.uiBasicWidget import QtGui, QtWidgets, QtCore
from vnpy.trader.riskManager.language import text
########################################################################

View File

@ -5,14 +5,13 @@ import csv
import os
from collections import OrderedDict
#from PyQt4 import QtGui, QtCore
from qtpy import QtWidgets, QtGui, QtCore
from vnpy.event import *
from vnpy.trader.vtEvent import *
from vtFunction import *
from vtGateway import *
import vtText
from vnpy.trader.vtFunction import *
from vnpy.trader.vtGateway import *
from vnpy.trader import vtText as vtText
COLOR_RED = QtGui.QColor('red')

View File

@ -2,11 +2,11 @@
import psutil
from gateway import GATEWAY_DICT
from uiBasicWidget import *
from ctaStrategy.uiCtaWidget import CtaEngineManager
from dataRecorder.uiDrWidget import DrEngineManager
from riskManager.uiRmWidget import RmEngineManager
from vnpy.trader.gateway import GATEWAY_DICT
from vnpy.trader.uiBasicWidget import *
from vnpy.trader.ctaStrategy.uiCtaWidget import CtaEngineManager
from vnpy.trader.dataRecorder.uiDrWidget import DrEngineManager
from vnpy.trader.riskManager.uiRmWidget import RmEngineManager
########################################################################

View File

@ -11,9 +11,9 @@ from uiMainWindow import *
from vnpy.event import EventEngine
from vnpy.rpc import RpcClient
from ctaStrategy.ctaEngine import CtaEngine
from dataRecorder.drEngine import DrEngine
from riskManager.rmEngine import RmEngine
from vnpy.trader.ctaStrategy.ctaEngine import CtaEngine
from vnpy.trader.dataRecorder.drEngine import DrEngine
from vnpy.trader.riskManager.rmEngine import RmEngine

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
from language import constant
from vnpy.trader.language import constant
# 将常量定义添加到vtConstant.py的局部字典中
d = locals()

View File

@ -7,16 +7,16 @@ from datetime import datetime
from pymongo import MongoClient
from pymongo.errors import ConnectionFailure
from vnpy.trader.vtGlobal import globalSetting
from vnpy.event import *
from vnpy.trader.vtGlobal import globalSetting
from vnpy.trader.vtEvent import *
from vtGateway import *
from language import text
from vnpy.trader.vtGateway import *
from vnpy.trader.language import text
from gateway import GATEWAY_DICT
from ctaStrategy.ctaEngine import CtaEngine
from dataRecorder.drEngine import DrEngine
from riskManager.rmEngine import RmEngine
from vnpy.trader.gateway import GATEWAY_DICT
from vnpy.trader.ctaStrategy.ctaEngine import CtaEngine
from vnpy.trader.dataRecorder.drEngine import DrEngine
from vnpy.trader.riskManager.rmEngine import RmEngine
########################################################################
@ -86,7 +86,7 @@ class MainEngine(object):
# 接口连接后自动执行数据库连接的任务
#self.dbConnect()
#----------------------------------------------------------------------
def subscribe(self, subscribeReq, gatewayName):
"""订阅特定接口的行情"""
@ -94,7 +94,7 @@ class MainEngine(object):
if gateway:
gateway.subscribe(subscribeReq)
#----------------------------------------------------------------------
def sendOrder(self, orderReq, gatewayName):
"""对特定接口发单"""
@ -116,7 +116,7 @@ class MainEngine(object):
if gateway:
gateway.cancelOrder(cancelOrderReq)
#----------------------------------------------------------------------
def qryAccount(self, gatewayName):
"""查询特定接口的账户"""

View File

@ -3,10 +3,10 @@
import time
from vnpy.event import *
from vnpy.trader.vtEvent import *
from vtConstant import *
from vtObject import *
from vnpy.trader.vtEvent import *
from vnpy.trader.vtConstant import *
from vnpy.trader.vtObject import *
########################################################################

View File

@ -4,7 +4,6 @@ import sys
import os
import platform
#from PyQt4 import QtGui, QtCore
from qtpy import QtWidgets, QtGui
from vnpy.trader.vtGlobal import globalSetting

View File

@ -2,7 +2,7 @@
import time
from vtConstant import *
from vnpy.trader.vtConstant import EMPTY_STRING, EMPTY_UNICODE, EMPTY_FLOAT, EMPTY_INT
########################################################################

View File

@ -8,7 +8,7 @@ from time import sleep
from threading import Thread
from vnpy.rpc import RpcServer
from vtEngine import MainEngine
from vnpy.trader.vtEngine import MainEngine
########################################################################

View File

@ -1,6 +1,6 @@
# encoding: UTF-8
from language import text
from vnpy.trader.language import text
# 将常量定义添加到vtText.py的局部字典中
d = locals()