getHistoricalData method
Fetches historical OHLCV bars for the specified symbol and timeframe.
Optionally pass before to fetch candles older than that timestamp (for pagination).
Implementation
@override
Future<List<Candle>> getHistoricalData({
required String symbol,
required Timeframe timeframe,
int count = 500,
DateTime? before,
}) async {
if (_candles.isEmpty) return [];
final eligible = before != null
? _candles.where((c) => c.timestamp.isBefore(before)).toList()
: _candles;
if (eligible.isEmpty) return [];
if (eligible.length <= count) {
return List.unmodifiable(eligible);
}
return List.unmodifiable(eligible.sublist(eligible.length - count));
}