internal static PriceTicker ToPriceTicker(Binance.WsCandlestick ticker) { return(new PriceTicker() { Symbol = ticker.symbol, LastPrice = ticker.kline.closePrice, PriceChangePercent = (100m * ticker.kline.closePrice / ticker.kline.openPrice) - 100m, Volume = ticker.kline.quoteVolume, BuyVolume = ticker.kline.takerBuyQuoteVolume }); }
private void OnCandleHandler(Binance.WsCandlestick x) { if (x.kline.interval == "1m") { PriceChanges += 1; var mins = (int)(DateTime.Now - PriceChangesTrackingStartTime).TotalSeconds; PriceChangesPerMinute = PriceChanges / (1 + mins); UpdateStatus($"{x.symbol}: {x.kline.closePrice}; {PriceChangesPerMinute}/sec", 3); } else if (x.kline.interval == "1h" && x.kline.isFinal > 0) { PriceChanges = 0; PriceChangesPerMinute = 0; PriceChangesTrackingStartTime = DateTime.Now; } }
void Update(Binance.WsCandlestick ticker) { TreeIter iter; var result = store.GetIterFirst(out iter); while (result) { var bot = store.GetValue(iter, 0) as MonitoringBot; if (bot.Symbol == ticker.symbol) { bot.UpdateLastPrice(ticker.kline.closePrice, ticker.kline.lowPrice); store.SetValue(iter, 0, bot); // Force UI to refresh it. return; } result = store.IterNext(ref iter); } }
private void OnKline(Binance.WsCandlestick candlestick) { /*var ticker = GetPriceTicker(candlestick.symbol); * if (ticker != null) * { * var candle = Convert(candlestick); * switch (candlestick.kline.interval) * { * case "1m": * ticker.Candle1m = candle; * break; * case "5m": * ticker.Candle5m = candle; * AnalyzeCandle(ticker.Candle5m, 1.04m, "5m"); * break; * case "15m": * ticker.Candle15m = candle; * AnalyzeCandle(ticker.Candle15m, 1.08m, "15m"); * break; * case "30m": * ticker.Candle30m = candle; * AnalyzeCandle(ticker.Candle30m, 1.10m, "30m"); * break; * case "1h": * ticker.Candle1h = candle; * AnalyzeCandle(ticker.Candle1h, 1.12m, "1h"); * break; * case "6h": * ticker.Candle6h = candle; * break; * case "12h": * ticker.Candle12h = candle; * break; * case "1d": * ticker.Candle1d = candle; * break; * case "3d": * ticker.Candle3d = candle; * break; * case "1w": * ticker.Candle1w = candle; * break; * } * }*/ }
/*public PriceTicker ToPriceTicker(Binance.WsCandlestick ticker) * { * return new PriceTicker() * { * Symbol = ticker.symbol, * LastPrice = ticker.kline.closePrice, * PriceChangePercent = (100m * ticker.kline.closePrice / ticker.kline.openPrice) - 100m, * Volume = ticker.kline.quoteVolume, * BuyVolume = ticker.kline.takerBuyQuoteVolume * }; * }*/ public Candle Convert(Binance.WsCandlestick candlestick) { var kline = candlestick.kline; return(new Candle() { Open = kline.openPrice, High = kline.highPrice, Low = kline.lowPrice, Close = kline.closePrice, QuoteVolume = kline.quoteVolume, BuyQuoteVolume = kline.takerBuyQuoteVolume, Volume = kline.volume, BuyVolume = kline.takerBuyVolume, Symbol = candlestick.symbol, Interval = candlestick.kline.interval, OpenTime = kline.openTime.FromUnixTimestamp(), CloseTime = kline.closeTime.FromUnixTimestamp() }); }
private void OnKline(Binance.WsCandlestick candle) { //lblPrice.Content = candle.kline.closePrice; //lblVolume.Content = candle.kline.quoteVolume; }