This action will force synchronization from 老张/TdxTradeServer, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
本程序实现了一个服务器,用来接收交易请求,并将请求转发给trade.dll,使其可以通过rest api 被其它程序调用。
注意,注意,注意: 本程序不提供trade.dll文件,仅仅调用该dll库进行交易,并将其封装成rest api使用,
我们也不会提供任何trade.dll文件给使用者(关于trade.dll,请自行百度\谷歌)
如需技术支持,可以想办法联系我。
结构图
+--------------------------------------------------------------+
| Your Quant or Other System |
| |
| |
| +----------------------+ +----------------------------------+
| | | | ||
| | Python client Api | | Other Language Apis ||
| | pytdx | | ||
| | | | ||
| | | | ||
| +----------------------+ +----------------------------------+
| |
| |
+----------------------------+---^-----------------------------+
| |
+----------------------------v---+-----------------------------+
| |
| TongDaXin Trade SerVer Listening : 10092 port |
| + |
| | +---------------------+ |
| | | | |
| +----->+ Trade.dll | |
| | | |
| | | |
| + +---------------------+ |
+--------------------------------^-----------------------------+
| |
+----------------------------v---+-----------------------------+
| |
| Tong Da Xin Trade Servers |
| |
| |
| |
+--------------------------------------------------------------+
本程序使用QT5.9.1开发,使用restbed
作为web server实现,使用jsonformoderncpp
作为json序列化和反序列化工具,使用conan
作为c++依赖库的管理。 请使用兼容c++11
的编译器编译(这里我使用的vs2015的编译器,理论上mingw应该也可以)
pacman -S perl
pacman -S make
[general]
bash_path="c:\msys32\bin\bash"
..
[settings_defaults]
arch=x86
compiler=Visual Studio
compiler.version=14
compiler.runtime=MTd
build_type=Debug
os=Windows
conan install --build zlib --buildOpenSSL --build asio --build restbed
然后打开QT Creator编译即可。
我们可以通过配置文件来配置系统,配置文件可以在如下两个地方被放置
配置文件Demo
bind=10.11.5.175 ; 绑定的ip地址,默认是127.0.0.1
port=10092 ; 绑定的端口
trade_dll_path=D:\\trade_rainx.dll ;一份可以使用的trade.dll文件
transport_enc_key=4f1cf3fec4c84c84 ; 可选, aes加密秘钥
transport_enc_iv=0c78abc083b011e7 ; 可选, aes加密iv
注意,后面的加密选项为可选,如果transport_enc_key
或者 transport_enc_iv
不提供的话,将使用明文和client api
通讯,请注意和client api
保持一致。 如果您跨机器调用接口,建议使用加密功能,并且,请生成随即密钥和iv, 注意,我们这里key
和iv
必须是16
个字节
服务器端通过restbed
实现了一个webserver, 程序会提供 http://[your_bind]:[your_port]/api
endpoint, 所有的交互都由客户端通过HTTP POST
到本endpoint 实现。
URLENCODE(BASE64(AES128_CBC(JSON(PAYLOAD))))
结构加密传输,双方都采用相同方式加密解密请求的内容结构如下
{
"func": "one_function",
"params": {
"param1": "p1",
"param2": "p2"
}
}
应答的结构如下
{
"success": true,
"data": {
....
},
"error": "some errors only appear when success is False"
}
假设端口为 19820
In [5]: requests.post("http://127.0.0.1:19820/api", json={"func":"ping"}).text
Out[5]: '{"success":true, "data": "pong"}'
In [6]: requests.get("http://127.0.0.1:19820/status").text
Out[6]: '{"reqnum":1,"success":true}'
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。