Esempio n. 1
0
        private void ButtonAnalyse_Click(object sender, RoutedEventArgs e)
        {
            SwapCollection swapCollection = new SwapCollection();
            string         initPath       = StartupParameters.DefaultSourcePath;

            swapCollection.LoadSwap(System.IO.Path.Combine(initPath, SwapCollection.SwapFileName));

            foreach (SymbolChooser.SymbolViewItem svi in symbolChooser.SymbolViewItems)
            {
                foreach (Analysis.ResetTimeAnalysis.SideAnalyser currSide in ChosenSides)
                {
                    ResetTimeViewModel rt = new ResetTimeViewModel(svi.FullPath, svi.Symbol, currSide, Int32.Parse(TextBoxWorkingPercentTime.Text), swapCollection);

                    if (CheckBoxStrategyPointAnalyse.IsChecked.Value)
                    {
                        rt.AnalyseStrategy(DatePickerFrom.SelectedDate, DatePickerTo.SelectedDate);
                    }
                    if (CheckBoxAllPointAnalyse.IsChecked.Value)
                    {
                        rt.AnalyseAllPoints(DatePickerFrom.SelectedDate, DatePickerTo.SelectedDate);
                    }
                }
            }
            System.Windows.MessageBox.Show("ButtonAnalyse_Click was done");
        }
        //public ResetTimeViewModel(string sourceDirectory, string symbolName, SwapCollection swapCollection)
        //    : this(sourceDirectory, symbolName, ResetTimeAnalysis.SideAnalyser.Both, 100, swapCollection)
        //{
        //}

        public ResetTimeViewModel(string sourceDirectory, string symbolName, ResetTimeAnalysis.SideAnalyser sa, int notReadOnlyTimePercent, SwapCollection swapCollection)
        {
            this.SourceDirectory        = sourceDirectory;
            this.SymbolName             = symbolName;
            this.Side                   = sa;
            this.NotReadOnlyTimePercent = notReadOnlyTimePercent;
            this.SwapCollection         = swapCollection;
        }
Esempio n. 3
0
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            Log4Smart.Logger.ClearAllResult();
            ButtonStart.IsEnabled = false;

            IEnumerable <string> allSymbols = symbolChooser.SymbolViewItems.Select(p => p.Symbol.Trim().ToLower());
            string         baseResultPath   = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "result");
            SwapCollection swapCollection   = new SwapCollection();

            swapCollection.LoadSwap(GetSwapFilePath());

            TestManagerViewModel tma = new TestManagerViewModel(Math.Min(Environment.ProcessorCount, Int32.Parse(ConfigurationManager.AppSettings["MaxThreadNumber"])));

            foreach (string currPath in GetAllSymbolPath())
            {
                if (!allSymbols.Contains(Path.GetFileName((currPath).ToLower())))
                {
                    continue;
                }

                try
                {
                    InputData inData = new InputData();
                    inData.LoadFromDirectory(currPath, swapCollection);
                    string baseSymbolResultPath = System.IO.Path.Combine(baseResultPath, inData.Symbol);

                    List <string> extractedParameterNames = new List <string>();
                    ConfigReader  confReader =
                        //new MartinGaleConfigReader();
                        //new Pipsovik.PipsovikConfigReader();
                        //new SuperAdaptStrategy.SuperAdaptConfigReader();
                        new BuyLimitAndWait.BuyLimitAndWaitConfigReader();

                    List <StratergyParameterRange> ranges = confReader.GetRanges(extractedParameterNames);


                    foreach (StratergyParameterRange currStratergyParameterRange in ranges)
                    {
                        OptimizationFunctionIntNDFactory factory = GetStrategyFactory(currStratergyParameterRange, confReader);

                        DateTime startAnalyzeDateTime = inData.Data[0].DateTime;
                        tma.RunBruteForceTest(Path.Combine(baseSymbolResultPath, currStratergyParameterRange.ToString(extractedParameterNames)),
                                              inData, factory);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.ToString());
                }
            }
            tma.WaitJobFinished();

            System.Windows.MessageBox.Show("AnalyseStrategyeMarginEquityWindow Completed");
        }
Esempio n. 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (Settings1.Default.NumberLastMonthToAnalyze > 0)
            {
                Log4Smart.Logger.ClearAllResult();
            }
            ButtonStart.Enabled = false;

            IEnumerable <string> allSymbols = from p in Settings1.Default.Symbols.Split(new char[] { ',' })
                                              select p.Trim().ToLower();

            string         baseResultPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "result");
            SwapCollection swapCollection = new SwapCollection();

            swapCollection.LoadSwap(GetSwapFilePath());
            foreach (string currPath in GetAllSymbolPath())
            {
                if (!allSymbols.Contains(Path.GetFileName((currPath).ToLower())))
                {
                    continue;
                }

                try
                {
                    TestManager tma    = new TestManager(Settings1.Default.NumberThreads);
                    InputData   inData = new InputData();
                    inData.LoadFromDirectory(currPath, swapCollection);
                    string baseSymbolResultPath = System.IO.Path.Combine(baseResultPath, inData.Symbol);

                    List <string> extractedParameterNames = new List <string>();

                    List <StratergyParameterRange> ranges =
                        //new MartinGaleConfigReader().GetRanges(extractedParameterNames);
                        //new SuperAdaptConfigReader().GetRanges(extractedParameterNames);
                        // new SuperStrategyConfigReader().GetRanges(extractedParameterNames);
                        // new BuyAndWaitConfigReader().GetRanges(extractedParameterNames);
                        new BuyLimitAndWaitConfigReader().GetRanges(extractedParameterNames);
                    //new TheoristConfigReader().GetRanges(extractedParameterNames);


                    foreach (StratergyParameterRange currStratergyParameterRange in ranges)
                    {
                        OptimizationFunctionIntNDFactory factory = //new TheoristFunctionFactory(currStratergyParameterRange);
                                                                   //new BuyAndWaitFunctionFactory(currStratergyParameterRange);
                                                                   new BuyLimitAndWaitFunctionFactory(currStratergyParameterRange);
                        // new BuyLimitAndWaitFunctionFactory(currStratergyParameterRange);
                        //new SuperAdaptFunctionFactory(currStratergyParameterRange);
                        //OptimizationFunctionIntNDFactory factory = new MartinGaleFunctionFactory(currStratergyParameterRange);
                        //OptimizationFunctionIntNDFactory factory = new SuperStrategyFunctionFactory(currStratergyParameterRange);
                        //OptimizationFunctionIntNDFactory factory = new MartinGaleFunctionFactory();
                        //tma.EstimateAll(inData/*inData.Select(inData.Data.Last().DateTime.AddMonths(-1), inData.Data.Last().DateTime)*/, factory);



                        for (int lp = Settings1.Default.LearningPeriodStartDay; lp <= Settings1.Default.LearningPeriodEndDay; lp += Settings1.Default.LearningPeriodStep)
                        {
                            for (int tp = Settings1.Default.TestPeriodStartDay; tp <= Settings1.Default.TestPeriodEndDay; tp += Settings1.Default.TestPeriodStepDay)
                            {
                                DateTime startAnalyzeDateTime = DateTime.Now.AddMonths(-Settings1.Default.NumberLastMonthToAnalyze);
                                if (Settings1.Default.NumberLastMonthToAnalyze == 0)
                                {
                                    startAnalyzeDateTime = startAnalyzeDateTime.AddWorkingDay(-tp * 2);
                                }
                                tma.RunGeneticTests(System.IO.Path.Combine(baseSymbolResultPath, currStratergyParameterRange.ToString(extractedParameterNames)),
                                                    inData, startAnalyzeDateTime, lp, tp, factory);
                            }
                        }
                    }
                    tma.WaitJobFinished();
                    CalculateSum.Program.SumDirectory(baseSymbolResultPath);

                    //SymbolResult.Load(baseSymbolResultPath).SaveStatistics(baseSymbolResultPath);
                    //CalculateSum.Program.CalculatePortfolio(baseResultPath, 1500000, 0.9, 500000);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.ToString());
                }
            }

            this.Close();
        }