{"id":19242910,"url":"https://github.com/ricequant/rqalpha-mod-ctp","last_synced_at":"2025-04-07T06:07:16.528Z","repository":{"id":57462955,"uuid":"92352265","full_name":"ricequant/rqalpha-mod-ctp","owner":"ricequant","description":"RQAlpha 对接 ctp 的扩展 Mod。通过启用该 Mod 来实现期货策略的实盘交易","archived":false,"fork":false,"pushed_at":"2018-06-15T10:29:56.000Z","size":6935,"stargazers_count":236,"open_issues_count":5,"forks_count":35,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-31T04:08:33.614Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ricequant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-25T01:32:51.000Z","updated_at":"2025-03-06T20:25:27.000Z","dependencies_parsed_at":"2022-09-05T15:40:51.075Z","dependency_job_id":null,"html_url":"https://github.com/ricequant/rqalpha-mod-ctp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricequant%2Frqalpha-mod-ctp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricequant%2Frqalpha-mod-ctp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricequant%2Frqalpha-mod-ctp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricequant%2Frqalpha-mod-ctp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ricequant","download_url":"https://codeload.github.com/ricequant/rqalpha-mod-ctp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601447,"owners_count":20964864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T17:16:00.186Z","updated_at":"2025-04-07T06:07:16.498Z","avatar_url":"https://github.com/ricequant.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RQAlpha-mod-ctp\n\nRQAlpha 对接 CTP 的扩展 Mod。通过启用该 Mod 来实现期货策略的实盘交易。目前本模块仍处在正式发布前的测试阶段，您可以下载参与测试并开 Issue 提交 bug，也欢迎您提交代码，参与开发。\n\n该 Mod 底层引用了 [PyCTP](https://github.com/lovelylain/pyctp), 一些函数的封装和写法参考了 [VN.PY](https://github.com/vnpy/vnpy)。\n\n\n## 量化社区\n\n[Ricequant](http://www.ricequant.com) 旨在为量化爱好者提供可靠、易用的工具。与此同时我们也搭建了一个量化社区供大家探讨与交流回测框架、策略。欢迎大家前来分享自己对于量化交易的理解。\n\n## 环境要求\n\n该 Mod 支持 python 2.7, 3.4, 3.5，暂时仅支持 Linux，后续会加入 windows 支持。\n\n## 安装\n\n```bash\n\nrqalpha mod install ctp\n\n```\n\n或者将源代码克隆，并在安装目录执行 \n\n```bash\n\nrqalpha mod install -e .\n\n```\n\n## 配置项\n\n您需要在配置项中填入您的 CTP 账号密码等信息，您可以在 simnow 官网 申请实盘模拟账号。\n配置项的使用与 RQAlpha 其他 mod 无异\n\n```python\n\n{   \n    # CTP 登录信息\n    \"login\": {\n        'user_id': None,\n        'password': None,\n        'broker_id': \"9999\",\n    },\n    # 事件相关设置\n    \"event\": {\n        # 是否使用默认的 CTP 实时数据源\n        \"enabled\": True,\n        # 是否在非交易时间段内触发行情事件\n        \"all_day\": False,\n        \"address\": \"tcp://180.168.212.228:41213\",\n    },\n    # 交易相关设置\n    \"trade\": {\n        # 是否使用默认的 CTP 交易接口\n        \"enabled\": True,\n        \"address\": \"tcp://180.168.146.187:10000\",\n    },\n}\n\n```\n\n## FAQ\n\nFAQ\n\n* 为什么策略在初始化期间停滞了几十秒甚至数分钟？\n\n程序在启动前，需要从 CTP 获取 Instrument 和 Commission 等数据，由于 CTP 控流等原因，向 CTP 发送大量请求会占用很长时间。您可以将 log_level 设置成 verbose 来查看详细的回调函数执行情况。未来可能会考虑开放设置是否全量更新 commission 信息以换取更快的启动速度。\n\n\n* 为什么我在RQAlpha中查询到的账户、持仓信息与我通过快期等终端查询到的不一致？\n\n本 mod 会尽力将您的账户信息恢复至 RQAlpha 中，但由于计算逻辑的不同，可能会导致各个终端显示的数字有差异，另外您通过其他终端下单交易也有可能导致数据同步的不及时。不过这也有可能是程序bug，如果您发现不一致情况严重，欢迎通过Issue的方式向作者提出。\n\n\n* 我想要仅仅使用 CTP 的交易/实时行情接口，并配合其他 mod 使用 RQAlpha。\n\n您可以在配置项中将 event 和 trade 部分的 enabled 项设置为 False 来禁用这一部分。\n\n\n## History\n\n* 0.1.3\n\n    * 对接了 pyctp，实现了 python2 和 python3 下的 RQAlpha 期货实盘。\n\n* 0.1.4 \n    \n    * 更改了配置项的格式。\n    * 拆分了事件和交易部分，用户可以通过配置项将其中一部分禁用。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricequant%2Frqalpha-mod-ctp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fricequant%2Frqalpha-mod-ctp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricequant%2Frqalpha-mod-ctp/lists"}