public override void pollTicks(object source, ElapsedEventArgs e) { lock (_pollTicksLock) { foreach (CProduct product in dctExchangeProducts.Values) { try { if (product.Symbol.Length > 4) { ExchangeTicker ticker = api.GetTicker(product.Symbol); product.Bid = ticker.Bid; product.Ask = ticker.Ask; product.Last = ticker.Last; Decimal last; Decimal.TryParse(ticker.Last.ToString(), out last); product.SetLast(last); product.Volume = ticker.Volume.QuantityAmount; product.TimeStampLastTick = ticker.Volume.Timestamp; foreach (CStrategy strategy in product.colStrategy) { strategy.updateGUI(); } } } catch (Exception ex) { server.AddLog(ex.Message); } } } }
void GetTickers() { //lock (subscribed) { Debug.Print("getTickers: " + api.Name); foreach (var item in subscribed.ToArray <KeyValuePair <string, Market> >()) { try { Debug.Write("\t " + item.Key); //Task<ExchangeTicker> ticker = api.GetTickerAsync(item.Key); //ticker.Wait(); var ticker = api.GetTicker(item.Key); item.Value.Bid.price = (double)(ticker.Bid / div); item.Value.Ask.price = (double)(ticker.Ask / div); Debug.Print(" " + item.Value.Bid.price + " / " + item.Value.Ask.price); } catch (Exception ex) { Debug.Print(item.Key + " ---> " + ex.Message); } } } }
public static string GetPrice(string symbol, ExchangeAPI exchangeAPI) { var ticker = exchangeAPI.GetTicker(exchangeAPI.NormalizeSymbol(symbol)); return(ticker.Last.ToString()); }