sentiment method
The sentiment method is used to get the sentiment for a given stock symbol.
The id
argument is used to specify the stock id.
// Get sentiment for Apple
final client = BavestRestClient(api_key);
final sentiment = client.sentiment(SecurityIdentifier(symbol: "AAPL"));
Implementation
@override
Future<Sentiment> sentiment(SecurityIdentifier id) async {
const url = '$_baseUrl/sentiment';
final params = id.toJson();
var response = await _post(url, params);
if (_isSuccess(response)) {
return Sentiment.fromJson(jsonDecode(response!.data));
}
throw Exception("could not receive esg data for $id");
}