portfolioMetrics method

  1. @override
Future<PortfolioMetric> portfolioMetrics(
  1. Portfolio portfolio, {
  2. String currency = 'EUR',
})
override

The portfolioMetrics method is used to get the portfolio metrics for a given portfolio.

The portfolio argument is used to specify the portfolio.

// Get portfolio metrics for portfolio
final client = BavestRestClient(api_key);
final portfolioMetrics = client.portfolioMetrics(portfolio);

Implementation

@override
Future<PortfolioMetric> portfolioMetrics(Portfolio portfolio,
    {String currency = 'EUR'}) async {
  const url = '$_baseUrl/portfolio/metrics';
  final params = portfolio.toJson()..addAll({'currency': currency});

  final response = await _post(url, params);
  if (_isSuccess(response)) {
    return PortfolioMetric.fromJson(jsonDecode(response!.data));
  }

  throw Exception("could not receive portfolio metrics for $portfolio");
}