예제 #1
0
 public static void finishMasterThread()
 {
     SystemFlg.setMMFlg(false);
     SystemFlg.setMarketDataFlg(false);
     SystemFlg.setMasterFlg(false);
     SystemFlg.setDBWriterFlg(false);
     Form1.Form1Instance.setLabel12("Finished master thread");
 }
예제 #2
0
        public async static Task <string> startMMBot(double entry_spread_width, double size)
        {
            string res = "";

            SystemFlg.setMMFlg(true);

            initialize();
            entry_spread = entry_spread_width;
            order_size   = size;
            var ac = new Account();

            await Task.Delay(3000);


            await Task.Run(async() =>
            {
                int num = 0;
                while (SystemFlg.getMMFlg())
                {
                    if (FlyerAPI2.getApiAccessProhibition() == false)
                    {
                        //Log.addLog("MMBOT", "num=" + num.ToString());
                        await MMStrategy(ac);

                        //string line2 = "";
                        //var ord = ac.getAllOrders();

                        /*for (int i = 0; i < ord.Count; i++)
                         *  line2 += ord[i].order_side + " - " + ord[i].order_lot + "@" + ord[i].order_price + ", ";
                         */
                        //ac.takeLog("orders:"+line2);
                        //ac.takeLog("holdings:"+ ac.holding_ave_side + ", hold ave price=" + ac.holding_ave_price + " x " + ac.holding_total_size);

                        Form1.Form1Instance.Invoke((Action)(() =>
                        {
                            Form1.Form1Instance.setLabel5(ac.holding_ave_side + ", hold ave price=" + ac.holding_ave_price + " x " + ac.holding_total_size);
                            Form1.Form1Instance.setLabel4("num trade=" + ac.num_trade);
                            //Form1.Form1Instance.setLabel6(line2);
                        }));
                        num++;
                    }
                    else
                    {
                        Form1.Form1Instance.Invoke((Action)(() => { Form1.Form1Instance.setLabel4("api prohibited"); }));
                        await Task.Delay(1000);
                    }
                }
            });

            Form1.Form1Instance.Invoke((Action)(() => { Form1.Form1Instance.addListBox2("Finishing MMBot"); }));
            await ac.cancelAllOrders();

            await ac.checkExecutionAndUpdateOrders();

            await ac.startExitPriceTracingOrder();

            Form1.Form1Instance.Invoke((Action)(() => { Form1.Form1Instance.addListBox2("Finished MMBot"); }));

            //ac.displayAllLog();
            ac.writeLog();

            return(res);
        }