# Get Margin Data

get_margin_ratio(code_list)

  • Description

    Query the margin data of stocks.

  • Parameters

    Parameter Type Description
    code_list list Stock list.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, margin data is returned.
    str If ret != RET_OK, error description is returned.
    • Margin data format as follows:
      Field Type Description
      code str Stock code
      is_long_permit bool Is marginable trading allowed.
      is_short_permit bool Is shortable trading allowed.
      short_pool_remain float Short pool remaining.
      short_fee_rate float Borrow rate.
      alert_long_ratio float Marginable alert margin.
      alert_short_ratio float Shortable alert margin.
      im_long_ratio float Marginable initial margin.
      im_short_ratio float Shortable initial margin.
      mcm_long_ratio float Marginable margin call margin.
      mcm_short_ratio float Shortable margin call margin.
      mm_long_ratio float Marginable maintenance margin.
      mm_short_ratio float Marginable maintenance margin.
  • Example

from futu import *
trd_ctx = OpenSecTradeContext(filter_trdmarket=TrdMarket.HK, host='127.0.0.1', port=11111, security_firm=SecurityFirm.FUTUSECURITIES)
ret, data = trd_ctx.get_margin_ratio(code_list=['HK.00700','HK.09988'])  
if ret == RET_OK:
    print(data)
	print(data['is_long_permit'][0])  # Get whether marginable trading allowed for the first stock
    print(data['im_short_ratio'].values.tolist())  # Convert to list
else:
    print('error:', data)
trd_ctx.close()  # After using the connection, remember to close it to prevent the number of connections from running out
1
2
3
4
5
6
7
8
9
10
  • Output
       code  is_long_permit  is_short_permit  short_pool_remain  short_fee_rate  alert_long_ratio  alert_short_ratio  im_long_ratio  im_short_ratio  mcm_long_ratio  mcm_short_ratio  mm_long_ratio  mm_short_ratio
0  HK.00700            True             True          1826900.0            0.89              33.0               56.0           35.0            60.0            32.0             53.0           25.0            40.0
1  HK.09988            True             True          1150600.0            0.95              48.0               46.0           50.0            50.0            47.0             43.0           40.0            30.0
True
[60.0, 50.0]
1
2
3
4
5

Interface Limitations

  • A maximum of 10 requests per 30 seconds.
  • For each request, the maximum number of stocks supported by the parameter is 100.
  • Only HK stocks and US stocks are supported.