As is documented here, a request to the kline endpoint returns a list with all the data such as kline open time etc. In the docs it is commented out. Why is this endpoint not strongly typed, so that you can access the data easier inside your program? e. g.:
[
{
"OpenTime": 12345674,
"High": 13.0,
"CloseTime": 12345675
....
}
]
My attempt at doing this, aka casting untyped list to a proper object is the following:
type KlineRecord = {
OpenTime : decimal
OpenPrice : decimal
HighPrice : decimal
LowPrice : decimal
ClosePrice : decimal
Volume : decimal
CloseTime : decimal
QuoteAssetVolume : decimal
NumberOfTrades : decimal
TakerBuyBaseAssetVolume : decimal
TakerBuyQuoteAssetVolume : decimal
Ignore : decimal
}
let kline symbol interval =
market.KlineCandlestickData(symbol, interval)
|> Async.AwaitTask
|> Async.RunSynchronously
|> Kline.Parse
|> Array.map (fun f -> {
OpenTime = f[0]
OpenPrice = f[1]
HighPrice = f[2]
LowPrice = f[3]
ClosePrice = f[4]
Volume = f[5]
CloseTime = f[6]
QuoteAssetVolume = f[7]
NumberOfTrades = f[8]
TakerBuyBaseAssetVolume = f[9]
TakerBuyQuoteAssetVolume = f[10]
Ignore = f[11]
})
Hope you guys can give me some feedback on my approach, and whether we can ask someone to change the api for easier access.