Code Monkey home page Code Monkey logo

openctp / openctp Goto Github PK

View Code? Open in Web Editor NEW
2.0K 2.0K 442.0 462.99 MB

openctp提供CTP股票期权、中泰证券XTP、华鑫证券奇点TORA、东方证券OST、东方财富证券EMT、盈透证券TWS、易盛TAP、量投QDP等各通道的CTPAPI兼容接口,CTP程序可以无缝对接各股票柜台。openctp也提供了一套基于TTS交易系统的模拟环境,同样提供了CTPAPI兼容接口,不仅支持国内期货与期权全品种,也支持A股股票、基金、债券以及股票期权模拟交易,可以替代Simnow,为CTP量化交易开发者提供7x24可用的模拟环境。

Home Page: http://www.openctp.cn

License: BSD 3-Clause "New" or "Revised" License

CMake 0.25% C++ 12.62% C 86.30% Python 0.71% JavaScript 0.05% HTML 0.01% Vue 0.07%
ctp ctpapi futures options quant simnow stock stp trader tts xtp

openctp's Issues

mac M1下编译失败

Undefined symbols for architecture arm64:
  "CThostFtdcMdApi::GetApiVersion()", referenced from:
      _main in ctpping-f31e69.o
  "CThostFtdcMdApi::CreateFtdcMdApi(char const*, bool, bool)", referenced from:
      _main in ctpping-f31e69.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Makefile:

all: ctpping
ctpping:
	g++ -v -std=c++11 -I. -o ctpping ctpping.cpp -L../../shared/macos.arm64/

QQ行情UB

void
		query(char const* target)
	{
		// Set up an HTTP GET request message
		req_.version(11);
		req_.method(http::verb::get);
		req_.target(target); <---------------------------- 这里target在使用req_的cb里已经被销毁了吧
		req_.set(http::field::host, url_);
		req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);

		// Look up the domain name
		resolver_.async_resolve(
			url_,
			port_,
			beast::bind_front_handler(
				&CFtdcMdApiImpl::on_resolve,
				this));
	}

我看了下beast::http::request用的是stringview,async的回调里引用的std::string和内存可能已经释放了。

进程退出

编译了mac版的vnpy_tts,启动vnpy一段时间后,软件崩溃退出

libc++abi: terminating with uncaught exception of type std::range_error: wstring_convert: to_bytes error

[bug]CMake无法编译.虚类不能实体化

您好,
我克隆了openctp sina 和openctp华鑫sfp目录。系统为linux64
对于每个目录,我操作如下:

  1. mkdir build && cd build
  2. cmake .. && cmake --build .

编译会出现如下错误:
/cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.cpp: In static member function ‘static CThostFtdcMdApi* CThostFtdcMdApi::CreateFtdcMdApi(const char*, bool, bool)’:
/cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.cpp:14:35: error: invalid new-expression of abstract class type ‘CFtdcMdApiImpl’
14 | return new CFtdcMdApiImpl();
| ^
In file included from /cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.cpp:1:
/cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.h:14:7: note: because the following virtual functions are pure within ‘CFtdcMdApiImpl’:
14 | class CFtdcMdApiImpl : public CThostFtdcMdApi, public CTORATstpXMdSpi
| ^~~~~~~~~~~~~~
In file included from /cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.h:9:
/cpp-subscriber/ctp2huaxinSTP/6.5.1_20200908/ThostFtdcMdApi.h:163:21: note: ‘virtual int CThostFtdcMdApi::ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField*, int)’
163 | *virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField pQryMulticastInstrument, int nRequestID) = 0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~

这个编译错误貌似是合理的。不知道项目组有没有计划修复。
另外,如果我把上述return new CFtdcMdApiImpl(); 改为 return NULL; 则编译通过,但链接不通过,错误如下:
[root@7687c3c3c16c build]# cmake --build .
[ 8%] Building CXX object 6.3.15_20190220/CMakeFiles/thostmduserapi_se_6.3.15_20190220.dir//FtdcMdApiImpl.cpp.o
[ 16%] Linking CXX shared library /cpp-subscriber/ctp2huaxinSTP/6.3.15_20190220/libthostmduserapi_se.so
[ 16%] Built target thostmduserapi_se_6.3.15_20190220
[ 25%] Building CXX object 6.5.1_20200908/CMakeFiles/thostmduserapi_se_6.5.1_20200908.dir/
/FtdcMdApiImpl.cpp.o
[ 33%] Linking CXX shared library /cpp-subscriber/ctp2huaxinSTP/6.5.1_20200908/libthostmduserapi_se.so
[ 33%] Built target thostmduserapi_se_6.5.1_20200908
[ 41%] Building CXX object 6.3.19_P1_20200106/CMakeFiles/thostmduserapi_se_6.3.19_P1_20200106.dir/__/FtdcMdApiImpl.cpp.o
[ 50%] Linking CXX shared library /cpp-subscriber/ctp2huaxinSTP/6.3.19_P1_20200106/libthostmduserapi_se.so
/usr/bin/ld: cannot find -lxfastmdapi: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [6.3.19_P1_20200106/CMakeFiles/thostmduserapi_se_6.3.19_P1_20200106.dir/build.make:97: /cpp-subscriber/ctp2huaxinSTP/6.3.19_P1_20200106/libthostmduserapi_se.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:240: 6.3.19_P1_20200106/CMakeFiles/thostmduserapi_se_6.3.19_P1_20200106.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

我看到动态库在那里,但cmake没看到。不知道能否改进一下?
谢谢

为何一秒内两个tick的时间一样?缺毫秒部分。有时两个tick成交量一样

您好,我使用openctp api,打印了tick时间,价格,成交量信息,如下
bee tick time ag2206.SHFE 2022-04-29 10:54:24 4944.0 322397
bee tick time ag2206.SHFE 2022-04-29 10:54:25 4943.0 322400
bee tick time ag2206.SHFE 2022-04-29 10:54:25 4943.0 322400
bee tick time ag2206.SHFE 2022-04-29 10:54:26 4943.0 322468
bee tick time ag2206.SHFE 2022-04-29 10:54:26 4943.0 322471
发现两个问题;
1 一秒内两个tick的时间一样,缺毫秒部分。比如2022-04-29 10:54:25的两个tick。好像simnow里的tick不会出现这种现象。
2 有时1秒内的两个tick累积成交量一样,比如2022-04-29 10:54:25的两个tick,我理解其中第二个tick是0.5秒处的tick,其累积成交量应该变大。
any idea?

兼容性还是有问题啊,测试了6.3.19崩溃

我用官方的6.3.19编译以后,使用官方的6.3.19的动态链接库就不崩溃,用openctp的6.3.19的动态链接库,在调用Trader的Init函数就崩了。尴尬
难道是我使用方式不对?
根据openctp的原理说明,本质上是写了一个和官方一模一样接口的DLL,理论上应该是无缝替换,但是我这替换以后确实不行。

C#尝试读取或写入受保护的内存,这通常指示其他内存已损坏

1、下载代码后,运行\openctp-master\ctpapi-csharp\Example\CTP6_5_1ReleaseDemo下的解决方案
2、成功启动应用程序后,点击连接行情
111
3、在调用CTPMD.CreateMDApi();时,报异常“尝试读取或写入受保护的内存,这通常指示其他内存已损坏”
XZIT3P7Q8JX)D($B UN~WGK
O_LW%@6P~HOGXTDNP@NIRJ
4、调试后发现应该是CTPWrapper.dll报错
)_@ M5B`E4XVUX 20~ _VNT
请问,我的问题是出在哪里了呢?

感谢openctp无私提供的一个很好的开发测试平台, 反馈一个问题,希望能改进

感谢openctp无私提供的一个很好的开发测试平台,
反馈一个问题,希望能改进,
以rb2305合约为例,
行情大概一直在价格3500-4100之间循环,
可是 行情会突然从3500多 直接跳空到 4000,
形成爆盈 或 爆亏,不太利于验证策略在真实行情下的效果,
希望能将行情循环周期加大,变为实际的1月或1年的行情,越长当然越好,
谢谢🙏

tts支持合约的状态信息推送接口onRtnInstrumentStatus()吗?

我是vnpy会员,从TtsTdApi的C++源代码可以找到onRtnInstrumentStatus这个库函数接口的,于是我在tts网关的TtsTdApi增加onRtnInstrumentStatus来输出合约的状态信息,可是我发现连接tts网关成功后并没有收到任何一个合约的状态信息。
难道tts不支持这个接口吗?

腾讯云ubuntu系统安装openctp失败?

ubuntu@VM-8-2-ubuntu:~/work$ pip install openctp-ctp

Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting openctp-ctp
Downloading http://mirrors.tencentyun.com/pypi/packages/4e/5b/64e21da08e3c8930cde90e2b407cde65cf8a449fa9143db088e500f1f961/openctp_ctp-6.6.9-cp310-cp310-manylinux_2_35_x86_64.whl (7.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.9/7.9 MB 4.6 MB/s eta 0:00:00
Installing collected packages: openctp-ctp
Successfully installed openctp-ctp-6.6.9

ubuntu@VM-8-2-ubuntu:~/work$ python3

Python 3.10.6 (main, Nov 2 2022, 18:53:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> from openctp_ctp import mdapi, tdapi

terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Aborted (core dumped)

ubuntu@VM-8-2-ubuntu:~/work$

centos登录成功后隔5秒左右报错KeyError: ('TTS',)

env: centos 8, vnpy_ctp==6.6.7, vnpy==3.3.0, openctp 7x24 env&account
报错信息:
···
/vnpy_ctp/gateway/ctp_gateway.py(602): onRspQryInstrument
KeyError: ('TTS',)
···
将vnpy_ctp中的两个lib*.so分别替换为openctp中lin64下的两个文件,vnpy显示结算信息查询成功,然后等待5秒左右出现报错内容,正常应该输出合约信息查询成功。
经过测试,simnow仿真和24小时都正常,openctp仿真也正常,就是7x24无论交易日的交易时段或非交易时段都报该错误。
感谢解答!

C#转编的无法兼容呀

自己用官方给的lib文件转成了C#用的动态链接库,用贵平台的覆盖出错。如图,麻烦提供一个lib文件或其他方式。
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.