Esempio n. 1
0
        public static async void startBoardUpdate()
        {
            initialize();

            await Task.Run(async() =>
            {
                while (SystemFlg.getMarketDataFlg())
                {
                    if (FlyerAPI2.getApiAccessProhibition() == false)
                    {
                        var board = await FlyerAPI2.getBoardAsync("FX_BTC_JPY");

                        if (board.MidPrice != 0)
                        {
                            board.dt  = DateTime.Now;
                            var ask_p = board.Asks.Select(c => c.Price).ToArray();
                            var bid_p = board.Bids.Select(c => c.Price).ToArray();

                            var ask_min = ask_p.Min();
                            var bid_max = bid_p.Max();

                            board.spread = ask_min - bid_max;
                            setCurrentBoard(board);
                            MarketDataLog.addBoardData(board.dt, new double[] { bid_max, ask_min, board.spread });
                            Form1.Form1Instance.Invoke((Action)(() =>
                            {
                                Form1.Form1Instance.setLabel3(board.spread.ToString());
                            }));
                        }
                    }
                    //await Task.Delay(0);
                }
            });
        }
Esempio n. 2
0
        private async void buttonSendOrder_Click(object sender, EventArgs e)
        {
            if (SystemFlg.getMarketDataFlg() == false)
            {
                MarketData.startMarketData();
                await Task.Delay(3000);
            }


            var board = await FlyerAPI2.getBoardAsync("FX_BTC_JPY");

            double price = board.Asks.Select(x => x.Price).ToList().Min() - 1;

            var res = await FlyerAPI2.sendChiledOrderAsync("SELL", price, 0.01, 1);

            if (res.order_id != "")
            {
                addListBox2("completed send order:" + res.order_id);
            }

            if (id == "")
            {
                id = res.order_id;
            }


            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            bool   flg   = true;
            string dotti = "";

            while (flg)
            {
                var exe = await FlyerAPI2.getExecutionsAcceptanceIDAsync(res.order_id);

                System.Diagnostics.Debug.WriteLine(exe);
                if (exe.Count > 0)
                {
                    if (exe[0].child_order_accesptance_id == res.order_id)
                    {
                        flg   = false;
                        dotti = "getExecutionsAcceptanceIDAsync";
                    }
                }
                if (MarketDataLog.getExecutionStatus(res.order_id))
                {
                    flg   = false;
                    dotti = "getExecutionStatus";
                }
            }

            sw.Stop();
            id = res.order_id;
            Form1Instance.addListBox2(res.order_id + ":time=" + sw.ElapsedMilliseconds + ", dotti=" + dotti);

            SystemFlg.setMarketDataFlg(false);
            SystemFlg.setDBWriterFlg(false);

            /*
             * var board2 = await FlyerAPI2.getBoardAsync("FX_BTC_JPY");
             * var res2 = await FlyerAPI2.sendChiledOrderAsync("SELL", board2.Asks.Select(x => x.Price).ToList().Max()-1, 0.01, 1);
             *
             * var exe2 = await FlyerAPI2.getExecutionsAcceptanceIDAsync(res2.order_id);
             *
             * var posi2 = await FlyerAPI2.getPositionsAsync();
             */
        }