From 32d8a257baf5e14fb9ee7bbb9ed1da898efd0903 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 9 Jun 2018 18:54:41 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=E6=96=B0=E5=A2=9ECryptoTrader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/CryptoTrader/VT_setting.json | 20 +++++++++ examples/CryptoTrader/run.py | 61 +++++++++++++++++++++++++++ examples/VnTrader/run.py | 4 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 examples/CryptoTrader/VT_setting.json create mode 100644 examples/CryptoTrader/run.py diff --git a/examples/CryptoTrader/VT_setting.json b/examples/CryptoTrader/VT_setting.json new file mode 100644 index 00000000..473017fb --- /dev/null +++ b/examples/CryptoTrader/VT_setting.json @@ -0,0 +1,20 @@ +{ + "fontFamily": "微软雅黑", + "fontSize": 12, + + "mongoHost": "localhost", + "mongoPort": 27017, + "mongoLogging": true, + + "darkStyle": true, + "language": "chinese", + + "logActive": true, + "logLevel": "debug", + "logConsole": true, + "logFile": true, + + "tdPenalty": ["IF", "IH", "IC"], + + "maxDecimal": 4 +} \ No newline at end of file diff --git a/examples/CryptoTrader/run.py b/examples/CryptoTrader/run.py new file mode 100644 index 00000000..a09cb3dc --- /dev/null +++ b/examples/CryptoTrader/run.py @@ -0,0 +1,61 @@ +# encoding: UTF-8 + +# 重载sys模块,设置默认字符串编码方式为utf8 +try: + reload # Python 2 +except NameError: # Python 3 + from importlib import reload +import sys +reload(sys) +sys.setdefaultencoding('utf8') + +# 判断操作系统 +import platform +system = platform.system() + +# vn.trader模块 +from vnpy.event import EventEngine +from vnpy.trader.vtEngine import MainEngine +from vnpy.trader.uiQt import createQApp +from vnpy.trader.uiMainWindow import MainWindow + +# 加载底层接口 +from vnpy.trader.gateway import (huobiGateway, okexGateway, + binanceGateway, bitfinexGateway) + +# 加载上层应用 +from vnpy.trader.app import (riskManager, algoTrading) + + +#---------------------------------------------------------------------- +def main(): + """主程序入口""" + # 创建Qt应用对象 + qApp = createQApp() + + # 创建事件引擎 + ee = EventEngine() + + # 创建主引擎 + me = MainEngine(ee) + + # 添加交易接口 + me.addGateway(huobiGateway) + me.addGateway(okexGateway) + me.addGateway(binanceGateway) + me.addGateway(bitfinexGateway) + + # 添加上层应用 + me.addApp(riskManager) + me.addApp(algoTrading) + + # 创建主窗口 + mw = MainWindow(me, ee) + mw.showMaximized() + + # 在主线程中启动Qt事件循环 + sys.exit(qApp.exec_()) + + +if __name__ == '__main__': + main() diff --git a/examples/VnTrader/run.py b/examples/VnTrader/run.py index 24a54f97..9eaf85d3 100644 --- a/examples/VnTrader/run.py +++ b/examples/VnTrader/run.py @@ -30,7 +30,8 @@ elif system == 'Windows': secGateway) # 加载上层应用 -from vnpy.trader.app import (riskManager, ctaStrategy, spreadTrading) +from vnpy.trader.app import (riskManager, ctaStrategy, + spreadTrading, algoTrading) #---------------------------------------------------------------------- @@ -62,6 +63,7 @@ def main(): me.addApp(riskManager) me.addApp(ctaStrategy) me.addApp(spreadTrading) + me.addApp(algoTrading) # 创建主窗口 mw = MainWindow(me, ee)