vnpy/examples/CryptoTrader/run.py

67 lines
1.6 KiB
Python
Raw Normal View History

2018-06-09 10:54:41 +00:00
# encoding: UTF-8
# 重载sys模块设置默认字符串编码方式为utf8
try:
reload # Python 2
except NameError: # Python 3
from importlib import reload
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# vn.trader模块
from vnpy.event import EventEngine
from vnpy.trader.vtEngine import MainEngine
from vnpy.trader.uiQt import createQApp
# 加载底层接口
from vnpy.trader.gateway import (huobiGateway, okexGateway,
2018-06-16 14:10:36 +00:00
binanceGateway, bitfinexGateway,
2018-07-02 09:52:16 +00:00
bitmexGateway, fcoinGateway,
2018-07-11 14:07:14 +00:00
bigoneGateway, lbankGateway,
2018-07-13 11:58:12 +00:00
coinbaseGateway, ccxtGateway)
2018-06-09 10:54:41 +00:00
# 加载上层应用
2018-07-05 06:03:04 +00:00
from vnpy.trader.app import (algoTrading)
2018-06-09 10:54:41 +00:00
# 当前目录组件
from uiCryptoWindow import MainWindow
2018-06-09 10:54:41 +00:00
#----------------------------------------------------------------------
def main():
"""主程序入口"""
# 创建Qt应用对象
qApp = createQApp()
# 创建事件引擎
ee = EventEngine()
# 创建主引擎
me = MainEngine(ee)
# 添加交易接口
2018-07-13 11:58:12 +00:00
me.addGateway(ccxtGateway)
2018-07-11 14:07:14 +00:00
me.addGateway(coinbaseGateway)
2018-07-05 06:03:04 +00:00
me.addGateway(lbankGateway)
2018-07-02 09:52:16 +00:00
me.addGateway(bigoneGateway)
me.addGateway(fcoinGateway)
2018-06-16 14:10:36 +00:00
me.addGateway(bitmexGateway)
2018-06-09 10:54:41 +00:00
me.addGateway(huobiGateway)
me.addGateway(okexGateway)
me.addGateway(binanceGateway)
me.addGateway(bitfinexGateway)
2018-07-02 09:52:16 +00:00
2018-06-09 10:54:41 +00:00
# 添加上层应用
me.addApp(algoTrading)
# 创建主窗口
mw = MainWindow(me, ee)
mw.showMaximized()
# 在主线程中启动Qt事件循环
sys.exit(qApp.exec_())
if __name__ == '__main__':
main()