compressedAggregateTradesList method

Future<Either<String, List<AggregatedTrade>>> compressedAggregateTradesList({
  1. required String symbol,
  2. String? fromId,
  3. String? startTime,
  4. String? endTime,
  5. String? limit,
})

Get compressed, aggregate trades.

Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.

Implementation

Future<Either<String, List<AggregatedTrade>>> compressedAggregateTradesList({
  required String symbol,
  String? fromId,
  String? startTime,
  String? endTime,
  String? limit,
}) {
  Map<String, String> params = {
    'symbol': symbol,
  };
  if (fromId != null) params['fromId'] = fromId;
  if (startTime != null) params['startTime'] = startTime;
  if (endTime != null) params['endTime'] = endTime;
  if (limit != null) params['limit'] = limit;
  return sendRequest(
    path: 'fapi/v1/aggTrades',
    type: RequestType.GET,
    params: params,
  ).then((r) => r.isLeft
      ? Left(r.left)
      : Right(List<AggregatedTrade>.from(
          r.right.map((e) => AggregatedTrade.fromMap(e)))));
}