public override DateTime GetHuobiTime() { Ticker ticker = BtceApi.GetTicker(BtcePair.btc_usd); return(UnixTime.ConvertToDateTime(ticker.ServerTime)); }
public static Dictionary <BtcePair, Ticker> GetTicker(BtcePair[] pairlist) { return(MakeRequest("ticker", pairlist, x => Ticker.ReadFromJObject(x as JObject), null, true)); }
public static Ticker GetTicker(BtcePair pair) { string queryStr = string.Format("https://btc-e.com/api/2/{0}/ticker", BtcePairHelper.ToString(pair)); return(Ticker.ReadFromJObject(JObject.Parse(WebApi.Query(queryStr))["ticker"] as JObject)); }
private void UpdatePrices() { _pair = currencyComboBox.SelectedItem.ToString(); _ticker = _control.UpdatePrices(_pair); decimal oldTradePrice; decimal.TryParse(buyPriceLabel.Text, NumberStyles.Any, _culture, out oldTradePrice); buyPriceLabel.Text = _ticker.Buy.ToString(_culture); if (oldTradePrice!=0) UpdateArrow(oldTradePrice, _ticker.Buy, buyArrowPictureBox); decimal.TryParse(sellPriceLabel.Text, NumberStyles.Any, _culture, out oldTradePrice); sellPriceLabel.Text = _ticker.Sell.ToString(_culture); if (oldTradePrice != 0) UpdateArrow(oldTradePrice, _ticker.Sell, sellArrowPictureBox); UpdateDynamicStick(); depthLabel.Text = _ticker.VolumeCurrent.ToString(_culture); highpriceLabel.Text = _ticker.High.ToString(_culture); avgpriceLabel.Text = _ticker.Average.ToString(_culture); lowpriceLabel.Text = _ticker.Low.ToString(_culture); }
public static Ticker ReadFromJObject(JObject o) { if (o == null) return null; var r = new Ticker { Average = o.Value<decimal>("avg"), Buy = o.Value<decimal>("buy"), High = o.Value<decimal>("high"), Last = o.Value<decimal>("last"), Low = o.Value<decimal>("low"), Sell = o.Value<decimal>("sell"), Volume = o.Value<decimal>("vol"), VolumeCurrent = o.Value<decimal>("vol_cur"), ServerTime = o.Value<UInt32>("server_time"), }; return r; }
private void Update(bool enabled, double period) { lock (this) { // Fetch live data from internet if (enabled) { if (realtimeCandles.Count == 0) { UpdateStatus("Loading last 24 hours candles"); try { IList<OHLC> candles = GetCandlesFromBitcoincharts(DateTime.Now.Subtract(new TimeSpan(24, 0, 0)), period); if (candles.Count == 0) candles = ReadCandlesFromCSV(string.Format("realtime{0}.csv", pair.ToString()), DateTime.Now.Subtract(new TimeSpan(24, 0, 0))); foreach (var candle in candles) realtimeCandles.Add(candle); } catch (Exception) { UpdateStatus("Failed to get last 24 hours candles from Bitcoincharts"); Thread.Sleep(1000); } } // First load history if (realtimeCandles.Count > 0) { UpdateStatus("Fetching new data from BTC-e"); GetCandlesFromBtce(period); SaveCandlesToCSV(realtimeCandles, string.Format("realtime{0}.csv", pair.ToString())); } } try { if (pair != BtcePair.Unknown) { //UpdateStatus("Updating BTC-e ticker and fees"); if (fee == 0m) fee = BtceApi.GetFee(pair); ticker = BtceApi.GetTicker(pair); } if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(secret)) { //UpdateStatus("Updating account informations"); BtceApi btceApi = new BtceApi(key, secret); info = btceApi.GetInfo(); } UpdateStatus("Ready..."); } catch (Exception ex) { UpdateStatus(string.Format("Error during Update: {0}", ex.Message)); } //Depth btcusdDepth = BtceApi.GetDepth(BtcePair.btc_eur); //var transHistory = btceApi.GetTransHistory(); //var tradeHistory = btceApi.GetTradeHistory(count: 20); //var orderList = btceApi.GetOrderList(); //var tradeAnswer = btceApi.Trade(BtcePair.btc_eur, TradeType.Sell, 20, 0.1m); //var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId); } }