Exemple #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;
            }
        }
Exemple #2
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);
        }
Exemple #3
0
        private void DisplayGraph(IEnumerable <Price> data, IEnumerable <SplitEvent> splits)
        {
            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.GraphPane.GraphObjList.RemoveAll(s => (GraphMarkerType)s.Tag == GraphMarkerType.Split);

            if (cbGraphDisplay.SelectedIndex != -1 && cbGraphDisplay.SelectedItem.ToString().Contains("Raw"))
            {
                LineItem shareLine = zedGraphControl1.GraphPane.AddCurve("Raw",
                                                                         data.Select(d => (double)new XDate(d.date)).ToArray(),
                                                                         data.Select(d => (double)d.closePrice).ToArray(),
                                                                         GraphColour_Raw);
                shareLine.Symbol.Type = SymbolType.None;
            }
            if (cbGraphDisplay.SelectedIndex != -1 && cbGraphDisplay.SelectedItem.ToString().Contains("Normalised"))
            {
                LineItem shareLine = zedGraphControl1.GraphPane.AddCurve("Normalised",
                                                                         data.Select(d => (double)new XDate(d.date)).ToArray(),
                                                                         HistoricalPriceReader.Convert(data, splits).Select(d => (double)d.closePrice).ToArray(),
                                                                         GraphColour_Normanlised);
                shareLine.Symbol.Type = SymbolType.None;
            }

            zedGraphControl1.GraphPane.XAxis.Title.Text      = "Date";
            zedGraphControl1.GraphPane.XAxis.Type            = AxisType.Date;
            zedGraphControl1.GraphPane.XAxis.Scale.Format    = "dd-MM-yy";
            zedGraphControl1.GraphPane.XAxis.Scale.MajorUnit = DateUnit.Year;
            zedGraphControl1.GraphPane.XAxis.Scale.MajorStep = 1;
            zedGraphControl1.GraphPane.XAxis.Scale.MinorUnit = DateUnit.Day;
            zedGraphControl1.GraphPane.XAxis.Scale.MinorStep = 1;
            zedGraphControl1.GraphPane.XAxis.Scale.Min       = (double)new XDate(data.First().date);
            zedGraphControl1.GraphPane.XAxis.Scale.Max       = (double)new XDate(data.Last().date);
            zedGraphControl1.GraphPane.YAxis.Title.Text      = "Close Price";
            zedGraphControl1.AxisChange();

            if (cbSplitsShowOnGraph.Checked)
            {
                foreach (var s in splits)
                {
                    AddMarker(zedGraphControl1, s.date, GraphColour_Splits, GraphMarkerType.Split);
                }
            }

            zedGraphControl1.Invalidate();
        }
Exemple #4
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);
        }