Пример #1
0
        private void toolStripButton_buy_Click(object sender, EventArgs e)
        {
            ExchangeManager.ExchangeBalance marketBalance = ExchangeManager.Balances.FirstOrDefault(balance =>
                                                                                                    balance.Exchange == Exchange.Name &&
                                                                                                    balance.Symbol == Exchange.CurrentTicker.market);

            if (numericUpDown_total.Value == 0 || numericUpDown_amount.Value == 0)
            {
                MessageBox.Show("No Amount Or Total To Process", "EMPTY ORDER");
            }
            else
            {
                if (numericUpDown_total.Value > marketBalance.Balance)
                {
                    MessageBox.Show("Not Enough Funds For This Buy", "INSUFFICIENT FUNDS");
                }
                else
                {
                    if (View != "stop-limit")
                    {
                        string       message      = "Buy : " + numericUpDown_amount.Value.ToString("N8") + " " + Exchange.CurrentTicker.symbol + " @ Price : " + numericUpDown_price.Value.ToString("N8") + " " + Exchange.CurrentTicker.market;
                        string       title        = "TOTAL : " + numericUpDown_total.Value.ToString("N8") + " " + Exchange.CurrentTicker.market;
                        DialogResult dialogResult = MessageBox.Show(message, title, MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.Yes)
                        {
                            //do something
                            LogManager.AddLogMessage(Name, "toolStripButton_buy_Click", "THIS BUY FUNCTION NEEDS TO BE ENABLED", LogManager.LogMessageType.DEBUG);
                            ExchangeManager.CreateNewOrder(Exchange.Name, ExchangeManager.ExchangeOrderType.buy, Exchange.CurrentTicker.symbol, Exchange.CurrentTicker.market, numericUpDown_price.Value, numericUpDown_amount.Value);

                            numericUpDown_amount.Value = 0;
                            numericUpDown_total.Value  = 0;
                        }
                    }
                    else
                    {
                        //string message = "STOP-LIMIT Buy : " + numericUpDown_amount.Value.ToString("N8") + " " + Exchange.CurrentTicker.symbol +
                        //" @ Price : " + numericUpDown_price.Value.ToString("N8") + " " + Exchange.CurrentTicker.market +
                        //" With STOP LIMIT OF " + numericUpDown_stop.Value;
                        string message = "If the lowest ask rises to or above " + numericUpDown_stop.Value + " " + Exchange.CurrentTicker.market +
                                         ", An order to buy " + numericUpDown_amount.Value + " " + Exchange.CurrentTicker.symbol +
                                         " at a price of " + numericUpDown_price.Value + " " + Exchange.CurrentTicker.market + " will be placed.";

                        string       title        = "STOP-LIMIT BUY for " + numericUpDown_amount.Value + " " + Exchange.CurrentTicker.symbol + " @ " + numericUpDown_total.Value.ToString("N8") + " " + Exchange.CurrentTicker.market;
                        DialogResult dialogResult = MessageBox.Show(message, title, MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.Yes)
                        {
                            //do something
                            LogManager.AddLogMessage(Name, "toolStripButton_buy_Click", "THIS STOP-LIMIT BUY FUNCTION NEEDS TO BE ENABLED", LogManager.LogMessageType.DEBUG);
                            numericUpDown_amount.Value = 0;
                            numericUpDown_total.Value  = 0;
                        }
                    }
                }
            }
        }