1 Star 0 Fork 66

易城盛世网络科技 / AlgoPlus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT
如无必要,勿增实体

简介

AlgoPlus是上期技术CTP API的Python封装,具有以下特点:

  • 易使用:Python语言,结构清晰,注释完整,文档详尽。
  • 低延时:基于Cython释放GIL;支持多路行情源;无需主事件引擎,实现去中心化。
  • 忠实于CTP官方特性:充分利用CTP的异步、多线程特性。

AlgoPlus文档

http://algo.plus

安装

首先配置Anaconda环境,然后使用pip命令安装:

pip install AlgoPlus

从两个例子开始

订阅行情并落地为CSV文件

补充账户密码之后运行,可以订阅行情,并将接收到的数据写入csv文件中。

from AlgoPlus.CTP.MdApi import run_mdrecorder
from AlgoPlus.CTP.FutureAccount import FutureAccount, get_simnow_account

if __name__ == '__main__':
    # 账户配置
    instrument_id_list = [b'rb2010']  # 需要订阅的合约列表
    future_account = get_simnow_account(
        investor_id=b'',  # SimNow账户
        password=b'',  # SimNow账户密码
        instrument_id_list=instrument_id_list,  # 合约列表
        server_name='TEST'  # 电信1、电信2、移动、TEST
    )

    #
    run_mdrecorder(future_account)

监控账户成交

from multiprocessing import Process, Queue
from AlgoPlus.CTP.MdApi import run_tick_engine
from AlgoPlus.CTP.TraderApi import run_traderapi
from AlgoPlus.CTP.FutureAccount import FutureAccount, get_simnow_account

if __name__ == '__main__':

    # 止盈止损参数
    pl_parameter = {
        'StrategyID': 9,
        'ProfitLossParameter': {
            b'rb2010': {'0': [2], '1': [2]},   # '0'代表止盈, '1'代表止损
            b'ni2007': {'0': [20], '1': [20]},   # '0'代表止盈, '1'代表止损
        },
    }

    # 账户配置
    instrument_id_list = []
    for instrument_id in pl_parameter['ProfitLossParameter']:
        instrument_id_list.append(instrument_id)
    future_account = get_simnow_account(
        investor_id='',                         # SimNow账户
        password='',                            # SimNow账户密码
        instrument_id_list=instrument_id_list,  # 合约列表
        server_name='TEST'                    # 电信1、电信2、移动、TEST
    )

    # 共享队列
    share_queue = Queue(maxsize=100)
    share_queue.put(pl_parameter)

    # 行情进程
    md_process = Process(target=run_tick_engine, args=(future_account, [share_queue]))
    # 交易进程
    trader_process = Process(target=run_traderapi, args=(future_account, share_queue))

    #
    md_process.start()
    trader_process.start()

    #
    md_process.join()
    trader_process.join()

开源地址

  1. 码云:https://gitee.com/AlgoPlus/
  2. GitHub:https://github.com/CTPPlus/AlgoPlus

QQ群与微信公众号

  • QQ群:866469866

  • 微信公众号:AlgoPlus

版权

MIT

MIT License Copyright (c) 2019 CTPPlus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

最忠实于CTP官方API特性、最低延时、最易使用的Python版量化投资开源框架。 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/jlycss/AlgoPlus.git
git@gitee.com:jlycss/AlgoPlus.git
jlycss
AlgoPlus
AlgoPlus
master

搜索帮助