安装文档

1 系统安装与更新

1.1 Docker环境

功夫宗师交易系统推荐系统运行环境是 Centos7.2,推荐部署在taurus提供的docker环境中。

使用docker环境可以很方便的进行系统迁移,具体可以参考docker使用方法

1.1 系统安装

功夫宗师系统安装需要按顺序安装五个安装包(rpm),longfist、yijinjing、wingchun,dzxy和greatshift,由于有些rpm包在安装时会依赖其他包,推荐安装命令:yum install $(package_name.rpm),例如 $ yum install wingchun-1.0.0-Linux.rpm (本文中$()括号中是需要根据情况填写的信息)

1.2 系统更新

如果之前有安装过功夫宗师系统,需要先卸载再安装,推荐卸载命令:yum erase $(name),例如$ yum erase wingchun

2 系统运行

以下操作均可通过前端完成,运维人员可以使用后台操作的方式启停交易系统

交易系统的服务项为内存数据库服务yjj和交易接口服务(wingchun),其中wingchun基于yjj运行,所以启动时要依次启动yjj和wingchun服务,服务启动后即可执行量化交易程序。

安装好系统以后可以到/opt/kungfu/wingchun/etc/supervisor/conf.d/ 目录下查看.conf文件,系统启动时会遍历.conf文件,并启动对应服务项。

功夫宗师系统在启动之前需要配置交易账户信息,更换账户重启(MD/TD)服务服务)。

配置文件路径和账户配置文件:/shared/kungfu/misc/accounts.json,

配置过程为,切换用户,创建账户文件夹,编辑账号文件,命令如下

$ su bruce
$ mkdir /shared/kungfu/misc/
$ vi /shared/kungfu/misc/accounts.json

启动服务命令为:

$ systemctl start $(service_name)

关闭服务命令为:

$ systemctl stop $(service_name)

启动内存数据库服务 yijinjing

$ systemctl start yjj
$ systemctl status yjj
* yjj.service - Yi Jin Jing
   Loaded: loaded (/opt/kungfu/yijinjing/etc/systemd/user/yjj.service; linked; vendor preset: disabled)
   Active: active (running) since Thu 2018-01-18 07:45:50 CST; 6s ago
 Main PID: 534 (kungfu)
   CGroup: /system.slice/docker-134e68827fd8c662d30b636690b0324ac494145bd911a42e7c046ca991441136.scope/system.slice/yjj.service
           |-534 /usr/bin/python -u /opt/kungfu/yijinjing/bin/kungfu server
           `-535 /usr/bin/python -u /opt/kungfu/yijinjing/bin/kungfu server

Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.301] [INFO ] [engine.page] [socket] (status)13
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.301] [INFO ] [engine.page] [RegClient] (name)paged (writer?)1
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.301] [INFO ] [engine.page] [socket] (status)11
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.301] [INFO ] [engine.page] [RegJournal] (client)paged (idx)0
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.302] [INFO ] [engine.page] [Demand] (idx)0
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.302] [INFO ] [engine.page] [InPage] (folder)/shared/kungfu/journ...iter?)1
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.374] [INFO ] [engine.page] [AddrAdd] (path)/shared/kungfu/journa...c000000
Jan 18 07:45:50 134e68827fd8 kungfu[534]: rconsole server starting
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.384] [INFO ] [engine.page] (startTasks) (microseconds)10000
Jan 18 07:45:50 134e68827fd8 kungfu[534]: [18-01-18 07:45:50.384] [INFO ] [engine.page] NEW TEMP PAGE: /shared/kungfu/journal/TEMP_PAGE
Hint: Some lines were ellipsized, use -l to show in full.

启动行情交易服务 wingchun

[root@134e68827fd8 /]# systemctl start wingchun
[root@134e68827fd8 /]# systemctl status wingchun
* wingchun.service - Wing Chun Daemon
   Loaded: loaded (/opt/kungfu/wingchun/etc/systemd/user/wingchun.service; linked; vendor preset: disabled)
   Active: active (running) since Thu 2018-01-18 07:47:09 CST; 5s ago
  Process: 547 ExecStart=/usr/bin/supervisord -c /opt/kungfu/wingchun/etc/supervisor/supervisord.conf (code=exited, status=0/SUCCESS)
 Main PID: 550 (supervisord)
   CGroup: /system.slice/docker-134e68827fd8c662d30b636690b0324ac494145bd911a42e7c046ca991441136.scope/system.slice/wingchun.service
           |-550 /usr/bin/python /usr/bin/supervisord -c /opt/kungfu/wingchun/etc/supervisor/supervisord.conf
           |-551 /usr/bin/python -u /usr/bin/wingchun td oes
           |-552 /usr/bin/python -u /usr/bin/wingchun md oes
           |-554 /usr/bin/python -u /usr/bin/wingchun md ctp
           |-555 /usr/bin/python -u /usr/bin/wingchun md xtp
           |-556 /usr/bin/python -u /usr/bin/wingchun td ctp
           |-557 /usr/bin/python -u /usr/bin/wingchun td xtp
           `-558 /usr/bin/python -u /usr/bin/wingchun md sandbox

Jan 18 07:47:09 134e68827fd8 systemd[1]: Starting Wing Chun Daemon...
Jan 18 07:47:09 134e68827fd8 supervisord[547]: Unlinking stale socket /shared/kungfu/socket/wingchun-supervisor.sock
Jan 18 07:47:09 134e68827fd8 systemd[1]: Started Wing Chun Daemon.

启动前端服务 dzxy

启动数据统计服务 greatshift

服务正常运行时以上命令得到的输出结果中应为RUNING,否则是状态异常。 如果服务状态异常,可以参考日志工具通过日志查看详细信息。

3 行情交易连接

以下操作均可通过前端完成,运维人员可以使用后台操作的方式连接行情和交易

启动yjj和wingchun以后,可以运行wingchunctl命令来查看交易接口服务(wingchun)下的行情和交易服务项服务状态,整体或单独启停服务,具体方法如下:

$ wingchunctl
wingchun> status  //查看行情和交易(TD/MD)服务状态
wingchun> start engine_name  //启动某一项(TD/MD)服务
wingchun> stop engine_name  //停止某一项(TD/MD)服务
wingchun> restart engine_name  //重启某一项(TD/MD)服务

行情和交易服务项正常运行的状态应该为RUNING,否则为异常。

示例展示了启动ctp行情和交易连接

$ wingchunctl
md_ctp                           STOPPED   Jan 18 08:51 AM
td_ctp                           STOPPED   Jan 18 08:51 AM
wingchun> start md_ctp td_ctp
md_ctp: started
td_ctp: started
wingchun> status
md_ctp                           RUNNING   pid 614, uptime 0:00:38
td_ctp                           RUNNING   pid 620, uptime 0:00:28
wingchun>