Exemple #1
0
        /// <summary>
        /// Update the connection status label with current prices
        /// </summary>
        private void UpdateTicker(string currency, MarketDataEvent e)
        {
            var ticker = Symbols
                         .Aggregate(new StringBuilder(), (sb, s) => sb.Append(String.Format("{0}: {1}  ", s.ToUpper(), s == currency ? e.Price : LastTrades[s]?.Price)), sb => sb.ToString());

            connectionStatusLabel.Text = String.Format("Connected: {0}   {1}", GeminiClient.Wallet.Key(), ticker);

            if (currency == null)
            {
                tbBtcUsdPrice.Text = LastTrades["btcusd"]?.Price.ToString();
                tbEthUsdPrice.Text = LastTrades["ethusd"]?.Price.ToString();
                tbEthBtcPrice.Text = LastTrades["ethbtc"]?.Price.ToString();
            }
            else if (currency == "btcusd")
            {
                tbBtcUsdPrice.Text = price_str(currency, e);
                if (e.Price - LastTrades[currency].Price > 0)
                {
                    tbBtcUsdPrice.ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    tbBtcUsdPrice.ForeColor = System.Drawing.Color.Red;
                }
            }
            else if (currency == "ethbtc")
            {
                tbEthBtcPrice.Text = price_str(currency, e);
                if (e.Price - LastTrades[currency].Price > 0)
                {
                    tbEthBtcPrice.ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    tbEthBtcPrice.ForeColor = System.Drawing.Color.Red;
                }
            }
            else if (currency == "ethusd")
            {
                tbEthUsdPrice.Text = price_str(currency, e);
                if (e.Price - LastTrades[currency].Price > 0)
                {
                    tbEthUsdPrice.ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    tbEthUsdPrice.ForeColor = System.Drawing.Color.Red;
                }
            }

            tbBtcUsdVwap.Text = V["btcusd"] != 0 ? Math.Round(PV["btcusd"] / V["btcusd"], 2).ToString() : "Calculating";
            tbEthUsdVwap.Text = V["ethusd"] != 0 ? Math.Round(PV["ethusd"] / V["ethusd"], 2).ToString() : "Calculating";
            tbEthBtcVwap.Text = V["ethbtc"] != 0 ? Math.Round(PV["ethbtc"] / V["ethbtc"], 4).ToString() : "Calculating";
        }
Exemple #2
0
        public void ReplaceWith(SpanBuilder builder)
        {
            Debug.Assert(!builder.Symbols.Any() || builder.Symbols.All(s => s != null));

            Kind          = builder.Kind;
            Symbols       = builder.Symbols;
            EditHandler   = builder.EditHandler;
            CodeGenerator = builder.CodeGenerator ?? SpanCodeGenerator.Null;
            _start        = builder.Start;

            // Since we took references to the values in SpanBuilder, clear its references out
            builder.Reset();

            // Calculate other properties
            Content = Symbols.Aggregate(new StringBuilder(), (sb, sym) => sb.Append(sym.Content), sb => sb.ToString());
        }