Esempio n. 1
0
        public void StartExamination()
        {
            index = 1;
            var emulator = new Emulator2(DB);

            for (double indexCheckDiff = checkDiffFrom; indexCheckDiff < checkDiffTo + 0.1; indexCheckDiff += checkDiffStep)
            {
                for (double indexDiff = diffFrom; indexDiff < diffTo + 0.1; indexDiff += diffStep)
                {
                    for (double indexCheck = checkTimeFrom; indexCheck < checkTimeTo + 1; indexCheck += checkTimeStep)
                    {
                        for (double indexBuy = buyTimeFrom; indexBuy < buyTimeTo + 1; indexBuy += buyTimeStep)
                        {
                            for (double indexHold = holdTimeFrom; indexHold < holdTimeTo + 1; indexHold += holdTimeStep)
                            {
                                var SW = new Stopwatch();
                                SW.Start();

                                emulator.Settings(StartDate, EndDate, indexCheckDiff, SaveData, index, indexDiff, indexCheck, indexBuy, indexHold, balance);
                                emulator.MakeMoney();
                                outBalance = emulator.GetBalance();

                                examinations.Add(NewElement(indexDiff, indexCheckDiff, indexCheck, indexBuy, indexHold, outBalance));

                                Debug.WriteLine($"[{index}/{countCycles}] Diff: {indexDiff}, checkDiff: {indexCheckDiff}, CheckTime: {indexCheck}, Buytime: {indexBuy}, HoldTime: {indexHold}, Balance: {outBalance}");
                                if (SaveData)
                                {
                                    Debug.WriteLine("save th");

                                    OwnDataBase.database.BulkInsert(emulator.TradeHistory);
                                }

                                index++;
                                SW.Stop();
                                Debug.WriteLine(SW.ElapsedMilliseconds);
                            }
                            OwnDataBase.database.BulkInsert(examinations);
                            examinations.Clear();
                            OwnDataBase.database.BulkSaveChanges();
                            Debug.WriteLine("SAVE DATA");
                        }
                    }
                }
            }

            DB.Clear();
        }
Esempio n. 2
0
        public void StartExamination()
        {
            int index    = 1;
            var emulator = new Emulator2(DB);

            Settings settings;

            for (double indexDiff = diffFrom; indexDiff < diffTo + 0.1; indexDiff += diffStep)
            {
                for (double indexCheck = checkTimeFrom; indexCheck < checkTimeTo + 1; indexCheck += checkTimeStep)
                {
                    for (double indexBuy = buyTimeFrom; indexBuy < buyTimeTo + 1; indexBuy += buyTimeStep)
                    {
                        for (double indexHold = holdTimeFrom; indexHold < holdTimeTo + 1; indexHold += holdTimeStep)
                        {
                            var sw = new Stopwatch();
                            sw.Start();

                            settings            = new Settings(StartDate, EndDate, SaveData, balance, index, countCycles);
                            settings.emulator   = emulator;
                            settings.indexDiff  = indexDiff;
                            settings.indexCheck = indexCheck;
                            settings.indexBuy   = indexBuy;
                            settings.indexHold  = indexHold;


                            Thread thread = new Thread(new ParameterizedThreadStart(settings.StartEmulation));
                            thread.Start();



                            OwnDataBase.database.Examinations.Add(settings.NewElement(indexDiff, indexCheck, indexBuy, indexHold - 1, emulator.GetBalance()));
                            if (SaveData)
                            {
                                Debug.WriteLine("save th");
                                //OwnDataBase.database.TradeHistories.AddRange(emulator.TradeHistory);
                                OwnDataBase.database.BulkInsert(emulator.TradeHistory);
                            }

                            OwnDataBase.database.BulkSaveChangesAsync();
                            index++;

                            sw.Stop();
                            Debug.WriteLine(sw.ElapsedMilliseconds);
                        }
                    }
                }
            }
            DB.Clear();
        }
Esempio n. 3
0
        public void StartEmulation(object settings)
        {
            emulator.Settings(StartDate, EndDate, SaveData, index, indexDiff, indexCheck, indexBuy, indexHold, balance);
            emulator.MakeMoney();


            Debug.WriteLine($"[{index}/{countCycles}] Diff: {indexDiff}, CheckTime: {indexCheck}, Buytime: {indexBuy}, HoldTime: {indexHold}, Balance: {emulator.GetBalance()}");
        }