quote method

  1. @override
Future<Quote> quote(
  1. SecurityIdentifier id, {
  2. String? currency,
})
override

The quote method is used to get the quote for a given stock symbol. By default, the quote is returned in EUR. You can specify a different currency by passing the currency argument.

It returns a Quote object.

// Get quote for Apple in EUR
final client = BavestRestClient(api_key);
client.quote(SecurityIdentifier(symbol: "AAPL"));

Implementation

@override
Future<Quote> quote(SecurityIdentifier id, {String? currency}) async {
  const url = '$_baseUrl/quote';
  final params = id.toJson();

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

  throw Exception('Failed to get quote for $id');
}