get_securities_margin - 融资融券信息
getsecurities_margin
(_order_book_id, count=1, fields=None)- 获取融资融券信息。包括 深证融资融券数据 以及 上证融资融券数据 情况。既包括个股数据,也包括市场整体数据。需要注意,融资融券的开始日期为2010年3月31日。
参数:
- order_book_id (str | list[str]) – 可输入order_book_id, order_book_id list, symbol, symbol list。另外,输入’XSHG’或’sh’代表整个上证整体情况;’XSHE’或’sz’代表深证整体情况
- count (int) – 回溯获取的数据个数。默认为当前能够获取到的最近的数据
- fields (str) – 默认为所有字段。见下方列表
fields字段名margin_balance融资余额buy_on_margin_value融资买入额margin_repayment融资偿还额short_balance融券余额short_balance_quantity融券余量short_sell_value融券卖出额short_sell_quantity融券卖出量short_repayment_quantity融券偿还量total_balance融资融券余额
返回:
- 多个order_book_id,单个field的时候返回DataFrame,index为date,column为order_book_id
- 单个order_book_id,多个fields的时候返回DataFrame,index为date,column为fields
- 单个order_book_id,单个field返回Series
多个order_book_id,多个fields的时候返回DataPanel Items axis为fields Major_axis axis为时间戳 Minor_axis axis为order_book_idExample:
获取沪深两个市场一段时间内的融资余额:
- logger.info(get_securities_margin('510050.XSHG', count=5))
- #[Out]
- #margin_balance buy_on_margin_value short_sell_quantity margin_repayment short_balance_quantity short_repayment_quantity short_balance total_balance
- #2016-08-01 7.811396e+09 50012306.0 3597600.0 41652042.0 15020600.0 1645576.0 NaN NaN
- #2016-08-02 7.826381e+09 34518238.0 2375700.0 19532586.0 14154000.0 3242300.0 NaN NaN
- #2016-08-03 7.733306e+09 17967333.0 4719700.0 111043009.0 16235600.0 2638100.0 NaN NaN
- #2016-08-04 7.741497e+09 30259359.0 6488600.0 22068637.0 17499000.0 5225200.0 NaN NaN
- #2016-08-05 7.726343e+09 25270756.0 2865863.0 40423859.0 14252363.0 6112500.0 NaN NaN
- 获取沪深两个市场一段时间内的融资余额:
- logger.info(get_securities_margin(['XSHE', 'XSHG'], count=5, fields='margin_balance'))
- #[Out]
- # XSHE XSHG
- #2016-08-01 3.837627e+11 4.763557e+11
- #2016-08-02 3.828923e+11 4.763931e+11
- #2016-08-03 3.823545e+11 4.769321e+11
- #2016-08-04 3.833260e+11 4.776380e+11
- #2016-08-05 3.812751e+11 4.766928e+11
- 获取上证个股以及整个上证市场融资融券情况:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- logger.info(get_securities_margin(['XSHG', '601988.XSHG', '510050.XSHG'], count=5))
- #[Out]
- #<class 'pandas.core.panel.Panel'>
- #Dimensions: 8 (items) x 5 (major_axis) x 3 (minor_axis)
- #Items axis: margin_balance to total_balance
- #Major_axis axis: 2016-08-01 00:00:00 to 2016-08-05 00:00:00
- #Minor_axis axis: XSHG to 510050.XSHG
- 获取50ETF融资偿还额情况
- logger.info(get_securities_margin('510050.XSHG', count=5, fields='margin_repayment'))
- #[Out]
- #2016-08-01 41652042.0
- #2016-08-02 19532586.0
- #2016-08-03 111043009.0
- #2016-08-04 22068637.0
- #2016-08-05 40423859.0
- #Name: margin_repayment, dtype: float64