Skip to main content

Get Trading Session Of The Day

This API is used to obtain the daily trading hours of each market.

SDK Links

Python
longport.openapi.QuoteContext.trading_session
Rust
longport::quote::QuoteContext#trading_session
Go
QuoteContext.TradingSession
Node.js
QuoteContext#tradingSession

Request

Request Example

# Get Trading Session Of The Day
# https://open.longportapp.com/docs/quote/pull/trade-session
# 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 longport.openapi import QuoteContext, Config

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

resp = ctx.trading_session()
print(resp)

Response

Response Properties

NameTypeDescription
market_trade_sessionobject[]Trading session data
∟ marketstringMarket

US - US market
HK - HK market
CN - CN market
SG - SG market
∟ trade_sessionobject[]Trading session
∟∟ beg_timeint32Being trading time, in hhmm format, for example: 900
∟∟ end_timeint32End trading time, in hhmm format, for example: 1400
∟∟ trade_sessionint32Trading session, see TradeSession

Protobuf

message MarketTradePeriodResponse {
repeated MarketTradePeriod market_trade_session = 1;
}

message MarketTradePeriod {
string market = 1;
repeated TradePeriod trade_session = 2;
}

message TradePeriod {
int32 beg_time = 1;
int32 end_time = 2;
TradeSession trade_session = 3;
}

Response JSON Example

{
"market_trade_session": [
{
"market": "US",
"trade_session": [
{
"beg_time": 930,
"end_time": 1600
},
{
"beg_time": 400,
"end_time": 930,
"trade_session": 1
},
{
"beg_time": 1600,
"end_time": 2000,
"trade_session": 2
}
]
},
{
"market": "HK",
"trade_session": [
{
"beg_time": 930,
"end_time": 1200
},
{
"beg_time": 1300,
"end_time": 1600
}
]
},
{
"market": "CN",
"trade_session": [
{
"beg_time": 930,
"end_time": 1130
},
{
"beg_time": 1300,
"end_time": 1457
}
]
},
{
"market": "SG",
"trade_session": [
{
"beg_time": 900,
"end_time": 1200
},
{
"beg_time": 1300,
"end_time": 1700
}
]
}
]
}

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