Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ class BinanceProvider implements IBinanceProvider {

final response = await http.get(uri);
if (response.statusCode == 200) {
return CoinOhlc.fromJson(jsonDecode(response.body) as List<dynamic>);
return CoinOhlc.fromJson(
jsonDecode(response.body) as List<dynamic>,
source: OhlcSource.binance,
);
} else {
throw Exception(
'Failed to load klines for \'$symbol\': '
"Failed to load klines for '$symbol': "
'${response.statusCode} ${response.body}',
);
}
Expand Down Expand Up @@ -113,7 +116,7 @@ class BinanceProvider implements IBinanceProvider {
);
} else {
throw Exception(
'Failed to load 24hr ticker for \'$symbol\': '
"Failed to load 24hr ticker for '$symbol': "
'${response.statusCode} ${response.body}',
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class BinanceRepository implements CexRepository {
endAt: endAt,
limit: 1,
);
return Decimal.parse(ohlcData.ohlc.first.close.toString());
return ohlcData.ohlc.first.closeDecimal;
}

@override
Expand Down Expand Up @@ -206,10 +206,12 @@ class BinanceRepository implements CexRepository {
map,
ohlc,
) {
final date = DateTime.fromMillisecondsSinceEpoch(ohlc.closeTime);
map[DateTime(date.year, date.month, date.day)] = Decimal.parse(
ohlc.close.toString(),
final dateUtc = DateTime.fromMillisecondsSinceEpoch(
ohlc.closeTimeMs,
isUtc: true,
);
map[DateTime.utc(dateUtc.year, dateUtc.month, dateUtc.day)] =
ohlc.closeDecimal;
return map;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ class CoinGeckoCexProvider implements ICoinGeckoProvider {
return http.get(uri).then((http.Response response) {
if (response.statusCode == 200) {
final data = jsonDecode(response.body) as List<dynamic>;
return CoinOhlc.fromJson(data);
return CoinOhlc.fromJson(data, source: OhlcSource.coingecko);
} else {
throw Exception(
'Failed to load coin ohlc data: ${response.statusCode} ${response.body}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,12 @@ class CoinGeckoRepository implements CexRepository {
map,
ohlc,
) {
final date = DateTime.fromMillisecondsSinceEpoch(ohlc.closeTime);
map[DateTime(date.year, date.month, date.day)] = Decimal.parse(
ohlc.close.toString(),
final dateUtc = DateTime.fromMillisecondsSinceEpoch(
ohlc.closeTimeMs,
isUtc: true,
);
map[DateTime.utc(dateUtc.year, dateUtc.month, dateUtc.day)] =
ohlc.closeDecimal;
return map;
});

Expand Down
Loading
Loading