Skip to Content

Market Trading Days

This API is used to obtain the trading days of the market.

ℹ️Info

Request

Parameters

NameTypeRequiredDescription
marketstringYesMarket

Optional value:
US - US market
HK - HK market
CN - CN market
SG - SG market
beg_daystringYesbegin day, in YYMMDD format, for example: 20220401
end_daystringYesbegin day, in YYMMDD format, for example: 20220420

Check rules:
The interval cannot be greater than one month
Only supports query data of the most recent year

Protobuf

protobuf
message MarketTradeDayRequest {
  string market = 1;
  string beg_day = 2;
  string end_day = 3;
}

Request Example

python
# Get Market Trading Days
# https://open.longportapp.com/docs/quote/pull/trade-day
# Before running, please visit the "Developers to ensure that the account has the correct quotes authority.
# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "LongPort" mobile app.
from datetime import date
from longport.openapi import QuoteContext, Config, Market

config = Config.from_env()
ctx = QuoteContext(config)

resp = ctx.trading_days(Market.HK, date(2022, 1, 1), date(2022, 2, 1))
print(resp)

Response

Response Properties

NameTypeDescription
trade_daystring[]Trading days, in YYMMDD format
half_trade_daystring[]Half trading days, in YYMMDD format

Protobuf

protobuf
message MarketTradeDayResponse {
  repeated string trade_day = 1;
  repeated string half_trade_day = 2;
}

Response JSON Example

json
{
  "trade_day": [
    "20220120",
    "20220121",
    "20220124",
    "20220125",
    "20220126",
    "20220127",
    "20220128",
    "20220204",
    "20220207",
    "20220208",
    "20220209",
    "20220210"
  ],
  "half_trade_day": ["20220131"]
}

Error Code

Protocol Error CodeBusiness Error CodeDescriptionTroubleshooting Suggestions
3301600Invalid requestInvalid request parameters or unpacking request failed
3301606Request rate limitReduce the frequency of requests
7301602Server errorPlease try again or contact a technician to resolve the issue
7301600Invalue request parametersPlease check the request parameter: market, beg_day, end_day