public IDisposable TestWebsocketsBittrex(bool display = false) { // create a web socket connection to the exchange. Note you can Dispose the socket anytime to shut it down. // the web socket will handle disconnects and attempt to re-connect automatically. IExchangeAPI a = new ExchangeBittrexAPI(); /*using (var socket = b.GetTickersWebSocket((tickers) => * { * Console.WriteLine("{0} tickers, first: {1}", tickers.Count, tickers.First()); * })) * { * Console.WriteLine("Press ENTER to shutdown."); * Console.ReadLine(); * }*/ var socket = a.GetTickersWebSocket((tickers) => { if (display) { Console.WriteLine("BITTREX {0,4} tickers, first: {1}", tickers.Count, tickers.First()); } //HandleTickerUpdate(a, tickers); m_outputQ.Enqueue(new TickerOutput("BITTREX", tickers)); }); return(socket); }
private void button1_Click(object sender, EventArgs e) { repoCatalogMarket.DeleteAllItems(); JToken result = new ExchangeBittrexAPI().GetSymbolsWithAllField(); JArray array = result as JArray; foreach (JToken trade in array) { CatalogMarket cm = new CatalogMarket(); cm.Active = true; cm.Code = trade["MarketName"].ToString(); cm.ExchangeId = new ObjectId("5a5a76f667d6713bb4a10d69"); cm.Exchange = catalogExchange.Where(p => p.Id == cm.ExchangeId).SingleOrDefault(); cm.FirstCode = trade["BaseCurrency"].ToString(); cm.SecondCode = trade["MarketCurrency"].ToString(); cm.LogoUrl = trade["LogoUrl"].ToString(); cm.Name = trade["MarketCurrencyLong"].ToString(); cm.RunCount = 0; cm.CreatedAt = DateTime.Now; repoCatalogMarket.Insert(cm); } catalogMarket = repoCatalogMarket.GetAllList(); }
public CoinInfoService( ExchangeBittrexAPI bittrexApi, ExchangeBinanceAPI binanceApi, ExchangeHitbtcAPI hitbtcApi, ExchangeKucoinAPI kucoinApi, ExchangeCryptopiaAPI cryptopiaApi, MinExchangeOkexAPI okexApi, MinExchangeUpbitAPI upbitApi, MinExchangeHoubiAPI huobiApi, MinExchangeGateAPI gateApi, IMemoryCache memoryCache, IOptions <SiteSettings> options, IOptions <ExchangerEnableSettings> enableOptions) { this.binanceApi = binanceApi; this.bittrexApi = bittrexApi; this.hitbtcApi = hitbtcApi; this.kucoinApi = kucoinApi; this.cryptopiaApi = cryptopiaApi; this.memoryCache = memoryCache; this.okexApi = okexApi; this.options = options; this.gateApi = gateApi; this.huobiApi = huobiApi; this.upbitApi = upbitApi; this.enableOptions = enableOptions; }
public BittrexConnector() { api = new ExchangeBittrexAPI(); var symbols = api.GetSymbols(); Debug.Print("{0}: ", api.Name); foreach (var s in symbols) { // Debug.Print("\t{0}", s); } base.Register(this); }
public void TestWebsocketsBittrex() { // create a web socket connection to the exchange. Note you can Dispose the socket anytime to shut it down. // the web socket will handle disconnects and attempt to re-connect automatically. IExchangeAPI b = new ExchangeBittrexAPI(); using (var socket = b.GetTickersWebSocket((tickers) => { Console.WriteLine("{0} tickers, first: {1}", tickers.Count, tickers.First()); })) { Console.WriteLine("Press ENTER to shutdown."); Console.ReadLine(); } }
private static void RunBittrexWebSocket() { var bittrex = new ExchangeBittrexAPI(); IDisposable bitSocket = bittrex.GetTickersWebSocket(freshTickers => { foreach (KeyValuePair <string, ExchangeTicker> kvp in freshTickers) { Console.WriteLine($"market {kvp.Key}, ticker {kvp.Value}"); } }); Console.WriteLine("Press any key to quit."); Console.ReadKey(); bitSocket.Dispose(); }
private void TimerMarketData_Tick(object sender, EventArgs e) { timerMarketData.Interval = (int)numericUpDown1.Value * 1000; try { catalogMarket = repoCatalogMarket.GetAllList(); if (isBusyMarketData == false) { DateTime start = DateTime.UtcNow; DateTime lastPreviousDate = start.AddMinutes(-previousMinute); try { isBusyMarketData = true; ExchangeBittrexAPI api = new ExchangeBittrexAPI(); CatalogMarket market; DateTime now = DateTime.UtcNow; DateTime previousDate = now.AddMinutes(-previousMinute); var tickers = api.GetTickers(); foreach (var ticker in tickers) { market = catalogMarket.Where(p => p.Code == ticker.Key).SingleOrDefault(); if (market != null) { //if (market.HistoricalData == null) // market.HistoricalData = new List<ExchangeTicker>(); //List<ExchangeTicker> data = market.HistoricalData.Where(q => q.Volume.Timestamp > lastPreviousDate).ToList(); //market.HistoricalData.Clear(); //market.HistoricalData.AddRange(data); //market.HistoricalData.Add(ticker.Value); try { //var update = Builders<CatalogMarket>.Update // .Set("ticker", ticker.Value) // .Set("historicalData", market.HistoricalData) // .Set("updatedAt", DateTime.Now) // .Inc("runCount", 1); var update = Builders <CatalogMarket> .Update .Set("active", true) .Set("ticker", ticker.Value) .Set("updatedAt", DateTime.Now) .Inc("runCount", 1); repoCatalogMarket.UpdateItem(market.Id, update); } catch (Exception ex) { throw new ArgumentException(market.Code + " : " + ex.Message); } } else { addLog(string.Format("Market not found: {0}", ticker.Key)); } } isBusyMarketData = false; DateTime completed = DateTime.UtcNow; addLog(string.Format("Market data OK. Duration: {0:0.00}", completed.Subtract(start).TotalSeconds)); } catch (Exception ex) { throw new ArgumentException(ex.Message); } } else { addLog("Market data BUSY"); } } catch (Exception ex) { isBusyMarketData = false; addLog("Market data ERROR : " + ex.Message); } }