Exemplo n.º 1
0
        private void outcome_sampling_button_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "steps", "indicatorid", "outcometimeframe" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                new Thread(delegate()
                {
                    Dictionary <string, string> parameters = id.getResult();

                    if (Directory.Exists(Application.StartupPath + @"\Analysis\") == false)
                    {
                        Directory.CreateDirectory(Application.StartupPath + @"\Analysis\");
                    }

                    SampleOutcomeExcelGenerator excel = new SampleOutcomeExcelGenerator(Application.StartupPath + @"\Analysis\" + DateTime.Now.ToString("yyyy_dd_mm") + "_" + parameters["instrument"] + ".xls");

                    setState("Outcomesampling");
                    dataminingDb.getOutcomeIndicatorSampling(excel, parameters["indicatorid"], Convert.ToInt32(parameters["outcometimeframe"]), Convert.ToInt32(parameters["steps"]), dataminingDb.getInfo(parameters["indicatorid"]).getDecentRange(), parameters["instrument"]);

                    excel.FinishDoc();
                    excel.ShowDocument();
                }).Start();
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                dataminingDb.setDataGroups(id.getResult()["instrument"]);
            }
        }
Exemplo n.º 3
0
        private void unload_btn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                dataminingDb.unloadPair(id.getResult()["instrument"]);
            }
        }
Exemplo n.º 4
0
        private void getCodeDistributionBtn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "timeframe", "normalizedDifference" }, dataminingDb.getInfo());

            id.ShowDialog();

            Dictionary <string, string> parameters = id.getResult();

            if (id.isValidResult())
            {
                string msg = dataminingDb.getOutcomeCodeDistribution(double.Parse(parameters["normalizedDifference"], CultureInfo.InvariantCulture), Convert.ToInt32(parameters["timeframe"]), parameters["instrument"]);
                MessageBox.Show(msg);
            }
        }
Exemplo n.º 5
0
        private void outcomeCode_btn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "timeframe", "normalizedDifference" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                new Thread(delegate() {
                    Dictionary <string, string> parameters = id.getResult();
                    dataminingDb.addOutcomeCode(double.Parse(parameters["normalizedDifference"], CultureInfo.InvariantCulture), Convert.ToInt32(parameters["timeframe"]), parameters["instrument"]);
                }).Start();
            }
        }
Exemplo n.º 6
0
        private void outcome_btn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "timeframe" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                new Thread(delegate() {
                    Dictionary <string, string> parameters = id.getResult();
                    dataminingDb.addOutcome(Convert.ToInt32(parameters["timeframe"]), parameters["instrument"]);
                }).Start();
            }
        }
Exemplo n.º 7
0
        private void indicator_ma_btn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "timeframe" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                new Thread(delegate() {
                    Dictionary <string, string> parameters = id.getResult();
                    dataminingDb.addIndicator(new MovingAverageIndicator(Convert.ToInt64(parameters["timeframe"])), parameters["instrument"], "mid");
                }).Start();
            }
        }
Exemplo n.º 8
0
        private void indicator_volume_btn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "timeframe", "samplingrate", "stepsize" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                new Thread(delegate() {
                    Dictionary <string, string> parameters = id.getResult();
                    dataminingDb.addIndicator(new VolumeAtPriceIndicator(Convert.ToInt64(parameters["timeframe"]), double.Parse(parameters["stepsize"], CultureInfo.InvariantCulture), Convert.ToInt64(parameters["samplingrate"])), parameters["instrument"], "mid");
                }).Start();
            }
        }
Exemplo n.º 9
0
        private void indicator_time_btn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                new Thread(delegate() {
                    Dictionary <string, string> parameters = id.getResult();
                    dataminingDb.addIndicator(new TimeOpeningHoursIndicator(), parameters["instrument"], "mid");
                }).Start();
            }
        }
Exemplo n.º 10
0
        private void save_btn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Save data?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument" }, dataminingDb.getInfo());
                id.ShowDialog();

                if (id.isValidResult())
                {
                    new Thread(delegate()
                    {
                        dataminingDb.savePair(id.getResult()["instrument"]);
                    }).Start();
                }
            }
        }
Exemplo n.º 11
0
        private void import_btn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Import data?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument" }, dataminingDb.getInfo());
                id.ShowDialog();

                if (id.isValidResult())
                {
                    new Thread(delegate()
                    {
                        dataminingDb.importPair(id.getResult()["instrument"], 0, Timestamp.getNow(), sourceDatabase);
                    }).Start();
                }
            }
        }
Exemplo n.º 12
0
        private void metaIndicatorSum_btn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "fieldsArrayBy|", "wightArrayBy|", "fieldname" }, dataminingDb.getInfo());

            id.ShowDialog();

            if (id.isValidResult())
            {
                new Thread(delegate() {
                    Dictionary <string, string> parameters = id.getResult();

                    List <double> wights = new List <double>();
                    foreach (string s in parameters["wightArrayBy|"].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                    {
                        wights.Add(double.Parse(s, CultureInfo.InvariantCulture));
                    }

                    string[] fieldnames = parameters["fieldsArrayBy|"].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    dataminingDb.addMetaIndicatorSum(fieldnames, wights.ToArray(), parameters["fieldname"], parameters["instrument"]);
                }).Start();
            }
        }
Exemplo n.º 13
0
        private void maxPpOutcomeCodeBtn_Click(object sender, EventArgs e)
        {
            DataminingInputDialog id = new DataminingInputDialog(new string[] { "instrument", "outcomeCodeId" }, dataminingDb.getInfo());

            id.ShowDialog();

            long operationSum    = 0;
            int  operationsCount = 0;

            if (id.isValidResult())
            {
                string instrument = id.getResult()["instrument"];
                string outcomeId  = id.getResult()["outcomeCodeId"];

                string folderPath = Config.startupPath + "/analysis/";
                if (Directory.Exists(folderPath) == false)
                {
                    Directory.CreateDirectory(folderPath);
                }

                string graphFolderPath = folderPath + "ppForIndicators-" + outcomeId + "/";
                Directory.CreateDirectory(graphFolderPath);

                string indicatorListFilename = folderPath + "ppForIndicators-" + outcomeId + ".csv";
                if (File.Exists(indicatorListFilename) == false)
                {
                    writeTextToFile(indicatorListFilename, "OverHalf;MaxDiff;Direction;LinRegr;LogRegr;Indicator" + Environment.NewLine);
                }

                //Start some threads for
                for (int threadId = 0; threadId < 2; threadId++) //Todo: Do 4 threads
                {
                    new Thread(delegate()
                    {
                        while (true)
                        {
                            try
                            {
                                Stopwatch watch = new Stopwatch();
                                watch.Start();

                                WalkerIndicator indicator = IndicatorGenerator.getRandomIndicator();
                                string indicatorId        = "mid-" + indicator.getName();

                                Logger.log("Start indicator: " + indicatorId, "maxPp");

                                setState("Max pp: avg" + Math.Round(operationSum / 1000d / (operationsCount != 0 ? operationsCount : 1)) + "s" + " n" + operationsCount);

                                try {
                                    dataminingDb.addIndicator(indicator, instrument, "mid");
                                } catch (IndicatorNeverValidException)
                                {
                                    writeTextToFile(indicatorListFilename, "x;x;x;" + indicatorId + Environment.NewLine);
                                    Logger.log("Invalid Indicator " + indicatorId, "maxPp");
                                    continue;
                                }

                                Logger.log("Get info", "maxPp");
                                DistributionRange range = dataminingDb.getInfo(indicatorId).ranges["5"];

                                SampleOutcomeCodeExcelGenerator excel = new SampleOutcomeCodeExcelGenerator(graphFolderPath + indicatorId + ".xls");

                                Logger.log("Start sampling", "maxPp");
                                double[] ppMethod1 = dataminingDb.getOutcomeCodeIndicatorSampling(excel, indicatorId, 20, range, outcomeId, instrument);

                                excel.FinishDoc();

                                /*double[][] inputsTraining = new double[0][], outputsTraining = new double[0][];
                                 * dataminingDb.getInputOutputArrays(new string[] { indicatorId }, outcomeId, instrument, ref inputsTraining, ref outputsTraining, DataGroup.All, 1000 * 20, 0);
                                 *
                                 * double[][] inputsTest = new double[0][], outputsTest = new double[0][];
                                 * dataminingDb.getInputOutputArrays(new string[] { indicatorId }, outcomeId, instrument, ref inputsTest, ref outputsTest, DataGroup.All, 5000, 1);
                                 *
                                 * double ppMethod2 = PredictivePowerAnalyzer.getPredictivePowerWithMl(inputsTraining, outputsTraining, inputsTest, outputsTest, MLMethodForPPAnalysis.LinearRegression);
                                 *
                                 * double ppMethod3 = PredictivePowerAnalyzer.getPredictivePowerWithMl(inputsTraining, outputsTraining, inputsTest, outputsTest, MLMethodForPPAnalysis.LogRegression);*/

                                Logger.log("write to file", "maxPp");
                                //over 0.5, maxDiff, direction
                                string resultLine = ppMethod1[0] + ";" + ppMethod1[1] + ";" + ppMethod1[2] + ";" + "ni" + ";" + "ni" + ";" + indicatorId;
                                writeTextToFile(indicatorListFilename, resultLine + Environment.NewLine);
                                Logger.sendImportantMessage(DateTime.Now.ToShortTimeString() + " - " + resultLine);

                                Logger.log("remove datasets", "maxPp");
                                dataminingDb.removeDataset(indicatorId, instrument);

                                watch.Stop();
                                operationSum += watch.ElapsedMilliseconds;
                                operationsCount++;
                            }
                            catch {
                                Logger.log("Error in thread method", "maxPp");
                            }
                        }
                    }).Start();
                }
            }
        }