Skip to main content

Candlesticks

Interface Description

  • Function description:

    • Returns to Instrument in the window aggregated data.

    • According to the last N K-lines of the stock code, it supports various granularity K-lines such as m1 and m5. Currently, only the K-line with the previous weight is provided for the daily K-line and above, and only the un-weighted K-line is provided for the minute K.

  • URL: /market-data/bars

  • Method: GET

  • Rate limit: The calling frequency of each App ID is limited to 60 times per minute.

Request Parameters

ParameterTypeRequired fieldsDescription
symbolStringYesSecurities code, eg: BTCUSD
categoryStringYesSecurity Type, Enumeration, Reference:Category
timespanStringYesK-line time granularity. Reference: Timespan
countIntegerNoThe number of lines: the default is 200, and the maximum limit is 1440

Response Parameter

FieldTypeDescription
timestampLongUTC timestamp, eg: 1739100939000
openStringOpening price
closeStringClosing price
highStringHighest price
lowStringLowest price

Request Example

from webullpaysdkcore.client import ApiClient
from webullpaysdkmdata.common.category import Category
from webullpaysdkmdata.common.timespan import Timespan
from webullpaysdkmdata.request.get_historical_bars_request import GetHistoricalBarsRequest
from webullpaysdkcore.common.region import Region

your_app_key = "<your_app_key>"
your_app_secret = "<your_app_secret>"

api_client = ApiClient(your_app_key, your_app_secret, Region.US.value)
request = GetHistoricalBarsRequest()
request.set_category(Category.CRYPTO.name)
request.set_symbol("BTCUSD")
request.set_count(1440)
request.set_timespan(Timespan.M1.name)
response = api_client.get_response(request)
if response.status_code == 200:
bars = response.json()
print(bars)

Response Example

[
{
"timestamp": 1739100939000,
"open": "100",
"close": "101",
"high": "105",
"low": "99"
}
]