Exemplo n.º 1
0
        private void OnOrderUpdate(BinanceStreamOrderUpdate data)
        {
            var symbol = AllPrices.SingleOrDefault(a => a.Symbol == data.Symbol);

            if (symbol == null)
            {
                return;
            }

            lock (orderLock)
            {
                var order = symbol.Orders.SingleOrDefault(o => o.Id == data.OrderId);
                if (order == null)
                {
                    if (data.RejectReason != OrderRejectReason.None || data.ExecutionType != ExecutionType.New)
                    {
                        // Order got rejected, no need to show
                        return;
                    }

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        symbol.AddOrder(new OrderViewModel()
                        {
                            ExecutedQuantity = data.AccumulatedQuantityOfFilledTrades,
                            Id = data.OrderId,
                            OriginalQuantity = data.Quantity,
                            Price            = data.Price,
                            Side             = data.Side,
                            Status           = data.Status,
                            Symbol           = data.Symbol,
                            Time             = data.Time,
                            Type             = data.Type
                        });
                    });
                }
                else
                {
                    order.ExecutedQuantity = data.AccumulatedQuantityOfFilledTrades;
                    order.Status           = data.Status;
                }
            }
        }
Exemplo n.º 2
0
        private void ChkAutoSell_OnChecked(object sender, RoutedEventArgs e)
        {
            var purchasePrice = Convert.ToInt32(cboMaxPrice.Text);
            var minProfitable = (purchasePrice * .05) + purchasePrice;
            var roundedUp     = (int)Math.Ceiling(minProfitable);
            var minSell       = AllPrices.First(price => price > roundedUp);
            var maxSell       = AllPrices.First(sellPrice => sellPrice > minSell);

            cboMinSell.ItemsSource = AllPrices.Where(x => x >= minSell).Take(100);
            cboMaxSell.ItemsSource = AllPrices.Where(x => x >= maxSell).Take(100);

            cboMinSell.SelectedItem = minSell;
            cboMaxSell.SelectedItem = maxSell;

            AutoSellMode          = true;
            cboMinSell.Visibility = Visibility.Visible;
            cboMaxSell.Visibility = Visibility.Visible;
            lblMinSell.Visibility = Visibility.Visible;
            lblMaxSell.Visibility = Visibility.Visible;
        }
Exemplo n.º 3
0
        public MainViewModel()
        {
            BinanceClient.SetDefaultOptions(new BinanceClientOptions()
            {
                ApiCredentials = new ApiCredentials("bMNcUXrq4ZzUpMTM3jrNVqNIihI0sAeK6Zytudd7qEhCfyHdUPtL2uDmZSmEQ7J5 ", "qkA8T5Q6lNcUSTAhwi9jYaEbZpxmpvfoD0xB9ZdwLEEEQhYEqim1cJBjv2m1dNma"),
                LogVerbosity   = LogVerbosity.Debug,
                LogWriters     = new List <TextWriter> {
                    Console.Out
                }
            });
            BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions()
            {
                ApiCredentials = new ApiCredentials("bMNcUXrq4ZzUpMTM3jrNVqNIihI0sAeK6Zytudd7qEhCfyHdUPtL2uDmZSmEQ7J5 ", "qkA8T5Q6lNcUSTAhwi9jYaEbZpxmpvfoD0xB9ZdwLEEEQhYEqim1cJBjv2m1dNma"),
                LogVerbosity   = LogVerbosity.Debug,
                LogWriters     = new List <TextWriter> {
                    Console.Out
                }
            });


            using (var client = new BinanceClient())
            {
                var historicalTrades = client.GetHistoricalSymbolTrades("BNBBTC");
            }

            var socketClient = new BinanceSocketClient();

            var successTrades = socketClient.SubscribeToTradeUpdates("bnbbtc", (data) =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    if (AllPrices.Count == 20)
                    {
                        AllPrices.RemoveAt(0);
                    }

                    AllPrices.Add(data);
                    AllPrices.OrderByDescending(r => r.TradeTime);
                });
            });
        }