portfolioChart method
Future<Candles>
portfolioChart(
- Portfolio portfolio, {
- String currency = "EUR",
- required int from,
- required int to,
- required CandleResolution resolution,
override
The portfolioChart method is used to get the portfolio chart for a given portfolio.
The portfolio
argument is used to specify the portfolio.
// Get portfolio chart for portfolio
final client = BavestRestClient(api_key);
final portfolioChart = client.portfolioChart(portfolio, from: 1630352898, to: 1655848800, resolution: CandleType.day);
Implementation
@override
Future<Candles> portfolioChart(Portfolio portfolio,
{String currency = "EUR",
required int from,
required int to,
required CandleResolution resolution}) async {
const url = '$_baseUrl/portfolio/chart';
var params = portfolio.toJson()
..addAll({
"currency": currency,
"from": from,
"to": to,
"resolution": resolution.str,
});
var response = await _post(url, params);
if (_isSuccess(response)) {
var parsedJson = json.decode(response!.data);
return Candles.fromJson(parsedJson);
}
throw Exception("could not receive portfolio chart for $portfolio");
}