public override bool GetTickersInfo() { string text = string.Empty; string address = "http://api.hitbtc.com/api/1/public/symbols"; try { text = GetDownloadString(address); } catch (Exception) { return(false); } Tickers.Clear(); Dictionary <string, object> res = null; lock (JsonParser) { res = (Dictionary <string, object>)JsonParser.Parse(text); } List <object> symbols = (List <object>)res["symbols"]; int index = 0; foreach (Dictionary <string, object> s in symbols) { HitBtcTicker t = new HitBtcTicker(); t.Index = index; index++; t.BaseCurrency = s["currency"].ToString(); t.MarketCurrency = s["commodity"].ToString(); t.Step = Convert.ToDecimal(s["step"]); Tickers.Add(t); } return(true); }
public PanelViewModel(string panel, string market) { _panel = panel; MainButtonAction = "Update Database"; BackgroundWorkerNotBusy = true; if (Tickers == null) { Tickers = new ObservableCollection <Ticker>(); } const string path = "Resources/Tickers.xml"; var serializer = new XmlSerializer(typeof(Tickers)); var reader = new StreamReader(path); var tickers = ((Tickers)serializer.Deserialize(reader)).Ticker; reader.Close(); foreach (var ticker in tickers.Where(x => x.Market == market && x.Sources.Count > 0)) { ticker.LastUpdate = "Not Available"; Tickers.Add(ticker); } if (!String.IsNullOrEmpty(Properties.Settings.Default[_panel + "Path"].ToString())) { MetastockFolder = Properties.Settings.Default[_panel + "Path"].ToString(); } }
protected void AddMarketSummary(PriceTicker ticker) { if (tickersMapping.TryAdd(ticker.Symbol, Tickers.Count)) { Tickers.Add(ticker); } }
public void GetTickersInfo() { string address = "https://poloniex.com/public?command=returnTicker"; string text = GetDownloadString(address); if (string.IsNullOrEmpty(text)) { return; } Tickers.Clear(); JObject res = (JObject)JsonConvert.DeserializeObject(text); int index = 0; foreach (JProperty prop in res.Children()) { PoloniexTicker t = new PoloniexTicker(); t.Index = index; t.CurrencyPair = prop.Name; JObject obj = (JObject)prop.Value; t.Id = obj.Value <int>("id"); t.Last = obj.Value <double>("last"); t.LowestAsk = obj.Value <double>("lowestAsk"); t.HighestBid = obj.Value <double>("highestBid"); t.Change = obj.Value <double>("percentChange"); t.BaseVolume = obj.Value <double>("baseVolume"); t.Volume = obj.Value <double>("quoteVolume"); t.IsFrozen = obj.Value <int>("isFrozen") != 0; t.Hr24High = obj.Value <double>("high24hr"); t.Hr24Low = obj.Value <double>("low24hr"); Tickers.Add(t); index++; } }
public override bool GetTickersInfo() { string address = "https://yobit.net/api/3/info"; string text = string.Empty; try { text = GetDownloadString(address); } catch (Exception) { return(false); } if (string.IsNullOrEmpty(text)) { return(false); } Tickers.Clear(); JObject res = (JObject)JsonConvert.DeserializeObject(text); int index = 0; res = res.Value <JObject>("pairs"); foreach (JProperty prop in res.Children()) { YobitTicker t = new YobitTicker(this); t.Index = index; t.CurrencyPair = prop.Name; JObject obj = (JObject)prop.Value; t.Fee = obj.Value <double>("fee"); t.IsFrozen = obj.Value <int>("hidden") == 1; Tickers.Add(t); index++; } IsInitialized = true; return(true); }
private void ProcessMessageTicker(ISerializedValue[] arguments) { var currencyPair = CurrencyPair.Parse(arguments[0].Deserialize <string>()); var priceLast = arguments[1].Deserialize <double>(); var orderTopSell = arguments[2].Deserialize <double>(); var orderTopBuy = arguments[3].Deserialize <double>(); var priceChangePercentage = arguments[4].Deserialize <double>(); var volume24HourBase = arguments[5].Deserialize <double>(); var volume24HourQuote = arguments[6].Deserialize <double>(); var isFrozenInternal = arguments[7].Deserialize <byte>(); var marketData = new MarketData { PriceLast = priceLast, OrderTopSell = orderTopSell, OrderTopBuy = orderTopBuy, PriceChangePercentage = priceChangePercentage, Volume24HourBase = volume24HourBase, Volume24HourQuote = volume24HourQuote, IsFrozenInternal = isFrozenInternal }; if (Tickers.ContainsKey(currencyPair)) { Tickers[currencyPair] = marketData; } else { Tickers.Add(currencyPair, marketData); } OnTickerChanged?.Invoke(this, new TickerChangedEventArgs(currencyPair, marketData)); }
/// <summary> /// add new ticker for an unadded coin /// </summary> private void AddNewTicker() { if (String.IsNullOrEmpty(NewCoin) || IsCoinValid(NewCoin) == false) { return; } Tickers.Add(new Ticker(NewCoin, 0, 0)); NewCoin = ""; }
protected virtual void UpdateTickersList() { Tickers.Clear(); for (int i = 0; i < StrategyInfo.Tickers.Count; i++) { Tickers.Add(StrategyInfo.Tickers[i].Ticker); } Ticker = Tickers.Count > 0 ? Tickers[0] : null; }
public override bool GetTickersInfo() { if (Tickers.Count > 0) { return(true); } string address = "https://api.bitfinex.com/v1/symbols"; byte[] bytes = null; try { bytes = GetDownloadBytes(address); } catch (Exception) { return(false); } if (bytes == null) { return(false); } string text = UTF8Encoding.Default.GetString(bytes); text = text.Replace('[', ' '); text = text.Replace(']', ' '); text = text.Replace('"', ' '); string[] tickers = text.Split(','); foreach (string item in tickers) { BitFinexTicker m = new BitFinexTicker(this); string currencyPair = item.Trim(); m.MarketCurrency = currencyPair.Substring(0, 3).ToUpper(); m.BaseCurrency = currencyPair.Substring(3, 3).ToUpper(); m.CurrencyPair = "t" + currencyPair.ToUpper(); m.MarketName = m.CurrencyPair; m.Index = Tickers.Count; Tickers.Add(m); } address = "https://api.bitfinex.com/v2/tickers?symbols="; foreach (BitFinexTicker ticker in Tickers) { address += ticker.CurrencyPair; if (Tickers.IndexOf(ticker) < Tickers.Count - 1) { address += ","; } } TickersUpdateAddress = address; IsInitialized = true; return(true); }
public override bool GetTickersInfo() { string address = "https://www.bitmex.com/api/v1/instrument?columns=typ,symbol,rootSymbol,quoteCurrency,highPrice,lowPrice,bidPrice,askPrice,lastChangePcnt,hasLiquidity,volume,tickSize,takerFee&start=0&count=500"; string text = string.Empty; try { text = GetDownloadString(address); if (string.IsNullOrEmpty(text)) { return(false); } Tickers.Clear(); JArray res = JsonConvert.DeserializeObject <JArray>(text); int index = 0; foreach (JObject obj in res.Children()) { if (!obj.Value <bool>("hasLiquidity")) { continue; } string pair = obj.Value <string>("symbol"); BitmexTicker t = (BitmexTicker)Tickers.FirstOrDefault(tt => tt.CurrencyPair == pair); if (t == null) { t = new BitmexTicker(this); } t.Index = index; t.ContractTicker = true; t.ContractValue = 1; // 1 USD t.CurrencyPair = pair; t.MarketCurrency = obj.Value <string>("rootSymbol"); t.BaseCurrency = obj.Value <string>("quoteCurrency"); t.TickSize = ToDouble(obj, "tickSize"); t.Last = ToDouble(obj, "lastPrice"); t.Hr24High = ToDouble(obj, "highPrice"); t.Hr24Low = ToDouble(obj, "lowPrice"); t.HighestBid = ToDouble(obj, "bidPrice"); t.LowestAsk = ToDouble(obj, "askPrice"); t.Timestamp = Convert.ToDateTime(obj.Value <string>("timestamp")); t.Change = ToDouble(obj, "lastChangePcnt"); t.Volume = ToDouble(obj, "volume24h"); t.Fee = ToDouble(obj, "takerFee") * 100; Tickers.Add(t); index++; } } catch (Exception) { return(false); } IsInitialized = true; return(true); }
public async Task <List <Ticker> > UpdateTickersAsync(List <Product> products) { string json = null; try { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.General, "Updating Update Tickers Information."); if (products == null || !products.Any()) { return(Tickers); } if (Tickers == null) { Tickers = new List <Ticker>(); } //Get price of all products foreach (Product product in products) { Request request = new Request(ConnectionAdapter.Authentication.EndpointUrl, "GET", $"/products/{product.ID}/ticker"); json = await ConnectionAdapter.RequestAsync(request); if (string.IsNullOrEmpty(json)) { return(Tickers); } Ticker ticker = JsonSerializer.Deserialize <Ticker>(json); Tickers?.RemoveAll(x => x.ProductID == product.ID); if (ticker == null) { continue; } ticker.ProductID = product.ID; Tickers.Add(ticker); } foreach (Ticker ticker in Tickers) { if (decimal.TryParse(ticker.Price, out decimal decimalPrice)) { CurrentPrices[ticker.ProductID] = decimalPrice; } } } catch (Exception e) { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.Error, $"Method: UpdateTickersAsync\r\nException Stack Trace: {e.StackTrace}\r\nJSON: {json}"); } return(Tickers); }
public override bool GetTickersInfo() { Context cc = GetContext(DefaultAccount); Tickers.Clear(); cc.MarketStocksAsync().ContinueWith(t => { MarketInstrumentList list = t.Result; foreach (MarketInstrument i in list.Instruments) { Tickers.Add(new Tinkoff.TinknoffInvestTicker(this, i)); } IsInitialized = true; }); return(true); }
protected void UpdateTickers() { Exchange ex = Exchange.Get(ExchangeType.Tinkoff); if (!ex.Connect()) { return; } if (!ex.IsInitialized) { ex.InitializedChanged += OnExchangeInitialized; return; } if (WebTickers == null) { return; } try { Tickers.Clear(); ex.Tickers.ForEach(t => { TickerExchangeWebInfo nyse = WebTickers.Tickers.FirstOrDefault(n => (n.Exchange == "NYSE" || n.Exchange == "NASDAQ") && n.Ticker == t.Name); if (nyse != null) { TickerExchangeWebInfo xetra = WebTickers.Tickers.FirstOrDefault(n => n.Exchange == "Xetra" && n.Ticker == t.Name); TinkoffGapScannerInfo info = new TinkoffGapScannerInfo(); info.NyseTicker = nyse; info.XetraTicker = xetra; info.TinkoffTicker = (TinknoffInvestTicker)t; Tickers.Add(info); info.Updated += TickerUpdated; } }); } catch (Exception) { } finally { BeginInvoke(new MethodInvoker(() => { this.gridControl1.DataSource = Tickers; this.gridControl1.RefreshDataSource(); })); } }
private void GetTickerItem(PoloniexTicker item) { lock (Tickers) { PoloniexTicker t = Tickers.FirstOrDefault((i) => i.CurrencyPair == item.CurrencyPair); if (t != null) { lock (t) { t.Assign(item); t.UpdateHistoryItem(); RaiseTickerUpdate(t); } } else { Tickers.Add(item); RaiseTickerUpdate(item); } } }
public override bool UpdateTickersInfo() { if (!IsInitialized) { return(true); } Context cc = GetContext(DefaultAccount); cc.MarketStocksAsync().ContinueWith(t => { MarketInstrumentList list = t.Result; foreach (MarketInstrument i in list.Instruments) { TinknoffInvestTicker ticker = (TinknoffInvestTicker)Tickers.FirstOrDefault(tt => tt.Name == i.Name); if (ticker != null) { ticker.Instrument = i; continue; } Tickers.Add(new Tinkoff.TinknoffInvestTicker(this, i)); } }); return(true); }
public override bool GetTickersInfo() { string text = string.Empty; string address = "https://api.exmo.me/v1/pair_settings"; try { text = GetDownloadString(address); } catch (Exception) { return(false); } if (string.IsNullOrEmpty(text)) { return(false); } Tickers.Clear(); Dictionary <string, object> res = null; lock (JsonParser) { res = (Dictionary <string, object>)JsonParser.Parse(text); } int index = 0; foreach (string s in res.Keys) { ExmoTicker t = new ExmoTicker(); t.Index = index; string[] curr = s.Split('_'); t.BaseCurrency = curr[1]; t.MarketCurrency = curr[0]; index++; Tickers.Add(t); } return(true); }
public override bool ObtainExchangeSettings() { string address = "https://api.binance.com/api/v1/exchangeInfo"; string text = string.Empty; try { text = GetDownloadString(address); } catch (Exception e) { Telemetry.Default.TrackException(e); return(false); } if (string.IsNullOrEmpty(text)) { return(false); } JObject settings = JsonConvert.DeserializeObject <JObject>(text); JArray rateLimits = settings.Value <JArray>("rateLimits"); RequestRate = new List <RateLimit>(); OrderRate = new List <RateLimit>(); for (int i = 0; i < rateLimits.Count; i++) { JObject rateLimit = (JObject)rateLimits[i]; string rateType = rateLimit.Value <string>("rateLimitType"); if (rateType == "REQUESTS") { RequestRate.Add(GetRateLimit(rateLimit)); } if (rateType == "ORDERS") { OrderRate.Add(GetRateLimit(rateLimit)); } } JArray symbols = settings.Value <JArray>("symbols"); for (int i = 0; i < symbols.Count; i++) { JObject s = (JObject)symbols[i]; BinanceTicker t = new BinanceTicker(this); t.CurrencyPair = s.Value <string>("symbol"); t.MarketCurrency = s.Value <string>("baseAsset"); t.BaseCurrency = s.Value <string>("quoteAsset"); if (Tickers.FirstOrDefault(tt => tt.CurrencyPair == t.CurrencyPair) != null) { continue; } Tickers.Add(t); JArray filters = s.Value <JArray>("filters"); for (int fi = 0; fi < filters.Count; fi++) { JObject filter = (JObject)filters[fi]; string filterType = filter.Value <string>("filterType"); if (filterType == "PRICE_FILTER") { t.PriceFilter = new TickerFilter() { MinValue = filter.Value <double>("minPrice"), MaxValue = filter.Value <double>("maxPrice"), TickSize = filter.Value <double>("tickSize") } } ; else if (filterType == "LOT_SIZE") { t.QuantityFilter = new TickerFilter() { MinValue = filter.Value <double>("minQty"), MaxValue = filter.Value <double>("maxQty"), TickSize = filter.Value <double>("stepSize") } } ; else if (filterType == "MIN_NOTIONAL") { t.NotionalFilter = new TickerFilter() { MinValue = filter.Value <double>("minNotional"), MaxValue = double.MaxValue } } ; } } return(true); }
public override void ObtainExchangeSettings() { string address = "https://api.binance.com/api/v1/exchangeInfo"; string text = string.Empty; try { text = GetDownloadString(address); } catch (Exception) { return; } if (string.IsNullOrEmpty(text)) { return; } JObject settings = JsonConvert.DeserializeObject <JObject>(text); JArray rateLimits = settings.Value <JArray>("rateLimits"); RequestRate = new List <RateLimit>(); OrderRate = new List <RateLimit>(); foreach (JObject rateLimit in rateLimits) { string rateType = rateLimit.Value <string>("rateLimitType"); if (rateType == "REQUESTS") { RequestRate.Add(GetRateLimit(rateLimit)); } if (rateType == "ORDERS") { OrderRate.Add(GetRateLimit(rateLimit)); } } JArray symbols = settings.Value <JArray>("symbols"); foreach (JObject s in symbols) { BinanceTicker t = new BinanceTicker(this); t.CurrencyPair = s.Value <string>("symbol"); t.MarketCurrency = s.Value <string>("baseAsset"); t.BaseCurrency = s.Value <string>("quoteAsset"); Tickers.Add(t); JArray filters = s.Value <JArray>("filters"); foreach (JObject filter in filters) { string filterType = filter.Value <string>("filterType"); if (filterType == "PRICE_FILTER") { t.PriceFilter = new TickerFilter() { MinValue = filter.Value <double>("minPrice"), MaxValue = filter.Value <double>("maxPrice"), TickSize = filter.Value <double>("tickSize") } } ; else if (filterType == "LOT_SIZE") { t.QuantityFilter = new TickerFilter() { MinValue = filter.Value <double>("minQty"), MaxValue = filter.Value <double>("maxQty"), TickSize = filter.Value <double>("stepSize") } } ; } } }
public override void Setup() { base.Setup(); Tickers.Add("", new Ticker()); }