public void UpdateQuotes() { Ticker sourceTicker = mtGoxExchangeAPI.GetTicker(Currency.USD); var tick = new TickDataModel(); tick.SourceExchange = sourceExchange; tick.High = Sanitize(sourceTicker.High); tick.Low = Sanitize(sourceTicker.Low); tick.Average = Sanitize(sourceTicker.Average); //tick.Volume = Sanitize(sourceTicker.Volume ); tick.Last = Sanitize(sourceTicker.Last); tick.Bid = Sanitize(sourceTicker.Bid); tick.Ask = Sanitize(sourceTicker.Ask); dataStore.Save(tick); lastQuote = tick; Thread.Sleep(1000); return; }
private void btnManualRequestPriceHTTP_Click(object sender, EventArgs e) { Ticker ticker = exchangeConnection.GetTicker(Currency.USD); // current ticker try { Decimal decBid = Convert.ToDecimal(ticker.Bid.Substring(1, ticker.Bid.Length - 1)); Decimal decAsk = Convert.ToDecimal(ticker.Ask.Substring(1, ticker.Ask.Length - 1)); Decimal decPrice = (decBid + decAsk) / 2; RecordPrice(decBid, decAsk, decPrice, ticker.TimeStamp.ToString()); int cPrices = Convert.ToInt16(lblPriceCountHTTP.Text.Length == 0 ? "0" : lblPriceCountHTTP.Text); ++cPrices; lblPriceCountHTTP.Invoke((Action)(() => { lblPriceCountHTTP.Text = cPrices.ToString(); })); lblLastResultPriceHTTP.Invoke((Action)(() => { lblLastResultPriceHTTP.Text = System.DateTime.Now.ToString("M/dd/yyyy hh:mm:ss tt"); })); lblLastPriceHTTP.Invoke((Action)(() => { lblLastPriceHTTP.Text = ticker.Last.ToString(); })); m_decLastPrice = Convert.ToDecimal(ticker.Last.Substring(1, ticker.Last.Length - 1)); } catch (Exception ex) { Logger.Logger.LogException(ex); } }