可获取上海黄金现货交易所上市的现货,包含黄金、铂金、白银等的基础信息及日行情、分钟行情、tick 行情数据,具体调用方式请参考:
- 合约列表,请使用 all_instruments 调取,参数及字段详情请参考 API-all_instruments.
In [4]: all_instruments('Spot')
Out[4]:
de_listed_date exchange listed_date market_tplus order_book_id symbol trading_hours type
0 0000-00-00 SGEX 2003-07-30 0 PT9995.SGEX 铂金现货(Pt99.95合约) 09:31-11:30,13:01-15:00 Spot
1 0000-00-00 SGEX 2014-09-19 0 IAU100G.SGEX 国际黄金现货(iAu100g合约) 09:31-11:30,13:01-15:00 Spot
2 0000-00-00 SGEX 2006-10-30 0 AU9995.SGEX 黄金现货(Au99.95合约) 09:31-11:30,13:01-15:00 Spot
3 0000-00-00 SGEX 2002-10-30 0 AU9999.SGEX 黄金现货(Au99.99合约) 09:31-11:30,13:01-15:00 Spot
...
- 基础合约,请使用 instruments 调取,参数及字段详情请参考 API-all_instruments.
In [5]: instruments('AUTD.SGEX')
Out[5]: Instrument(order_book_id='AUTD.SGEX', symbol='黄金现货(Au(T+D)合约)', exchange='SGEX', listed_date='2004-08-16', type='Spot', de_listed_date='0000-00-00', trading_hours='09:31-11:30,13:01-15:00', market_tplus=0)
- 日行情数据,请使用 get_price 调取,参数及字段详情请参考 API-get_price.
In [7]: get_price('AUTD.SGEX',20200301,20200317)
Out[7]:
open_interest open volume low close total_turnover high
2020-03-02 259220.0 365.30 189052.0 352.34 359.00 6.804021e+10 366.07
2020-03-03 256530.0 359.70 81836.0 356.17 358.23 2.927269e+10 359.98
...
2020-03-16 266458.0 354.89 320914.0 340.03 344.66 1.117367e+11 358.15
2020-03-17 277112.0 330.77 244946.0 330.77 330.78 8.159528e+10 339.50
- 分钟行情数据,可使用 get_price 调取历史和实时分钟数据,参数和字段详情请参考 API-get_price.
In [8]:get_price('AUTD.SGEX',20200810,20200810,'1m')
Out[8]:
close high low open_interest open volume trading_date total_turnover
datetime
2020-08-07 20:01:00 443.55 444.86 443.12 290956.0 444.60 998.0 2020-08-10 443036900.0
2020-08-07 20:02:00 444.60 444.60 443.30 290876.0 443.60 1108.0 2020-08-10 491766680.0
2020-08-07 20:03:00 445.18 445.18 444.50 290974.0 444.60 822.0 2020-08-10 365613320.0
...
2020-08-10 15:28:00 441.91 441.91 441.82 300704.0 441.88 316.0 2020-08-10 139636220.0
2020-08-10 15:29:00 441.92 441.92 441.82 300718.0 441.90 156.0 2020-08-10 68934740.0
2020-08-10 15:30:00 442.00 442.00 441.90 289656.0 441.92 278.0 2020-08-10 122858880.0
- 使用 current_minute 获取 AUTD.SGEX 最近的分钟线数据,参数和字段请参考 API-current_minute.
In [9]:current_minute('AUTD.SGEX')
Out[9]:
close high low open open_interest total_turnover trading_date volume
order_book_id datetime
AUTD.SGEX 2020-08-26 15:30:00 412.38 412.39 412.3 412.39 251432.0 47830960.0 20200826 116
- tick 行情数据,可使用 get_price 调取历史和实时 tick 数据,参数和字段详情请参考 API-get_price.
In [10]:get_price('AUTD.SGEX',20200810,20200810,'tick')
Out[10]:
trading_date open last high low prev_settlement prev_close volume open_interest total_turnover ... a2_v a3_v a4_v a5_v b1_v b2_v b3_v b4_v b5_v change_rate
datetime
2020-08-07 19:33:16.446 2020-08-10 0.0 445.72 0.00 0.0 445.94 445.72 0.0 290930.0 0.000000e+00 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.000493
2020-08-07 19:45:05.514 2020-08-10 0.0 445.72 0.00 0.0 445.94 445.72 0.0 290930.0 0.000000e+00 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.000493
2020-08-07 19:45:16.267 2020-08-10 0.0 445.72 0.00 0.0 445.94 445.72 0.0 290930.0 0.000000e+00 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.000493
...
2020-08-10 15:44:23.717 2020-08-10 444.6 442.00 447.09 438.9 445.94 445.72 171746.0 289656.0 7.603756e+10 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.008835
2020-08-10 15:44:33.717 2020-08-10 444.6 442.00 447.09 438.9 445.94 445.72 171746.0 289656.0 7.603756e+10 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.008835
2020-08-10 15:44:43.717 2020-08-10 444.6 442.00 447.09 438.9 445.94 445.72 171746.0 289656.0 7.603756e+10 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.008835
- 使用 current_snapshot 获取 AUTD.SGEX 快照数据,参数和字段请参考 API-current_snapshot.
In [9]:current_snapshot('AUTD.SGEX')
Out[9]:
Tick(ask_vols: [3, 6, 3, 1, 1], asks: [412.38, 412.4, 412.45, 412.48, 412.49], bid_vols: [56, 2, 3, 1, 1], bids: [412.3, 412.25, 412.2, 412.17, 412.1], datetime: 2020-08-26 15:45:08.031000, high: 414.1, iopv: nan, last: 412.38, low: 411.16, open: 412.8, open_interest: 245154.0, order_book_id: AUTD.SGEX, prev_close: 413.8, prev_iopv: nan, prev_settlement: 414.68, total_turnover: 21982639060.0, trading_phase_code: None, volume: 53250)
# get_spot_benchmark_price - 获取现货早午盘价
get_price_change_rate(id_or_symbols, start_date='20130104', end_date='20140104', expect_df=True)
获取现货一段时间的早午盘价格。
# 参数
参数 | 类型 | 说明 |
---|---|---|
id_or_symbols | str or str list | 可输入 'AU9999.SGEX'或者'AG9999.SGEX' |
start_date | str, datetime.date, datetime.datetime, pandasTimestamp | 开始日期,默认为近 3 个月 |
end_date | str, datetime.date, datetime.datetime, pandasTimestamp | 结束日期,默认为近 3 个月 |
# 返回
pandas DataFrame
返回 | 类型 | 说明 |
---|---|---|
order_book_ids | str | 合约代码 |
date | datetime.date | 日期 |
morning | float | 早盘价度 |
noon | float | 午盘价度 |
# 范例
- 获取黄金一段时间的早午盘价格。
[In]
rqdatac.get_spot_benchmark_price('AU9999.SGEX',20230501,20230508)
[Out]
morning noon
order_book_id date
AU9999.SGEX 2023-05-04 453.77 453.24
2023-05-05 455.84 455.57