Esempio n. 1
0
        private void Move_Click(object sender, EventArgs e)
        {
            if (dgOrders.SelectedRows.Count == 0)
            {
                MessageBox.Show("No order selected", "Warning");
                return;
            }

            var market = GetMarket();

            if (market == MarketType.Empty)
            {
                return;
            }

            foreach (DataGridViewRow row in dgOrders.SelectedRows)
            {
                using (var form = new OrderPlace(
                           market,
                           pairs.Data[EnumValue.GetValue(market)],
                           new {
                    pair = row.Cells["Pair"].Value?.ToString(),
                    buy = row.Cells["Side"].Value?.ToString() == "Buy",
                    limit = row.Cells["Type"].Value?.ToString() == "Limit",
                    amount = row.Cells["Amount"].Value?.ToString(),
                    price = row.Cells["Price"].Value?.ToString(),
                    guid = row.Cells["API_GUID"].Value?.ToString()
                }))
                {
                    form.ShowDialog();
                    if (form.IsOK)
                    {
                        socket?.Send(Sends.OrderMove(
                                         rbReal.Checked ? SysType.Real : SysType.Demo,
                                         market,
                                         new Order {
                            OrderID = row.Cells["OrderID"].Value.ToString(),
                            Price   = form.tbPrice.Text
                        }
                                         ));
                    }
                }
            }
        }
        private void Place_Click(object sender, EventArgs e)
        {
            var market = GetMarket();

            if (market == MarketType.Empty)
            {
                return;
            }

            using (var form = new OrderPlace(market, pairs[market]))
            {
                form.ShowDialog();
                if (form.IsOK)
                {
                    var order = rest.OrderPlace(
                        rbReal.Checked ? SysType.Real : SysType.Demo,
                        market,
                        new Order
                    {
                        Pair   = form.cbPair.Text,
                        Side   = form.rbBuy.Checked ? OrderSide.Buy : OrderSide.Sell,
                        Type   = form.rbLimit.Checked ? OrderType.Limit : OrderType.Market,
                        Amount = form.tbAmount.Text,
                        Price  = form.rbLimit.Checked ? form.tbPrice.Text : null,
                    },
                        string.IsNullOrWhiteSpace(form.tbGUID.Text) ? null : form.tbGUID.Text
                        );

                    if (string.IsNullOrWhiteSpace(order.ErrorMessage))
                    {
                        orders         = orders ?? new Dictionary <MarketType, List <DataOrder> >();
                        orders[market] = orders[market] ?? new List <DataOrder>();
                        orders[market].Add(order);
                        lbOrders.Text = "Update time: " + DateTime.Now.ToString() + " for market " + EnumValue.GetValue(market) + " and order id " + order.OrderID;

                        UpdateOrders();
                    }
                    else
                    {
                        MessageBox.Show("Order not placed: " + order.ErrorMessage, "Error");
                    }
                }
            }
        }
Esempio n. 3
0
        private void Place_Click(object sender, EventArgs e)
        {
            if (lbMarkets.SelectedItem == null)
            {
                MessageBox.Show("No Markets selected", "Warning");
                return;
            }

            var market = GetMarket();

            if (market == MarketType.Empty)
            {
                return;
            }

            using (var form = new OrderPlace(
                       market,
                       pairs.Data[EnumValue.GetValue(market)]))
            {
                form.ShowDialog();
                if (form.IsOK)
                {
                    socket?.Send(Sends.OrderPlace(
                                     rbReal.Checked ? SysType.Real : SysType.Demo,
                                     market,
                                     new Order {
                        Pair   = form.cbPair.Text,
                        Side   = form.rbBuy.Checked ? OrderSide.Buy : OrderSide.Sell,
                        Type   = form.rbLimit.Checked ? OrderType.Limit : OrderType.Market,
                        Amount = form.tbAmount.Text,
                        Price  = form.rbLimit.Checked ? form.tbPrice.Text : null,
                    },
                                     string.IsNullOrWhiteSpace(form.tbGUID.Text) ? null : form.tbGUID.Text
                                     ));
                }
            }
        }
        private void Move_Click(object sender, EventArgs e)
        {
            var market = GetMarket();

            if (market == MarketType.Empty)
            {
                return;
            }

            if (dgOrders.SelectedRows.Count == 0)
            {
                MessageBox.Show("No order selected", "Warning");
                return;
            }

            foreach (DataGridViewRow row in dgOrders.SelectedRows)
            {
                var order_id = row.Cells["OrderID"].Value.ToString();

                using (var form = new OrderPlace(
                           market,
                           pairs[market],
                           new
                {
                    pair = row.Cells["Pair"].Value?.ToString(),
                    buy = row.Cells["Side"].Value?.ToString() == "Buy",
                    limit = row.Cells["Type"].Value?.ToString() == "Limit",
                    amount = row.Cells["Amount"].Value?.ToString(),
                    price = row.Cells["Price"].Value?.ToString(),
                    guid = row.Cells["API_GUID"].Value?.ToString()
                }))
                {
                    form.ShowDialog();
                    if (form.IsOK)
                    {
                        var order = rest.OrderMove(
                            rbReal.Checked ? SysType.Real : SysType.Demo,
                            market,
                            new Order
                        {
                            OrderID = order_id,
                            Price   = form.tbPrice.Text
                        }
                            );

                        if (string.IsNullOrWhiteSpace(order.ErrorMessage))
                        {
                            orders         = orders ?? new Dictionary <MarketType, List <DataOrder> >();
                            orders[market] = orders[market] ?? new List <DataOrder>();
                            orders[market].RemoveAll(x => x.OrderID == order_id);
                            orders[market].Add(order);
                            lbOrders.Text = "Update time: " + DateTime.Now.ToString() + " for market " + EnumValue.GetValue(market) + " and order id " + order.OrderID;

                            UpdateOrders();
                        }
                        else
                        {
                            MessageBox.Show("Order not moved: " + order.ErrorMessage, "Error");
                        }
                    }
                }
            }
        }