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:

  • 获取沪深两个市场一段时间内的融资余额:

  1. logger.info(get_securities_margin('510050.XSHG', count=5))
  2. #[Out]
  3. #margin_balance buy_on_margin_value short_sell_quantity margin_repayment short_balance_quantity short_repayment_quantity short_balance total_balance
  4. #2016-08-01 7.811396e+09 50012306.0 3597600.0 41652042.0 15020600.0 1645576.0 NaN NaN
  5. #2016-08-02 7.826381e+09 34518238.0 2375700.0 19532586.0 14154000.0 3242300.0 NaN NaN
  6. #2016-08-03 7.733306e+09 17967333.0 4719700.0 111043009.0 16235600.0 2638100.0 NaN NaN
  7. #2016-08-04 7.741497e+09 30259359.0 6488600.0 22068637.0 17499000.0 5225200.0 NaN NaN
  8. #2016-08-05 7.726343e+09 25270756.0 2865863.0 40423859.0 14252363.0 6112500.0 NaN NaN
  • 获取沪深两个市场一段时间内的融资余额:
  1. logger.info(get_securities_margin(['XSHE', 'XSHG'], count=5, fields='margin_balance'))
  2. #[Out]
  3. # XSHE XSHG
  4. #2016-08-01 3.837627e+11 4.763557e+11
  5. #2016-08-02 3.828923e+11 4.763931e+11
  6. #2016-08-03 3.823545e+11 4.769321e+11
  7. #2016-08-04 3.833260e+11 4.776380e+11
  8. #2016-08-05 3.812751e+11 4.766928e+11
  • 获取上证个股以及整个上证市场融资融券情况:
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  1. logger.info(get_securities_margin(['XSHG', '601988.XSHG', '510050.XSHG'], count=5))
  2. #[Out]
  3. #<class 'pandas.core.panel.Panel'>
  4. #Dimensions: 8 (items) x 5 (major_axis) x 3 (minor_axis)
  5. #Items axis: margin_balance to total_balance
  6. #Major_axis axis: 2016-08-01 00:00:00 to 2016-08-05 00:00:00
  7. #Minor_axis axis: XSHG to 510050.XSHG
  • 获取50ETF融资偿还额情况
  1. logger.info(get_securities_margin('510050.XSHG', count=5, fields='margin_repayment'))
  2. #[Out]
  3. #2016-08-01 41652042.0
  4. #2016-08-02 19532586.0
  5. #2016-08-03 111043009.0
  6. #2016-08-04 22068637.0
  7. #2016-08-05 40423859.0
  8. #Name: margin_repayment, dtype: float64