Candles
Get historical price candles for an index.
Endpoint
https://api.marketdata.app/v1/indices/candles/{resolution}/{symbol}/
Method
GET
Request Example
- HTTP
- NodeJS
- Python
- Go
fetch(
"https://api.marketdata.app/v1/indices/candles/D/VIX?from=2022-09-01&to=2022-09-05"
)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
import requests
url = "https://api.marketdata.app/v1/indices/candles/D/VIX?from=2022-09-01&to=2022-09-05"
response = requests.request("GET", url)
print(response.text)
import (
"fmt"
api "github.com/MarketDataApp/sdk-go"
)
func ExampleIndicesCandlesRequest_get() {
vix, err := IndexCandles().Symbol("VIX").Resolution("D").From("2022-09-01").To("2022-09-05").Get()
if err != nil {
fmt.Println("Error retrieving VIX index candles:", err.Error())
return
}
for _, candle := range vix {
fmt.Println(candle)
}
}
Response Example
{
"s": "ok",
"c": [22.84, 23.93, 21.95, 21.44, 21.15],
"h": [23.27, 24.68, 23.92, 22.66, 22.58],
"l": [22.26, 22.67, 21.68, 21.44, 20.76],
"o": [22.41, 24.08, 23.86, 22.06, 21.5],
"t": [1659326400, 1659412800, 1659499200, 1659585600, 1659672000]
}
Request Parameters
- Required
- Dates
-
resolution
string
The duration of each candle.
Minutely Resolutions: (
minutely
,1
,3
,5
,15
,30
,45
, ...) Hourly Resolutions: (hourly
,H
,1H
,2H
, ...) Daily Resolutions: (daily
,D
,1D
,2D
, ...) Weekly Resolutions: (weekly
,W
,1W
,2W
, ...) Monthly Resolutions: (monthly
,M
,1M
,2M
, ...) Yearly Resolutions:(yearly
,Y
,1Y
,2Y
, ...) -
symbol
string
The index symbol, without any leading or trailing index identifiers. For example, use DJI do not use $DJI, ^DJI, .DJI, DJI.X, etc.
All date
parameters are optional. By default the most recent candle is returned if no date parameters are provided.
-
from
date
The leftmost candle on a chart (inclusive). From and countback are mutually exclusive. If you use
countback
,from
must be omitted. Accepted timestamp inputs: ISO 8601, unix, spreadsheet. -
to
date
The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
-
countback
number
Will fetch a specific number of candles before (to the left of)
to
. From and countback are mutually exclusive. If you usefrom
,countback
must be omitted.
There is no maximum date range limit on daily candles. When requesting intraday candles of any resolution, no more than 1 year of data can be requested in a single request.
Response Attributes
- Success
- No Data
- Error
-
s
string
Will always be
ok
when there is data for the candles requested. -
o
array[number]
Open price.
-
h
array[number]
High price.
-
l
array[number]
Low price.
-
c
array[number]
Close price.
-
t
array[number]
Candle time (Unix timestamp, UTC). Daily, weekly, monthly, yearly candles are returned without times.
-
s
string
Status will be
no_data
if no candles are found for the request. -
nextTime
number
optionalUnix time of the next quote if there is no data in the requested period, but there is data in a subsequent period.
-
s
string
Status will be
error
if the request produces an error response. -
errmsg
string
An error message.