Exemplo n.º 1
0
        static async Task ShowMyActiveOrders()
        {
            Console.WriteLine("");
            Console.WriteLine("========================================");
            Console.WriteLine("my orders");
            Console.WriteLine("========================================");
            var orders = await client.GetMyActiveOrders();

            foreach (var order in orders)
            {
                Console.WriteLine(order.ToString());
            }
            Console.WriteLine("");
        }
Exemplo n.º 2
0
        async Task getOpenOrders()
        {
            List <string> orderListA = new List <string>();
            List <string> orderListB = new List <string>();
            List <string> orderList  = orderListA;

            if (listBox2.DataSource == null)
            {
                listBox2.Items.Add("Connecting to BitFlyer server ...");
            }

            if (listBox2.DataSource != null)
            {
                if (listBox2.DataSource.Equals(orderListA))
                {
                    orderList = orderListB;
                }
                else
                {
                    orderList = orderListA;
                }
            }

            if (orderList != null)
            {
                orderList.Clear();
            }

            try
            {
                orders = await client.GetMyActiveOrders();
            }
            catch (Exception ex)
            {
                listBox2.DataSource = null;
                listBox2.Items.Add(ex);
                listBox2.Items.Add("Connecting to BitFlyer server ...");

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

                await Task.Delay(1000);

                return;
            }

            if (orders == null)
            {
                orderList.Add("No Open Order.");
            }
            else if (orders.Count == 0)
            {
                orderList.Add("No Open Order.");
            }
            else
            {
                foreach (Order oo in orders)
                {
                    string   side   = oo.Side.ToString();
                    string[] amount = oo.OutstandingSize.ToString().Split('.');
                    string   price  = oo.Price.ToString();
                    string   date   = oo.Date.ToLongTimeString() + ss[1] + oo.Date.ToShortDateString();

                    orderList.Add(ss[4 - side.Length] + side + ss[4 - amount[0].Length] + amount[0] +
                                  (amount.Length == 2 ? ("." + amount[1] + ss[8 - amount[1].Length]) : ss[9]) + " BTC at " +
                                  ss[6 - price.Length] + price + ss[3] + date);
                }
            }

            int foc = listBox2.SelectedIndex;
            int pos = listBox2.TopIndex;

            if (!mask2)
            {
                listBox2.BeginUpdate();
                listBox2.DataSource = orderList;
                listBox2.EndUpdate();
            }

            if (orders == null)
            {
                // do nothing
            }
            else
            {
                listBox2.SelectedIndex = (foc < orders.Count) ? foc : 0;
                listBox2.TopIndex      = (pos < orders.Count) ? pos : 0;
            }
        }