# Get Subscription Status

query_subscription(is_all_conn=True)

  • Description

    Get subscription information

  • Parameters

    Parameter Type Description
    is_all_conn bool Whether to return the subscription status of all connections.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data dict If ret == RET_OK, subscription information data is returned.
    str If ret != RET_OK, error description is returned.
    • subscription information data format as follows:

        {
            'total_used': subscription quota used by all connections,
            'own_used': The subscription quota used by the current connection,
            'remain': remaining subscription quota,
            'sub_list': The stock list corresponding to each subscription type,
            {
                'Subscription type': A list of all subscribed stocks under this subscription type,
                …
            }
        }
      
  • Example

from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)

quote_ctx.subscribe(['HK.00700'], [SubType.QUOTE])
ret, data = quote_ctx.query_subscription()
if ret == RET_OK:
    print(data)
else:
    print('error:', data)
quote_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
{'total_used': 1, 'remain': 999, 'own_used': 1, 'sub_list': {'QUOTE': ['HK.00700']}}
1