2017-05-02 13:46:12 +00:00
|
|
|
|
# encoding: UTF-8
|
|
|
|
|
|
2017-05-31 16:10:07 +00:00
|
|
|
|
# 重载sys模块,设置默认字符串编码方式为utf8
|
2017-05-02 13:46:12 +00:00
|
|
|
|
import sys
|
2017-05-31 16:10:07 +00:00
|
|
|
|
reload(sys)
|
|
|
|
|
sys.setdefaultencoding('utf8')
|
|
|
|
|
|
|
|
|
|
# vn.trader模块
|
2017-06-04 15:07:15 +00:00
|
|
|
|
from vnpy.event import EventEngine
|
2017-05-08 09:45:50 +00:00
|
|
|
|
from vnpy.trader.vtEngine import MainEngine
|
2017-06-01 07:53:51 +00:00
|
|
|
|
from vnpy.trader.uiQt import qApp
|
|
|
|
|
from vnpy.trader.uiMainWindow import MainWindow
|
2017-05-31 16:10:07 +00:00
|
|
|
|
|
|
|
|
|
# 加载底层接口
|
2017-07-03 12:59:40 +00:00
|
|
|
|
# from vnpy.trader.gateway import (ctpGateway, femasGateway, xspeedGateway,
|
|
|
|
|
# sgitGateway, oandaGateway, ibGateway,
|
|
|
|
|
# shzdGateway, huobiGateway, okcoinGateway)
|
|
|
|
|
|
|
|
|
|
from vnpy.trader.gateway import ( huobiGateway, okcoinGateway)
|
2017-05-02 13:46:12 +00:00
|
|
|
|
|
2017-05-31 16:10:07 +00:00
|
|
|
|
# 加载上层应用
|
2017-06-30 03:22:53 +00:00
|
|
|
|
from vnpy.trader.app import (riskManager, ctaStrategy, spreadTrading)
|
2017-05-02 13:46:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
def main():
|
|
|
|
|
"""主程序入口"""
|
2017-05-31 16:10:07 +00:00
|
|
|
|
# 创建事件引擎
|
2017-06-05 08:22:16 +00:00
|
|
|
|
ee = EventEngine()
|
2017-05-31 16:10:07 +00:00
|
|
|
|
|
|
|
|
|
# 创建主引擎
|
|
|
|
|
me = MainEngine(ee)
|
|
|
|
|
|
|
|
|
|
# 添加交易接口
|
2017-07-03 12:59:40 +00:00
|
|
|
|
# me.addGateway(ctpGateway)
|
|
|
|
|
# me.addGateway(femasGateway)
|
|
|
|
|
# me.addGateway(xspeedGateway)
|
|
|
|
|
# me.addGateway(sgitGateway)
|
|
|
|
|
# me.addGateway(oandaGateway)
|
|
|
|
|
# me.addGateway(ibGateway)
|
|
|
|
|
# me.addGateway(shzdGateway)
|
2017-05-31 16:10:07 +00:00
|
|
|
|
me.addGateway(huobiGateway)
|
2017-06-01 08:40:30 +00:00
|
|
|
|
me.addGateway(okcoinGateway)
|
2017-05-02 13:46:12 +00:00
|
|
|
|
|
2017-05-31 16:10:07 +00:00
|
|
|
|
# 添加上层应用
|
|
|
|
|
me.addApp(riskManager)
|
|
|
|
|
me.addApp(ctaStrategy)
|
2017-06-12 09:14:34 +00:00
|
|
|
|
me.addApp(spreadTrading)
|
2017-05-02 13:46:12 +00:00
|
|
|
|
|
2017-06-01 07:53:51 +00:00
|
|
|
|
# 创建主窗口
|
2017-05-31 16:10:07 +00:00
|
|
|
|
mw = MainWindow(me, ee)
|
|
|
|
|
mw.showMaximized()
|
2017-05-02 13:46:12 +00:00
|
|
|
|
|
|
|
|
|
# 在主线程中启动Qt事件循环
|
2017-06-01 07:53:51 +00:00
|
|
|
|
sys.exit(qApp.exec_())
|
2017-05-31 16:10:07 +00:00
|
|
|
|
|
|
|
|
|
|
2017-05-02 13:46:12 +00:00
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
main()
|