コード例 #1
0
        private async void listBox2_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!processing && orders != null)
            {
                processing = true;

                try
                {
                    if (listBox2.SelectedIndex < orders.Count)
                    {
                        label6.Text = "Cancel Order #" + listBox2.SelectedIndex.ToString() + " Requesting";
                        await client.CancelOrder(orders.ElementAt(listBox2.SelectedIndex));

                        label6.Text = "Cancel Order #" + listBox2.SelectedIndex.ToString() + " Accepted";
                    }
                }
                catch (Exception ex)
                {
                    listBox2.DataSource = null;
                    listBox2.Items.Add(ex);
                    listBox2.Items.Add("Failed to cancel order.");
                    label6.Text  = "Cancel Order #" + listBox2.SelectedIndex.ToString() + " Failed";
                    label6.Text += "\n" + ex.ToString();

//                    bfTrader.Properties.Settings.Default.key = "";
//                    bfTrader.Properties.Settings.Default.secret = "";
//                    bfTrader.Properties.Settings.Default.Save();

                    await Task.Delay(1000);
                }

                processing = false;
            }
        }
コード例 #2
0
        static async Task CancelOneOrder()
        {
            Console.WriteLine("");
            Console.WriteLine("========================================");
            Console.WriteLine("my orders (for cancel)");
            Console.WriteLine("========================================");
            var orders = await client.GetMyActiveOrders();

            foreach (var order in orders)
            {
                Console.WriteLine(order.ToString());
            }
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("========================================");
            Console.WriteLine("cancel one order");
            Console.WriteLine("========================================");
            if (orders.Count > 0)
            {
                await client.CancelOrder(orders[0]);

                Console.WriteLine("one order cancel done");
            }
            else
            {
                Console.WriteLine("no order to cancel");
            }
        }
コード例 #3
0
        private async void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!processing && orders != null)
            {
                processing = true;

                try
                {
                    if (listBox1.SelectedIndex < orders.Count)
                    {
                        label1.Text = "Order # " + (listBox1.SelectedIndex + 1).ToString() + " cancel requesting";
                        await client.CancelOrder(orders.ElementAt(listBox1.SelectedIndex));

                        label1.Text = "Order # " + (listBox1.SelectedIndex + 1).ToString() + " cancel accepted";
                    }
                    else
                    {
                        label1.Text = "Order # " + (listBox1.SelectedIndex + 1).ToString() + " out of range";
                    }
                }
                catch (Exception ex)
                {
                    listBox1.DataSource = null;
                    listBox1.Items.Add(ex);
                    listBox1.Items.Add("Failed to cancel order.");

                    Properties.Settings.Default.key    = "";
                    Properties.Settings.Default.secret = "";
                    Properties.Settings.Default.Save();
                }

                await Task.Delay(3000);

                processing = false;
            }
        }