diff --git a/.gitignore b/.gitignore index 4a7e4030..8a5ca675 100644 --- a/.gitignore +++ b/.gitignore @@ -53,20 +53,22 @@ Release/ ======= api/vn.ctp/build/* api/vn.lts/build/* -trader/logs/vnpy* -trader/logs/no* -trader/orders/*.csv -trader/learning/* -trader/obj/* -trader/temp/* -trader/catStrategy/cache/* -trader/catStrategy/ctaPeriod.py -trader/catStrategy/ctaRangeBar.py -trader/catStrategy/ctaRenkoBar.py -trader/gateway/ctpGateway/CTP_EBF_connection.json -trader/gateway/ctpGateway/CTP_Post_connection.json -trader/gateway/ctpGateway/CTP_Prod_connection.json - +vnpy/trader/logs/vnpy* +vnpy/trader/logs/no* +vnpy/trader/orders/*.csv +vnpy/trader/learning/* +vnpy/trader/obj/* +vnpy/trader/temp/* +vnpy/trader/app/catStrategy/cache/* +vnpy/trader/app/catStrategy/ctaPeriod.py +vnpy/trader/app/catStrategy/ctaRangeBar.py +vnpy/trader/app/catStrategy/ctaRenkoBar.py +vnpy/trader/app/catStrategy/strategy_store/* +vnpy/trader/gateway/ctpGateway/CTP_EBF_connection.json +vnpy/trader/gateway/ctpGateway/CTP_Post_connection.json +vnpy/trader/gateway/ctpGateway/CTP_Prod_connection.json +vnpy/trader/gateway/ctpGateway/CTP_JR_connection.json +vnpy/trader/gateway/ctpGateway/CTP_JR2_connection.json .idea diff --git a/trader/app/ctaStrategy/CTA_setting.json b/trader/app/ctaStrategy/CTA_setting.json deleted file mode 100644 index ca2c9a80..00000000 --- a/trader/app/ctaStrategy/CTA_setting.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - - -] \ No newline at end of file diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index f378be64..78caaf60 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -530,7 +530,6 @@ class CtaEngine(object): # 触发每个策略的定时接口 for strategy in self.strategyDict.values(): strategy.onTimer() - # ---------------------------------------------------------------------- def insertData(self, dbName, collectionName, data): diff --git a/vnpy/trader/gateway/ctpGateway/__init__.py b/vnpy/trader/gateway/ctpGateway/__init__.py index fb2e14b1..d93e34f7 100644 --- a/vnpy/trader/gateway/ctpGateway/__init__.py +++ b/vnpy/trader/gateway/ctpGateway/__init__.py @@ -3,7 +3,7 @@ import sys import os -print u'init {0}'.format(os.path.dirname(__file__)) +#print u'init {0}'.format(os.path.dirname(__file__)) from vnpy.trader import vtConstant from ctpGateway import CtpGateway diff --git a/vnpy/trader/noUiMain.py b/vnpy/trader/noUiMain.py index b818dc5a..db4064cf 100644 --- a/vnpy/trader/noUiMain.py +++ b/vnpy/trader/noUiMain.py @@ -1,11 +1,12 @@ # encoding: UTF-8 - import os from setup_logger import setup_logger -from simple_monitor import * -from vtEngine import MainEngine +from vnpy.trader.simple_monitor import * +from vnpy.trader.vtEngine import MainEngine +from vnpy.trader.gateway import ctpGateway +from threading import Thread setup_logger(debug=True) # ---------------------------------------------------------------------- @@ -37,6 +38,8 @@ class NoUiMain(object): print u'instance mainengine' self.mainEngine = MainEngine() + self.mainEngine.addGateway(ctpGateway, self.gateway_name) + def trade_off(self): """检查现在是否为非交易时间""" now = datetime.now() @@ -140,7 +143,6 @@ class NoUiMain(object): def run_noui(): try: - log_file_name = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logs', u'noUiMain_{0}.log'.format(datetime.now().strftime('%m%d_%H%M')))) @@ -160,9 +162,4 @@ if __name__ == '__main__': thread = Thread(target=run_noui, args=()) thread.start() - # 创建Qt应用对象,用于事件循环 - #app = QtGui.QApplication(sys.argv) - #run_noui() - # 连续运行,用于输出行情 - #app.exec_() diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index dff363c1..a65350d8 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -101,7 +101,14 @@ class MainEngine(object): gateway = self.gatewayDict[gatewayName] gateway.subscribe(subscribeReq) else: - self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName)) + # 如果当前只有一个连接 + if len(self.gatewayDict) == 1: + k = list(self.gatewayDict.keys())[0] + gateway = self.gatewayDict[k] + gateway.subscribe(subscribeReq) + + else: + self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName)) # ---------------------------------------------------------------------- def sendOrder(self, orderReq, gatewayName):