All Projects → ricequant → Rqopen Client

ricequant / Rqopen Client

rqopen-client:本地拿到Ricequant上实盘模拟交易策略的交易信号和持仓

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Rqopen Client

Strategyease Python Sdk
策略易(StrategyEase)Python SDK,策略自动化交易 API 及量化平台。
Stars: ✭ 741 (+850%)
Mutual labels:  trade, quant
Openapi Python Sdk
Python SDK for Tiger Open API
Stars: ✭ 80 (+2.56%)
Mutual labels:  trade, quant
Vngo
golang version of vn.py
Stars: ✭ 25 (-67.95%)
Mutual labels:  trade, quant
DeltaTrader
极简版Python量化交易工具
Stars: ✭ 174 (+123.08%)
Mutual labels:  quant, trade
Nodequant
一个基于Node.js的开源量化交易平台,轻巧地开发和部署量化投资策略
Stars: ✭ 444 (+469.23%)
Mutual labels:  trade, quant
trader
交易模块
Stars: ✭ 20 (-74.36%)
Mutual labels:  quant, trade
Amazingquant
基于Event-driven的量化交易解决方案
Stars: ✭ 128 (+64.1%)
Mutual labels:  trade, quant
Funcat
Funcat 将同花顺、通达信、文华财经麦语言等的公式写法移植到了 Python 中。
Stars: ✭ 642 (+723.08%)
Mutual labels:  trade, quant
Abu
阿布量化交易系统(股票,期权,期货,比特币,机器学习) 基于python的开源量化交易,量化投资架构
Stars: ✭ 8,589 (+10911.54%)
Mutual labels:  trade, quant
Awesome Ai In Finance
🔬 A curated list of awesome machine learning strategies & tools in financial market.
Stars: ✭ 910 (+1066.67%)
Mutual labels:  quant
Tsukibot
Discord CryptoBot for Spot Prices
Stars: ✭ 38 (-51.28%)
Mutual labels:  trade
Quantaxis spider
QUANTAXIS 爬虫mod python/javascript/mongodb
Stars: ✭ 13 (-83.33%)
Mutual labels:  quant
Cryptoinscriber
📈 A live cryptocurrency historical trade data blotter. Download live historical trade data from any cryptoexchange, be it for machine learning, backtesting/visualizing trading strategies or for Quantopian/Zipline.
Stars: ✭ 27 (-65.38%)
Mutual labels:  trade
Python stock github
Python 量化投资及 Github 管理学习笔记
Stars: ✭ 39 (-50%)
Mutual labels:  quant
Mcafee Bot
buy coins based on @officialmcafee tweets
Stars: ✭ 61 (-21.79%)
Mutual labels:  trade
Deeplearning Trader
backtrader with DRL ( Deep Reinforcement Learning)
Stars: ✭ 24 (-69.23%)
Mutual labels:  trade
Alpaca Trade Api Python
Python client for Alpaca's trade API
Stars: ✭ 912 (+1069.23%)
Mutual labels:  trade
Element43
Market, Trade and Industry Manager for EVE Online
Stars: ✭ 72 (-7.69%)
Mutual labels:  trade
Pyspider Stock
A project using pyspider to collect data and NLP techs to analyze the correlation among the data
Stars: ✭ 56 (-28.21%)
Mutual labels:  quant
Quant Finance Resources
Courses, Articles and many more which can help beginners or professionals.
Stars: ✭ 36 (-53.85%)
Mutual labels:  quant

RQOpen-Client - RQOpen客户端

简介

通过这个简单的python库,你可以拿到你在 www.ricequant.com 运行的实盘、模拟交易或回测的运行数据。包含交易列表,仓位信息,投资组合信息。

RQOpen 获取到的信号,会比系统时间稍微延迟一些。Ricequant Gateway 在切分钟线的时候会延迟10多秒,因为数据源的问题。而 RQAlpha 产生信号后,保存在数据库中。由 RQOpen 轮训,轮训的间隔,也是信号的延迟时间。

安装

pip install rqopen-client

简单的范例

from pprint import pprint
from rqopen_client import RQOpenClient

username = "your ricequant username"
password = "your ricequant password"
run_id = your_run_id

client = RQOpenClient(username, password)
# client = RQOpenClient(username, password, return_df=Fales)

pprint(client.trades(run_id))
pprint(client.current_positions(run_id))

上面代码的一些展示结果(随便一个范例):

初始化&登录: RQOpenClient(username, password, return_df=True)

:param username: 登录账户
:param password: 密码
:param logger: 日志
:param log_level: 日志级别
:param base_url: 服务地址,默认web端   rqpro2.0需要单独配置
:param timeout: 超时时间
:param return_df: 返回数据是否为DataFrame  False返回dict

查询当日交易记录: current_trades(run_id)

返回示例 - 今天没有任何下单:

# return_df=False
{'code': 200,
 'resp': {'name': '改进版小盘股 2016-08-28 16:15:06', 'run_id': 968101, 'trades': []}}

# return_df=True
Empty DataFrame
Columns: []
Index: []

返回示例 - 当日有交易:

# return_df=False
{'code': 200,
 'resp': {'data': [{'commission': 5.0,
                    'date': '2019-01-04 09:31:00',
                    'exec_id': '15641121150000',
                    'last_price': 9.29,
                    'last_quantity': 100.0,
                    'order_book_id': '000001.XSHE',
                    'order_id': 15641121140000,
                    'position_effect': 'OPEN',
                    'side': 'BUY',
                    'tax': 0.0,
                    'trade_id': '15641121150000',
                    'transaction_cost': 5.0},
                   {'commission': 5.0,
                    'date': '2019-01-04 09:31:00',
                    'exec_id': '15641121150002',
                    'last_price': 16.29,
                    'last_quantity': 100.0,
                    'order_book_id': '000004.XSHE',
                    'order_id': 15641121140002,
                    'position_effect': 'OPEN',
                    'side': 'BUY',
                    'tax': 0.0,
                    'trade_id': '15641121150002',
                    'transaction_cost': 5.0}],
          'name': 'SVM大法好',
          'run_id': 6281}}

# return_df=True
                     commission  ... transaction_cost
date                             ...                 
2018-05-04 09:31:00       8.568  ...            8.568
2018-05-04 09:32:00       8.608  ...            8.608
2018-05-04 09:33:00       8.592  ...            8.592
2018-05-04 09:34:00       8.600  ...            8.600
2018-05-04 09:35:00       8.592  ...            8.592

查询最新持仓: current_positions(run_id)

返回示 - 有持仓:

# return_df=False
{'code': 200,
 'resp': {'name':  'SVM大法好',
  'run_id': 6281,
  'positions': [{'order_book_id': '000001.XSHE',
    'last_price': 13.86,
    'quantity': 5062.0},
   {'order_book_id': '000002.XSHE', 'last_price': 32.22, 'quantity': 4939.0},
   {'order_book_id': '000004.XSHE', 'last_price': 21.67, 'quantity': 4341.0},
   {'order_book_id': '000005.XSHE', 'last_price': 3.97, 'quantity': 4903.0}}]}}

# return_df=True
    last_price order_book_id  quantity
0        13.86   000001.XSHE    5062.0
1        32.22   000002.XSHE    4939.0
2        21.67   000004.XSHE    4341.0
3         3.97   000005.XSHE    4903.0
4         7.13   000006.XSHE    5011.0
5         7.57   000007.XSHE    4955.0
6         4.97   000008.XSHE    4906.0
7         7.19   000009.XSHE    4995.0
8         3.76   000010.XSHE    4996.0
9        12.19   000011.XSHE    4931.0
10        5.81   000012.XSHE    4984.0
11       12.75   000014.XSHE    4974.0

查询全部交易: trades(run_id)

返回示 - 有交易:

# return_df=False
{'code': 200,
 'resp': {'data': [{'commission': 5.0,
                    'date': '2019-01-07 11:05:00',
                    'exec_id': '15641121150040',
                    'last_price': 3.36,
                    'last_quantity': 1.0,
                    'order_book_id': '000010.XSHE',
                    'order_id': 15641121140202,
                    'position_effect': 'CLOSE',
                    'side': 'SELL',
                    'tax': 0.0033599999999998076,
                    'trade_id': '15641121150040',
                    'transaction_cost': 5.00336},
          'name': '横琴比赛',
          'run_id': 6281}}

# return_df=True
                     commission  ... transaction_cost
date                             ...                 
2019-01-04 09:31:00         5.0  ...          5.00000
2019-01-04 09:31:00         5.0  ...          5.00000
                         ...  ...              ...
2019-04-04 14:44:00         5.0  ...          5.10176
2019-04-04 14:54:00         5.0  ...          5.06417
[3102 rows x 11 columns]

查询全部持仓: positions(run_id)

返回示 - 有持仓:

# return_df=False
{'code': 200,
 'resp': {'data': [{'000001.XSHE': 975.0, # market_value
                    '000002.XSHE': 2493.0,
                    '000004.XSHE': 1660.0000000000002,
                    '000005.XSHE': 275.0,
                    '000006.XSHE': 526.0,
                    '000007.XSHE': 800.0,
                    '000008.XSHE': 391.0,
                    '000009.XSHE': 437.0,
                    '000010.XSHE': 332.0,
                    '000011.XSHE': 956.0,
                    '000012.XSHE': 409.99999999999994,
                    '000014.XSHE': 969.0,
                    'cash': 1990076.0,
                    'date': '2019-01-04 00:00:00'},
          'name': '横琴比赛',
          'run_id': 6281}}

# return_df=True
            000001.XSHE  000002.XSHE  ...  000014.XSHE          cash
date                                  ...                           
2019-01-04       975.00      2493.00  ...       969.00  1.990076e+06
2019-01-07      1801.90      4534.05  ...      1664.99  1.981082e+06
2019-01-08      2675.82      6950.00  ...      2388.66  1.972075e+06
2019-01-09      3618.16      9144.13  ...      3246.15  1.963209e+06
[4rows x 13 columns]

查询投资组合: portfolio(run_id)

# return_df=False
{'code': 200,
 'resp': {'data': [{'annualized_returns': 0.038520563489603976,
                    'benchmark_daily_returns': 0.023957447956719332,
                    'benchmark_total_returns': 0.023957447956719332,
                    'cash': 1990076.0,
                    'daily_pnl': 300.000000000189,
                    'daily_returns': 0.0001500000000000945,
                    'date': '2019-01-04 00:00:00',
                    'market_value': 10224.0,
                    'portfolio_value': 2000300.0,
                    'starting_cash': 2000000.0,
                    'total_returns': 0.0001500000000000945,
                    'transaction_cost': 60.0},],
          'name': '横琴比赛',
          'run_id': 6281}}

# return_df=True
            annualized_returns  ...  transaction_cost
date                            ...                  
2019-01-04            0.038521  ...          60.00000
2019-01-07            0.022092  ...         226.54735
2019-01-08           -0.005048  ...         251.59331
2019-01-09           -0.004138  ...         266.77119=
[4 rows x 11 columns]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].