indexPriceKlineCandlestickData method

Future<Either<String, List<Kline>>> indexPriceKlineCandlestickData({
  1. required String pair,
  2. required String interval,
  3. String? startTime,
  4. String? endTime,
  5. String? limit,
})

Kline/candlestick bars for the index price of a pair.

Klines are uniquely identified by their open time.

Implementation

Future<Either<String, List<Kline>>> indexPriceKlineCandlestickData({
  required String pair,
  required String interval,
  String? startTime,
  String? endTime,
  String? limit,
}) {
  Map<String, String> params = {
    'pair': pair,
    'interval': interval,
  };
  if (startTime != null) params['startTime'] = startTime;
  if (endTime != null) params['endTime'] = endTime;
  if (limit != null) params['limit'] = limit;
  return sendRequest(
    path: 'fapi/v1/indexPriceKlines',
    type: RequestType.GET,
    params: params,
  ).then((r) => r.isLeft
      ? Left(r.left)
      : Right(List<Kline>.from(r.right.map((e) => Kline.fromList(e)))));
}