예제 #1
0
        public async Task <TestResultRepositiry> TestAsync()
        {
            TestResultRepositiry _result = await this.GetInputData();

            StaticService.LogFileWrite("-- TestAsync = " + runTime, "runtime.txt", true);

            return(_result);
        }
예제 #2
0
        public async Task <string> CalcBBAsync(SettingsClass _sc)
        {
            string _result = await this.GetInputData(_sc);

            StaticService.LogFileWrite("-- CalculationBBAsync = " + _result, "runtime.txt", true);

            return("Расчет закончен.");
        }
예제 #3
0
        public void ConvertMyDiagnostics()
        {
            string _runtime = StaticService.RutimeMethod(() =>
            {
                this.ConvertMy();
            });

            StaticService.LogFileWrite("-- ConvertMy = " + _runtime, "runtime.txt", true);
        }
예제 #4
0
        /// <summary>
        /// Task для конвертации в .dat
        /// </summary>
        private Task TaskConvert(byte[] _result, string _id)
        {
            StaticService.LogFileWrite(DateTime.Now.ToLongTimeString() + "  " + _id, "runtime.txt", true);

            return(Task.Run(() =>
            {
                string _text = Encoding.UTF8.GetString(_result);
                string[] _separator = new string[3] {
                    "\r\n", "\n", "\r"
                };
                string[] _mapStr = _text.Split(_separator, StringSplitOptions.RemoveEmptyEntries);

                string _date = String.Empty;
                string _time = String.Empty;
                decimal _price = 0;

                MarketTradesRepository marketTradRepo = new MarketTradesRepository();
                int _iD = 0;

                foreach (string _line in _mapStr)
                {
                    string[] _splites = Regex.Split(_line, paternRegEx1);

                    _iD++;
                    _date = _splites[0];
                    _time = _splites[1];

                    try
                    {
                        _price = Convert.ToDecimal(_splites[2]);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    marketTradRepo.Add(new ParametrMarketTrades(_iD.ToString(), _date, _time, 0, _price, ""));
                }

                if (marketTradRepo.Count > 0)
                {
                    StaticService.Serializes(marketTradRepo, folder + marketTradRepo[0].DateTimeTrades.ToShortDateString());
                }

                StaticService.LogFileWrite(DateTime.Now.ToLongTimeString() + "  " + _id, "runtime.txt", true);
            }));
        }
예제 #5
0
        /// <summary>
        /// Открываем лонги, если цена выше самой верхней линии.
        /// Открываем шорты, если цена ниже самой нижней линии.
        /// Закрытие: переворачиваемся.
        /// </summary>
        private Task TrendAlgoritmTest(string _path)
        {
            return(Task.Run(() =>
            {
                TradesBolingerRepository _trdBRepo = null;
                string file_name = "test_result.txt";
                try
                {
                    _trdBRepo = (TradesBolingerRepository)StaticService.Deserializes(_path);
                }
                catch (Exception)
                {
                    StaticService.LogFileWrite(_path, "error_log.txt", true);
                }

                string _key = Path.GetFileNameWithoutExtension(_path);
                string _dateRes = StaticService.GetComment(_key, SettingsClass.PaternDate1);
                string _settBB = StaticService.GetComment(_key, SettingsClass.Patern);

                TestTradesCollection testTradColl = new TestTradesCollection();
                TestTradesCollection testTradCollOPT = new TestTradesCollection();

                int tp = 0;
                double profitPortfolio = 0; // прибыль портфеля на каждую сделку
                int countTrades = 0;
                double maxProfit = 0;
                double minProfit = 0;
                int countProfitTrades = 0;
                int countLossTrades = 0;

                // OPT
                double profitPortfolioOpt = 0;
                int countTradesOpt = 0;
                double maxProfitOpt = 0;
                double minProfitOpt = 0;
                int countProfitTradesOpt = 0;
                int countLossTradesOpt = 0;
                // end opt

                StaticService.LogFileWrite("\n         ---------" + _key + "---------", file_name, true);

                if (_trdBRepo != null)
                {
                    foreach (ParametrTradesBolinger pcT in _trdBRepo)
                    {
                        //StaticClassService.LogFileWrite(pcT.DateTimeTrades + "\t" + pcT.NumberTrades + "\t" + pcT.PriceTrades + "\t" + pcT.SeccodeTrades + "\t" + pcT.LineUp + "\t" + pcT.LineDown + "\t" + pcT.LineMidl, file_name, true);

                        DateTime dateTimeTrade = pcT.DateTimeTrades;

                        if (dateTimeTrade.TimeOfDay < new TimeSpan(19, 0, 0))
                        {
                            double price = (double)pcT.PriceTrades;

                            //---Здесь вызываем Класс нужного алгоритма---
                            Algoritms.BollingerCrossing.Algoritm(pcT, testTradColl, testTradCollOPT, file_name, price, dateTimeTrade, ref tp, ref countTrades, ref countTradesOpt, ref profitPortfolio, ref profitPortfolioOpt, ref maxProfit, ref maxProfitOpt, ref minProfit, ref minProfitOpt, ref countProfitTrades, ref countProfitTradesOpt, ref countLossTrades, ref countLossTradesOpt);
                            //--------------------------------------------
                        }
                    }
                }

                // save result
                testResultRepo.Add(new ParametrTestResult(_key, _dateRes, _settBB, profitPortfolio, countTrades, maxProfit, minProfit, countProfitTrades, countLossTrades));
                testResultRepo.Add(new ParametrTestResult(_key + "OPT", _dateRes, _settBB, profitPortfolioOpt, countTradesOpt, maxProfitOpt, minProfitOpt, countProfitTradesOpt, countLossTradesOpt)); // Opt

                // serialize TestTradesCollection end TestTradesCollection'OPT'
                StaticService.Serializes(testTradColl, folderOutTestTradesSimple + _key);
                StaticService.Serializes(testTradCollOPT, folderOutTestTradesOPT + _key);
            }));
        }
예제 #6
0
        public async void ConvertAsyncDiagnostic()
        {
            string _result = await this.ConvertAsync();

            StaticService.LogFileWrite("-- ConvertAsync = " + _result, "runtime.txt", true);
        }