Esempio n. 1
0
        private void btnAllSharesGo_Click(object sender, EventArgs e)
        {
            foreach (var s in this.symbols)
            {
                Price[] data = HistoricalPriceReader.Convert(this.GetShareData(s), this.GetSplitData(s)).ToArray();

                SimpleSearch search = new SimpleSearch();
                search.Process(data, this.simpleSearchSettings);
                var results = search.Results;
            }
        }
Esempio n. 2
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            zedGraphControl1.GraphPane.GraphObjList.RemoveAll(t => t is LineObj);

            SimpleSearchSettings settings = new SimpleSearchSettings();
            settings.fallSearchPeriodInDays = int.Parse(tbFallSearchPeriod.Text);
            settings.riseSearchPeriodInDays = int.Parse(tbRiseSearchPeriod.Text);
            settings.requiredChangeRate = decimal.Parse(tbRateChange.Text);
            settings.numerOfRepeats = int.Parse(tbRepeats.Text);

            string symbol = cbSelectSymbol.SelectedItem as string;
            IEnumerable<Price> data = this.GetShareData(symbol);
            IEnumerable<SplitEvent> splitData = this.GetSplitData(symbol);
            data = HistoricalPriceReader.Convert(data, splitData).ToArray();

            SimpleSearch processor = new SimpleSearch();
            processor.Process(data.ToArray(), settings);

            DisplaySimpleSearchResults(processor.Results);
        }
Esempio n. 3
0
        private void btnSimpleSearchGentics_Click(object sender, EventArgs e)
        {
            SimpleSearchSettings currentSettings = new SimpleSearchSettings(), bestSettings;
            int currentFailedSells, bestFailedSells;
            int currentOkSells, bestOkSells;
            Random rnd = new Random();
            string symbol = cbSelectSymbol.SelectedItem as string;
            Price[] data = HistoricalPriceReader.Convert(this.GetShareData(symbol), this.GetSplitData(symbol)).ToArray();

            bestSettings = this.simpleSearchSettings;

            SimpleSearch search = new SimpleSearch();
            search.Process(data, this.simpleSearchSettings);
            var results = search.Results;

            bestFailedSells = results.Count(r => r.Last().state == ResultState.FailedFindingSellPoint);
            bestOkSells     = results.Count(r => r.Last().state == ResultState.OK);

            for (int c = 365; c > 0; c--)
            {
                currentSettings.fallSearchPeriodInDays = rnd.Next(1, c);
                currentSettings.riseSearchPeriodInDays = rnd.Next(1, c);
                currentSettings.requiredChangeRate     = rnd.Next(1, c);
                currentSettings.numerOfRepeats         = this.simpleSearchSettings.numerOfRepeats;

                search.Process(data, currentSettings);
                results = search.Results;

                currentFailedSells = results.Count(r => r.Last().state == ResultState.FailedFindingSellPoint);
                currentOkSells     = results.Count(r => r.Last().state == ResultState.OK);

                if (currentOkSells > 0 && (currentFailedSells < bestFailedSells || (currentFailedSells == bestFailedSells && currentOkSells > bestOkSells)))
                {
                    bestSettings = (SimpleSearchSettings)currentSettings.Clone();
                    bestFailedSells = currentFailedSells;
                    bestOkSells = currentOkSells;
                }
            }

            tbFallSearchPeriod.Text = bestSettings.fallSearchPeriodInDays.ToString();
            tbRiseSearchPeriod.Text = bestSettings.riseSearchPeriodInDays.ToString();
            tbRateChange.Text = bestSettings.requiredChangeRate.ToString();
            tbRepeats.Text = bestSettings.numerOfRepeats.ToString();

            search.Process(data, bestSettings);
            DisplaySimpleSearchResults(search.Results);
        }