# Unsubscribe All Event Contract

unsubscribe_all_event_contract()

  • Description

    Unsubscribe from all event contract real-time market data on the current connection. After the call, order book, K-line, ticker and other pushes will no longer be received.

  • Parameters

    This interface takes no parameters. It unsubscribes all event contract subscriptions on the current connection.

  • Return

    Parameter Type Description
    ret RET_CODE Interface call result
    err_message None When ret == RET_OK, returns None
    str When ret != RET_OK, returns the error description
  • Example

from moomoo import *
import time

quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)

# Subscribe to multiple event contracts
quote_ctx.subscribe_event_contract(
    ['EC.KXODIMATCH-26JUL140600INDENG-IND'], [SubType.TICKER]
)
quote_ctx.subscribe_event_contract(
    ['EC.KXNFLAFCCHAMP-27-CIN'], [SubType.K_DAY]
)

# You can only unsubscribe at least 1 minute after subscribing
time.sleep(62)

# Unsubscribe all subscriptions at once
ret, err = quote_ctx.unsubscribe_all_event_contract()
if ret == RET_OK:
    print('All event contract subscriptions unsubscribed')
else:
    print('Unsubscribe failed:', err)

quote_ctx.close()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  • Output
All event contract subscriptions unsubscribed
1