diff --git a/vnpy/api/sopt/libthostmduserapi_se.so b/vnpy/api/sopt/libthostmduserapi_se.so new file mode 100644 index 00000000..295c7360 Binary files /dev/null and b/vnpy/api/sopt/libthostmduserapi_se.so differ diff --git a/vnpy/api/sopt/libthosttraderapi_se.so b/vnpy/api/sopt/libthosttraderapi_se.so new file mode 100644 index 00000000..a195f26f Binary files /dev/null and b/vnpy/api/sopt/libthosttraderapi_se.so differ diff --git a/vnpy/api/sopt/setup.py b/vnpy/api/sopt/setup.py new file mode 100644 index 00000000..c00ec0ef --- /dev/null +++ b/vnpy/api/sopt/setup.py @@ -0,0 +1,107 @@ +import platform + +from setuptools import Extension, setup + +# 编译前 +# pip install -U setuptools,pybind11 +# 在ctp目录下, +# activate py37 +# python setup.py build +dir_path = "sopt" +runtime_library_dirs = [] +if platform.uname().system == "Windows": + compiler_flags = [ + "/MP", "/std:c++17", # standard + "/O2", "/Ob2", "/Oi", "/Ot", "/Oy", "/GL", # Optimization + "/wd4819" # 936 code page + ] + extra_link_args = [] + +else: + compiler_flags = [ + "-std=c++17", # standard + "-O3", # Optimization + "-Wno-delete-incomplete", "-Wno-sign-compare", "-pthread" + ] + extra_link_args = ["-lstdc++"] + runtime_library_dirs = ["$ORIGIN"] + +vnsoptmd = Extension( + # 编译对象 + "vnsoptmd", + # 指定 vnsoptmd 的位置 + [ + f"vnsopt/vnsoptmd/vnsoptmd.cpp", + ], + # 编译需要的头文件 + include_dirs=[ + f"include", + f"include/sopt", + f"include/pybind11", + f"vnsopt", + ], + # 指定为c plus plus + language="cpp", + define_macros=[], + undef_macros=[], + # 依赖目录 + library_dirs=[f"libs", f"."], + # 依赖项 + libraries=["thostmduserapi_se", "thosttraderapi_se", ], + extra_compile_args=compiler_flags, + extra_link_args=extra_link_args, + depends=[], + runtime_library_dirs=runtime_library_dirs, +) +vnsopttd = Extension( + "vnsopttd", + [ + f"vnsopt/vnsopttd/vnsopttd.cpp", + ], + include_dirs=[ + f"include", + f"include/sopt", + f"include/pybind11", + f"vnsopt", + ], + define_macros=[], + undef_macros=[], + library_dirs=[f"libs", f"."], + libraries=["thostmduserapi_se", "thosttraderapi_se"], + extra_compile_args=compiler_flags, + extra_link_args=extra_link_args, + runtime_library_dirs=runtime_library_dirs, + depends=[], + language="cpp", +) + +if platform.system() == "Windows": + # use pre-built pyd for windows ( support python 3.7 only ) + ext_modules = [vnsopttd, vnsoptmd] +elif platform.system() == "Darwin": + ext_modules = [] +else: + ext_modules = [vnsopttd, vnsoptmd] + +pkgs = [''] +install_requires = [] +setup( + name='sopt', + version='1.0', + description="good luck", + author='incenselee', + author_email='incenselee@hotmail.com', + license="MIT", + packages=pkgs, + install_requires=install_requires, + platforms=["Windows", "Linux", "Mac OS-X"], + package_dir={'sopt': 'sopt'}, + package_data={'sopt': ['*', ]}, + ext_modules=ext_modules, + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3.7', + ] +) diff --git a/vnpy/api/sopt/vnsopt/vnsoptmd/vnsoptmd.cpp b/vnpy/api/sopt/vnsopt/vnsoptmd/vnsoptmd.cpp index 766914c5..e13f5738 100644 --- a/vnpy/api/sopt/vnsopt/vnsoptmd/vnsoptmd.cpp +++ b/vnpy/api/sopt/vnsopt/vnsoptmd/vnsoptmd.cpp @@ -1,5 +1,4 @@ -#include "stdafx.h" -#include "vnsoptmd.h" +#include "vnsoptmd.h" /////////////////////////////////////////////////////////////////////////// /////////////原生回调接口生成task @@ -824,4 +823,4 @@ PYBIND11_MODULE(vnsoptmd, m) .def("onRtnDepthMarketData", &MdApi::onRtnDepthMarketData) .def("onRtnForQuoteRsp", &MdApi::onRtnForQuoteRsp) ; -} \ No newline at end of file +} diff --git a/vnpy/api/sopt/vnsopt/vnsopttd/vnsopttd.cpp b/vnpy/api/sopt/vnsopt/vnsopttd/vnsopttd.cpp index e84ae639..72929508 100644 --- a/vnpy/api/sopt/vnsopt/vnsopttd/vnsopttd.cpp +++ b/vnpy/api/sopt/vnsopt/vnsopttd/vnsopttd.cpp @@ -1,5 +1,4 @@ -#include "stdafx.h" -#include "vnsopttd.h" +#include "vnsopttd.h" /////////////////////////////////////////////////////////////////////////// /////////////原生回调接口生成task diff --git a/vnpy/api/sopt/vnsoptmd.so b/vnpy/api/sopt/vnsoptmd.so new file mode 100644 index 00000000..1c3d22bb Binary files /dev/null and b/vnpy/api/sopt/vnsoptmd.so differ diff --git a/vnpy/api/sopt/vnsopttd.so b/vnpy/api/sopt/vnsopttd.so new file mode 100644 index 00000000..ec2faa6f Binary files /dev/null and b/vnpy/api/sopt/vnsopttd.so differ diff --git a/vnpy/gateway/ctp/ctp_gateway.py b/vnpy/gateway/ctp/ctp_gateway.py index 2caa0ea6..02240dbf 100644 --- a/vnpy/gateway/ctp/ctp_gateway.py +++ b/vnpy/gateway/ctp/ctp_gateway.py @@ -1851,7 +1851,7 @@ class TqMdApi(): """""" try: from tqsdk import TqApi - self.api = TqApi() + self.api = TqApi(url="wss://u.shinnytech.com/t/md/front/mobile") except Exception as e: self.gateway.write_log(f'天勤行情API接入异常'.format(str(e))) if self.api: