private void InitExchanges() { // We need to be careful to only add exchanges which OnGetTickers implementation make only 1 request Providers.Add("binance", new ExchangeSharpRateProvider("binance", new ExchangeBinanceAPI(), true)); Providers.Add("bittrex", new ExchangeSharpRateProvider("bittrex", new ExchangeBittrexAPI(), true)); Providers.Add("poloniex", new ExchangeSharpRateProvider("poloniex", new ExchangePoloniexAPI(), true)); Providers.Add("hitbtc", new ExchangeSharpRateProvider("hitbtc", new ExchangeHitbtcAPI(), false)); Providers.Add("cryptopia", new ExchangeSharpRateProvider("cryptopia", new ExchangeCryptopiaAPI(), false)); // Handmade providers Providers.Add("bitpay", new BitpayRateProvider(new NBitpayClient.Bitpay(new NBitcoin.Key(), new Uri("https://bitpay.com/")))); Providers.Add(QuadrigacxRateProvider.QuadrigacxName, new QuadrigacxRateProvider()); Providers.Add(CoinAverageRateProvider.CoinAverageName, new CoinAverageRateProvider() { Exchange = CoinAverageRateProvider.CoinAverageName, HttpClient = _httpClientFactory?.CreateClient(), Authenticator = _CoinAverageSettings }); Providers.Add("kraken", new KrakenExchangeRateProvider() { HttpClient = _httpClientFactory?.CreateClient() }); // Those exchanges make multiple requests when calling GetTickers so we remove them //DirectProviders.Add("gdax", new ExchangeSharpRateProvider("gdax", new ExchangeGdaxAPI())); //DirectProviders.Add("gemini", new ExchangeSharpRateProvider("gemini", new ExchangeGeminiAPI())); //DirectProviders.Add("bitfinex", new ExchangeSharpRateProvider("bitfinex", new ExchangeBitfinexAPI())); //DirectProviders.Add("okex", new ExchangeSharpRateProvider("okex", new ExchangeOkexAPI())); //DirectProviders.Add("bitstamp", new ExchangeSharpRateProvider("bitstamp", new ExchangeBitstampAPI())); foreach (var provider in Providers.ToArray()) { var prov = new BackgroundFetcherRateProvider(Providers[provider.Key]); prov.RefreshRate = provider.Key == CoinAverageRateProvider.CoinAverageName ? CacheSpan : TimeSpan.FromMinutes(1.0); Providers[provider.Key] = prov; } var cache = new MemoryCache(_CacheOptions); foreach (var supportedExchange in GetSupportedExchanges()) { if (!Providers.ContainsKey(supportedExchange.Key)) { var coinAverage = new CoinAverageRateProvider() { Exchange = supportedExchange.Key, HttpClient = _httpClientFactory?.CreateClient(), Authenticator = _CoinAverageSettings }; var cached = new CachedRateProvider(supportedExchange.Key, coinAverage, cache) { CacheSpan = CacheSpan }; Providers.Add(supportedExchange.Key, cached); } } }
private void InitExchanges() { // We need to be careful to only add exchanges which OnGetTickers implementation make only 1 request Providers.Add("binance", new ExchangeSharpRateProvider("binance", new ExchangeBinanceAPI(), true)); Providers.Add("bittrex", new ExchangeSharpRateProvider("bittrex", new ExchangeBittrexAPI(), true)); Providers.Add("poloniex", new ExchangeSharpRateProvider("poloniex", new ExchangePoloniexAPI(), true)); Providers.Add("hitbtc", new ExchangeSharpRateProvider("hitbtc", new ExchangeHitbtcAPI(), false)); // Cryptopia is often not available // Disabled because of https://twitter.com/Cryptopia_NZ/status/1085084168852291586 // Providers.Add("cryptopia", new ExchangeSharpRateProvider("cryptopia", new ExchangeCryptopiaAPI(), false)); // Handmade providers Providers.Add(QuadrigacxRateProvider.QuadrigacxName, new QuadrigacxRateProvider()); Providers.Add(CoinAverageRateProvider.CoinAverageName, new CoinAverageRateProvider() { Exchange = CoinAverageRateProvider.CoinAverageName, HttpClient = _httpClientFactory?.CreateClient("EXCHANGE_COINAVERAGE"), Authenticator = _CoinAverageSettings }); Providers.Add("kraken", new KrakenExchangeRateProvider() { HttpClient = _httpClientFactory?.CreateClient("EXCHANGE_KRAKEN") }); Providers.Add("bylls", new ByllsRateProvider(_httpClientFactory?.CreateClient("EXCHANGE_BYLLS"))); // Those exchanges make multiple requests when calling GetTickers so we remove them //DirectProviders.Add("gdax", new ExchangeSharpRateProvider("gdax", new ExchangeGdaxAPI())); //DirectProviders.Add("gemini", new ExchangeSharpRateProvider("gemini", new ExchangeGeminiAPI())); //DirectProviders.Add("bitfinex", new ExchangeSharpRateProvider("bitfinex", new ExchangeBitfinexAPI())); //DirectProviders.Add("okex", new ExchangeSharpRateProvider("okex", new ExchangeOkexAPI())); //DirectProviders.Add("bitstamp", new ExchangeSharpRateProvider("bitstamp", new ExchangeBitstampAPI())); foreach (var provider in Providers.ToArray()) { if (provider.Key == "cryptopia") // Shitty exchange, rate often unavailable, it spams the logs { continue; } var prov = new BackgroundFetcherRateProvider(Providers[provider.Key]); if (provider.Key == CoinAverageRateProvider.CoinAverageName) { prov.RefreshRate = CacheSpan; prov.ValidatyTime = CacheSpan + TimeSpan.FromMinutes(1.0); } else { prov.RefreshRate = TimeSpan.FromMinutes(1.0); prov.ValidatyTime = TimeSpan.FromMinutes(5.0); } Providers[provider.Key] = prov; } var cache = new MemoryCache(_CacheOptions); foreach (var supportedExchange in GetSupportedExchanges()) { if (!Providers.ContainsKey(supportedExchange.Key)) { var coinAverage = new CoinAverageRateProvider() { Exchange = supportedExchange.Key, HttpClient = _httpClientFactory?.CreateClient(), Authenticator = _CoinAverageSettings }; var cached = new CachedRateProvider(supportedExchange.Key, coinAverage, cache) { CacheSpan = CacheSpan }; Providers.Add(supportedExchange.Key, cached); } } }