portfolioAllocation method
The portfolioAllocation method is used to get the portfolio allocation for a given portfolio.
The portfolio
argument is used to specify the portfolio.
// Get portfolio allocation for portfolio
final client = BavestRestClient(api_key);
final portfolioAllocation = client.portfolioAllocation(portfolio);
Implementation
@override
Future<List<PortfolioAllocation>> portfolioAllocation(
Portfolio portfolio) async {
const url = '$_baseUrl/portfolio/allocation';
final params = portfolio.toJson();
var response = await _post(url, params);
if (_isSuccess(response)) {
List<dynamic> filteredResults = jsonDecode(response!.data);
return filteredResults
.map((e) => PortfolioAllocation.fromJson(e))
.toList();
}
throw Exception("could not receive portfolio allocation for $portfolio");
}