public async Task ThrowException_ForIntradayIntervals(Interval interval) { using var client = new AlphaVantageClient(_apiKey); using var cryptoClient = client.Crypto(); var fromCurrency = DigitalCurrency.BTC; var toCurrency = PhysicalCurrency.ILS; await Assert.ThrowsAsync <AlphaVantageException>(async() => { await cryptoClient.GetTimeSeriesAsync(fromCurrency, toCurrency, interval); }); }
public static async Task CryptoDemo() { // use your AlphaVantage API key string apiKey = "1"; // there are 5 more constructors available using var client = new AlphaVantageClient(apiKey); using var cryptoClient = client.Crypto(); CryptoTimeSeries cryptoTimeSeries = await cryptoClient.GetTimeSeriesAsync(DigitalCurrency.BTC, PhysicalCurrency.ILS, Interval.Weekly); CryptoRating cryptoRating = await cryptoClient.GetCryptoRatingAsync(DigitalCurrency.BTC); CryptoExchangeRate exchangeRate = await cryptoClient.GetExchangeRateAsync(DigitalCurrency.BTC, PhysicalCurrency.ILS); }
public async Task ReturnValidCryptoRating() { using var client = new AlphaVantageClient(_apiKey); using var forexClient = client.Crypto(); var currency = DigitalCurrency.BTC; var exchangeRate = await forexClient.GetCryptoRatingAsync(currency); exchangeRate.Should().NotBeNull() .And.Match <CryptoRating>(er => er.Symbol == currency && string.IsNullOrEmpty(er.Name) == false && er.Rating != default && er.FcasScore > 0 && er.DeveloperScore > 0 && er.MarketMaturityScore > 0 && er.UtilityScore > 0 && er.LastRefreshed != default && string.IsNullOrEmpty(er.TimeZone) == false ); }
public async Task ReturnExchangeRate() { using var client = new AlphaVantageClient(_apiKey); using var forexClient = client.Crypto(); var fromCurrency = DigitalCurrency.BTC; var toCurrency = PhysicalCurrency.ILS; var exchangeRate = await forexClient.GetExchangeRateAsync(fromCurrency, toCurrency); exchangeRate.Should().NotBeNull() .And.Match <CryptoExchangeRate>(er => er.FromCurrencyCode == fromCurrency && string.IsNullOrEmpty(er.FromCurrencyName) == false && er.ToCurrencyCode == toCurrency && string.IsNullOrEmpty(er.ToCurrencyName) == false && er.ExchangeRate != default && er.LastRefreshed != default && string.IsNullOrEmpty(er.TimeZone) == false && er.BidPrice != default && er.AskPrice != default ); }
public async Task ReturnValidNotIntradayTimeSeries(Interval interval) { using var client = new AlphaVantageClient(_apiKey); using var cryptoClient = client.Crypto(); var fromCurrency = DigitalCurrency.BTC; var toCurrency = PhysicalCurrency.ILS; var timeSeries = await cryptoClient.GetTimeSeriesAsync(fromCurrency, toCurrency, interval); timeSeries.Should().NotBeNull() .And.Match <CryptoTimeSeries>(ts => ts.Interval == interval && ts.FromCurrency == fromCurrency && ts.ToCurrency == toCurrency); timeSeries.MetaData.Should().NotBeNull() .And.HaveCountGreaterThan(1); timeSeries.DataPoints.Should().NotBeNull() .And.HaveCountGreaterThan(1) .And.NotContainNulls() .And.OnlyContain(dp => IsDataPointValid(dp)); }