Exemplo n.º 1
0
        public void AnalyseStrategy(DateTime?fromNullable, DateTime?toNullable)
        {
            Dictionary <int, ResetTimeAnalyzer> dictResp = new Dictionary <int, ResetTimeAnalyzer>();

            double swap = 0;

            if (ResetTimeAnalysis.SideAnalyser.Buy == Side && SwapCollection != null)
            {
                swap = SwapCollection.GetBuySwap(SymbolName);
            }
            if (ResetTimeAnalysis.SideAnalyser.Sell == Side && SwapCollection != null)
            {
                swap = SwapCollection.GetSellSwap(SymbolName);
            }

            InputData inDataAll = new InputData();

            inDataAll.LoadFromDirectory(this.SourceDirectory, null);
            DateTime from = fromNullable.HasValue ? fromNullable.Value : inDataAll.Data.First().DateTime;
            DateTime to   = toNullable.HasValue ? toNullable.Value : inDataAll.Data.Last().DateTime;

            inDataAll = inDataAll.Select(from, to);

            while (from < to)
            {
                InputData inData = inDataAll.Select(from, to);
                if (inData.Data.Count == 0)
                {
                    continue;
                }
                int             countDiff             = inDataAll.Data.Count - inData.Data.Count;
                FuturePredictor fPredictor            = new FuturePredictor(inData.Data);
                List <StratergyParameterRange> ranges = new BuyLimitAndWaitConfigReader().GetRanges(new List <string>());

                Dictionary <int, ResetTimeAnalyzer> dictRespTest = new Dictionary <int, ResetTimeAnalyzer>();
                foreach (StrategyParameter currParam in ranges[0].GetAllParameters())
                {
                    if (!dictResp.ContainsKey(currParam["TP"]))
                    {
                        dictResp.Add(currParam["TP"], new ResetTimeAnalyzer(currParam["TP"], 1 / 60d, fPredictor.Bids, fPredictor.Asks, 1, swap));
                    }
                    IEnumerable <int> buyArray, sellArray;

                    ResetTimeAnalysis.CalculatePoints(currParam, inData, fPredictor, countDiff, out buyArray, out sellArray);
                    dictResp[currParam["TP"]].Process(buyArray, sellArray);
                }

                from = from.AddDays(14);
            }
            ResetTimeScript rts = new ResetTimeScript(dictResp.Values.ToList(), "",
                                                      GetScriptDirectory(this.SymbolName, "", fromNullable, toNullable));;

            rts.Save();
        }
Exemplo n.º 2
0
        public void AnalyseAllPoints(DateTime?fromNullable, DateTime?toNullable)
        {
            InputData inDataAll = new InputData();

            inDataAll.LoadFromDirectory(this.SourceDirectory, null);
            DateTime  from   = fromNullable.HasValue ? fromNullable.Value : inDataAll.Data.First().DateTime;
            DateTime  to     = toNullable.HasValue ? toNullable.Value : inDataAll.Data.Last().DateTime;
            InputData inData = inDataAll.Select(from, to);

            FuturePredictor fPredictor            = new FuturePredictor(inData.Data);
            List <StratergyParameterRange> ranges = new BuyLimitAndWaitConfigReader().GetRanges(new List <string>());


            Dictionary <int, ResetTimeAnalyzer> dictResp = new Dictionary <int, ResetTimeAnalyzer>();

            foreach (StrategyParameter currParam in ranges[0].GetAllParameters())
            {
                if (!dictResp.ContainsKey(currParam["TP"]) /*&& i++ < inData.Data.Count / 2*/)
                {
                    string profitSymbol = ForexSuite.SymbolsManager.GetProfitSymbol(this.SymbolName);
                    double coefToUSD    = ForexSuite.QuotesManager.ConvertCurrency(profitSymbol, "USD", inData.Data.Last().DateTime, ForexSuite.SymbolsManager.ValueFromPips(profitSymbol, 1));
                    dictResp.Add(currParam["TP"], new ResetTimeAnalyzer(currParam["TP"], 1 / 60d, fPredictor.Bids, fPredictor.Asks, coefToUSD));

                    IEnumerable <int> buyArray = null, sellArray = null;
                    switch (Side)
                    {
                    case ResetTimeAnalysis.SideAnalyser.Buy:
                        buyArray = Enumerable.Range(0, (inData.Data.Count - 1));
                        break;

                    default:
                        sellArray = Enumerable.Range(0, (inData.Data.Count - 1));
                        break;
                    }
                    dictResp[currParam["TP"]].Process(buyArray, sellArray);
                }
            }
            ResetTimeScript rts = new ResetTimeScript(dictResp.Values.ToList(), "",
                                                      GetScriptDirectory(this.SymbolName, "AllPoints", fromNullable, toNullable));;

            rts.Save();
        }