Esempio n. 1
0
        private async void button12_Click(object sender, EventArgs e)
        {
            try
            {
                label6.Text = "Cancel All Order Requesting";
                await client.CancelAllOrders();

                label6.Text = "Cancel All Order Accepted";
            }
            catch (Exception ex)
            {
                listBox2.DataSource = null;
                listBox2.Items.Add(ex);
                listBox2.Items.Add("Failed to cancel all orders.");

                label6.Text  = "Cancel All Order 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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Bitflyerの建玉の手じまいをする
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static async Task Tejimai(BitflyerClient client)
        {
            await client.CancelAllOrders();

            double buy  = 0;
            double sell = 0;

            try
            {
                Console.WriteLine("leave all positions");
                var positions = await client.GetMyPositions();

                foreach (var p in positions)
                {
                    if (p.Side == OrderSide.BUY)
                    {
                        sell += p.Size;
                    }
                    else if (p.Side == OrderSide.SELL)
                    {
                        buy += p.Size;
                    }
                }
                if (sell >= 0.001)
                {
                    //sell = ToRoundDown(sell, 3);
                    await client.Sell(sell);
                }
                if (buy >= 0.001)
                {
                    //buy = ToRoundDown(buy, 3);
                    await client.Buy(buy);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message + "," + sell + "," + buy);
            }
        }
Esempio n. 3
0
        private async void button1_Click(object sender, EventArgs e)
        {
            try
            {
                label1.Text = "Cancel all orders requesting";
                await client.CancelAllOrders();

                label1.Text = "Cancel all orders accepted";
            }
            catch (Exception ex)
            {
                listBox1.DataSource = null;
                listBox1.Items.Add(ex);
                listBox1.Items.Add("Failed to cancel all orders.");

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

            await Task.Delay(3000);
        }