Beispiel #1
0
        public async Task <CallResult <List <Candle> > > GetCandlesAsync(string symbol, FinnHubTimeResolutions resolution, DateTime from, DateTime to, bool adjusted = false, CancellationToken ct = default)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add(nameof(symbol), symbol);
            parameters.Add(nameof(resolution), JsonConvert.SerializeObject(resolution, new FinnHubTimeResolutionConverter(false)));
            parameters.Add(nameof(from), JsonConvert.SerializeObject(from, new TimestampSecondsConverter()));
            parameters.Add(nameof(to), JsonConvert.SerializeObject(to, new TimestampSecondsConverter()));
            parameters.Add(nameof(adjusted), adjusted);
            var result = await Get <CandlesResult>(parameters, CandlesEndpoint, ct);

            return(new CallResult <List <Candle> >(result.Data?.ToCandlesList(), result.Error));
        }
Beispiel #2
0
 public CallResult <List <Candle> > GetCandles(string symbol, FinnHubTimeResolutions resolution, DateTime from, DateTime to, bool adjusted = false) => GetCandlesAsync(symbol, resolution, from, to, adjusted).Result;