# Get Trading Calendar

request_trading_days(market=None, start=None, end=None, code=None)

  • Description

    Request trading calendar via market or code.
    Note that the trading day is obtained by excluding weekends and holidays from natural days, and the temporary market closed data is not excluded.

  • Parameters

    Parameter Type Description
    market TradeDateMarket Market type.
    start str Start date.
    end str End date.
    code str Security code.

    Note: when both market and code exist, market is ignored and only code is effective.

    • The combination of start and end is as follows
      Start type End type Description
      str str start and end are the specified dates respectively.
      None str start is 365 days before end.
      str None end is 365 days after start.
      None None start is 365 days before, end is the current date.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data list If ret == RET_OK, data of the trading day is returned. Data type of elements in the list is dict.
    str If ret != RET_OK, error description is returned.
    • Data of the trading day's format as follows:
      Field Type Description
      time str Time.
      trade_date_type TradeDateType Trading day type.
  • Example

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

ret, data = quote_ctx.request_trading_days(TradeDateMarket.HK, start='2020-04-01', end='2020-04-10')
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
  • Output
[{'time': '2020-04-01', 'trade_date_type': 'WHOLE'}, {'time': '2020-04-02', 'trade_date_type': 'WHOLE'}, {'time': '2020-04-03', 'trade_date_type': 'WHOLE'}, {'time': '2020-04-06', 'trade_date_type': 'WHOLE'}, {'time': '2020-04-07', 'trade_date_type': 'WHOLE'}, {'time': '2020-04-08', 'trade_date_type': 'WHOLE'}, {'time': '2020-04-09', 'trade_date_type': 'WHOLE'}]
1

Interface Limitations

  • A maximum of 30 requests per 30 seconds
  • The historical trading calendar provides data for the past 10 years, and the future trading calendar is available until December 31 this year.