Skip to main content

Get Security Candlesticks

This API is used to obtain the candlestick data of security.

Request

Parameters

NameTypeRequiredDescription
symbolstringYesSecurity code, in ticker.region format, for example:700.HK
periodint32YesCandlestick period, for example: 1000, see Period
countint32YesCount of cancdlestick, for example: 100

Check rules:
maximum count is 1000
adjust_typeint32YesAdjustment type, for example: 0, see AdjustType

Protobuf

message SecurityCandlestickRequest {
string symbol = 1;
Period period = 2;
int32 count = 3;
AdjustType adjust_type = 4;
}

Request Example

# Get Security Candlesticks
# https://open.longportapp.com/docs/quote/pull/candlestick
# 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, Period, AdjustType

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

resp = ctx.candlesticks("700.HK", Period.Day, 10, AdjustType.NoAdjust)
print(resp)

Response

Response Properties

NameTypeDescription
symbolstringSecurity code, for example: AAPL.US
candlesticksobject[]Candlestick data
∟ closestringClose price
∟ openstringOpen price
∟ lowstringLow price
∟ highstringHigh price
∟ volumeint64Volume
∟ turnoverstringTurnover
∟ timestampint64Timestamp

Protobuf

message SecurityCandlestickResponse {
string symbol = 1;
repeated Candlestick candlesticks = 2;
}

message Candlestick {
string close = 1;
string open = 2;
string low = 3;
string high = 4;
int64 volume = 5;
string turnover = 6;
int64 timestamp = 7;
}

Response JSON Example

{
"symbol": "700.HK",
"candlesticks": [
{
"close": "362.000",
"open": "364.600",
"low": "361.600",
"high": "368.800",
"volume": 10853604,
"turnover": "3954556819.000",
"timestamp": 1650384000
},
{
"close": "348.000",
"open": "352.000",
"low": "343.000",
"high": "356.200",
"volume": 25738562,
"turnover": "8981529950.000",
"timestamp": 1650470400
},
{
"close": "340.600",
"open": "334.800",
"low": "334.200",
"high": "343.000",
"volume": 28031299,
"turnover": "9492674293.000",
"timestamp": 1650556800
},
{
"close": "327.400",
"open": "332.200",
"low": "325.200",
"high": "338.600",
"volume": 25788422,
"turnover": "8541441823.000",
"timestamp": 1650816000
},
{
"close": "335.800",
"open": "332.200",
"low": "330.600",
"high": "341.600",
"volume": 27288328,
"turnover": "9166022626.000",
"timestamp": 1650902400
}
]
}

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: symbol, count, adjust_type, period
7301603No quotesSecurity no quote
7301604No accessNo access to security quote
7301607Too many candlesticks requetedReduce the amount of candlestick in each request