# 国债回购
可获取深交所、上交所上市的各个期限的国债回购基础数据及行情数据,具体调用方式请参考:
- 合约列表,请使用 all_instruments 调取,参数及字段详情请参考 API-all_instruments.
In [8]: all_instruments('Repo')
Out[8]:
abbrev_symbol de_listed_date exchange listed_date ... status symbol trading_hours type
0 R-273 2012-12-10 XSHE 2012-12-10 ... Delisted 深市国债273天回购 09:31-11:30,13:01-15:30 Repo
1 GC001 0000-00-00 XSHG 2006-05-08 ... Active 1天国债回购 09:31-11:30,13:01-15:30 Repo
2 GC002 0000-00-00 XSHG 2006-05-08 ... Active 2天国债回购 09:31-11:30,13:01-15:30 Repo
3 GC003 0000-00-00 XSHG 2006-05-08 ... Active 3天国债回购 09:31-11:30,13:01-15:30 Repo
4 GC004 0000-00-00 XSHG 2006-05-08 ... Active 4天国债回购 09:31-11:30,13:01-15:30 Repo
...
- 基础合约,请使用 instruments 调取,参数及字段详情请参考 API-instruments.
In[]:instruments('131810.XSHE')
Out[]:Instrument(order_book_id='131810.XSHE', symbol='深市国债1天回购', abbrev_symbol='R-001', exchange='XSHE', status='Active', listed_date='2012-12-10', de_listed_date='0000-00-00', round_lot=1000, type='Repo', trading_hours='09:31-11:30,13:01-15:30')
- 历史日行情、分钟行情、tick 行情数据,请使用 get_price 调取,参数及字段详情请参考 API-get_price.
In [9]: get_price('131810.XSHE')
Out[9]:
num_trades open volume low close total_turnover high
2019-12-18 794349.0 2.600 84141413.0 1.600 1.600 8.414141e+10 2.951
2019-12-19 836675.0 2.300 82446069.0 1.450 1.450 8.244607e+10 2.706
2019-12-20 811976.0 2.100 81157294.0 2.060 2.800 8.115729e+10 3.300
...
- 实时行情,请使用 get_ticks 调取,参数及字段详情请参考 API-get_ticks.
In[]:get_ticks('131810.XSHE')
Out[]:
open last high low iopv prev_iopv limit_up limit_down prev_close volume total_turnover a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 a1_v a2_v a3_v a4_v a5_v b1_v b2_v b3_v b4_v b5_v
datetime
2020-03-18 09:15:03 0.000 0.004 0.0 0.000 0.0 0.0 1.000000e+09 0.001 0.004 0.0 0.000000e+00 0.008 0.000 0.000 0.000 0.00 0.008 0.000 0.0 0.000 0.0 376020.0 0.0 0.0 0.0 0.0 376020.0 3042780.0 0.0 0.0 0.0
2020-03-18 09:15:12 0.000 0.004 0.0 0.000 0.0 0.0 1.000000e+09 0.001 0.004 0.0 0.000000e+00 0.008 0.000 0.000 0.000 0.00 0.008 0.000 0.0 0.000 0.0 463360.0 0.0 0.0 0.0 0.0 463360.0 2965440.0 0.0 0.0 0.0
2020-03-18 09:15:30 0.000 0.004 0.0 0.000 0.0 0.0 1.000000e+09 0.001 0.004 0.0 0.000000e+00 0.008 0.000 0.000 0.000 0.00 0.008 0.000 0.0 0.000 0.0 464720.0 0.0 0.0 0.0 0.0 464720.0 2964080.0 0.0 0.0 0.0
...
# 银行间同业拆放利率
# get_interbank_offered_rate - 获取上海银行间同业拆放利率数据
rqdatac.get_interbank_offered_rate(fields, start_date=None, end_date=None, source='Shibor')
获取上海银行间同业拆放利率(Shanghai Interbank Offered Rate,简称 Shibor)数据
# 参数
参数 | 类型 | 说明 |
---|---|---|
start_date | str, datetime.date, datetime.datetime, pandasTimestamp | 开始日期,默认为去年的查询当日 |
end_date | str, datetime.date, datetime.datetime, pandasTimestamp | 结束日期,默认为查询当日 |
fields | str, str list | 字段名称,默认获取全部字段 |
source | str | 数据源,目前仅支持 Shibor |
# 返回
pandas DataFrame
返回 | 类型 | 说明 |
---|---|---|
date | datetime.date | 日期 |
fields | float | 'ON':隔夜 '1W':1 周 '2W':2 周 '1M':1 个月 '3M':3 个月周 '6M':6 个月周 '9M':9 个月周 '1M':1 年 |
# 范例
- 获取一段时间的 Shibor 数据。
[In]
rqdatac.get_interbank_offered_rate(20230501,20230530)
[Out]
ON 1W 2W 1M 3M 6M 9M 1Y
date
2023-05-04 1.658 1.963 1.979 2.294 2.414 2.501 2.582 2.636
2023-05-05 1.234 1.815 1.920 2.277 2.401 2.491 2.564 2.618
2023-05-06 1.095 1.745 1.764 2.259 2.393 2.481 2.548 2.603
2023-05-08 1.408 1.795 1.793 2.248 2.386 2.470 2.540 2.596
2023-05-09 1.239 1.825 1.813 2.235 2.377 2.462 2.529 2.583
2023-05-10 1.110 1.902 1.861 2.228 2.363 2.452 2.521 2.569
2023-05-11 1.102 1.803 1.818 2.212 2.349 2.439 2.502 2.548
2023-05-12 1.320 1.829 1.846 2.199 2.325 2.427 2.487 2.524
2023-05-15 1.523 1.874 1.909 2.189 2.311 2.419 2.474 2.508
2023-05-16 1.476 1.766 1.822 2.180 2.294 2.410 2.462 2.496
2023-05-17 1.540 1.844 1.870 2.160 2.288 2.403 2.454 2.490
2023-05-18 1.463 1.760 1.948 2.136 2.278 2.392 2.447 2.490
2023-05-19 1.408 1.910 2.062 2.131 2.269 2.390 2.445 2.489
2023-05-22 1.276 1.897 2.100 2.124 2.262 2.379 2.442 2.489
2023-05-23 1.224 1.824 2.065 2.117 2.255 2.372 2.438 2.484
2023-05-24 1.271 1.762 2.050 2.113 2.252 2.366 2.438 2.481
2023-05-25 1.578 1.908 2.050 2.111 2.243 2.364 2.436 2.478
2023-05-26 1.438 1.992 2.096 2.108 2.238 2.358 2.434 2.478
2023-05-29 1.370 1.937 2.051 2.104 2.233 2.355 2.425 2.474