Beispiel #1
0
        private void TestNN()
        {
            var testingData = new List <List <double> >();

            var testingDataJson = Common.GetJsonFromFile();

            foreach (JArray testSet in testingDataJson["Inputs"])
            {
                var ts = new List <double>();
                for (var i = 0; i < testSet.Count(); ++i)
                {
                    ts.Add(testSet[i].Value <double>());
                }
                testingData.Add(ts);
            }

            _trainingDataMeta = testingDataJson["Meta"] as JObject;
            var outputOffset = _trainingDataMeta["OutputOffset"].Value <int>();
            var outputSize   = _trainingDataMeta["OutputSize"].Value <int>();
            var inputSize    = _trainingDataMeta["InputSize"].Value <int>();

            var inputPoints  = new PointCollection();
            var outputPoints = new PointCollection();

            for (var i = 0; i < testingData.Count; i++)
            {
                for (var j = 0; j < inputSize; ++j)
                {
                    var input  = testingData[i][j];
                    var output = j < outputSize?_nn.GenerateOutput(testingData[i])[j] : 0;

                    inputPoints.Add(new Point(i * inputSize + j, input));
                    outputPoints.Add(new Point(i * inputSize + j + outputOffset, output));
                }
            }

            OutputPlot.Clear();
            OutputPlot.LineThickness = 2.5;
            OutputPlot.ScaleXAxis    = true;
            OutputPlot.Add("Input", inputPoints, Colors.White);
            OutputPlot.Add("Output", outputPoints, Colors.Purple);
        }
Beispiel #2
0
        private async Task ShowStock(string stock)
        {
            try
            {
                var mongo            = new MongoClient("mongodb://localhost:27017");
                var db               = mongo.GetDatabase("traiding_data");
                var stockCollections = new List <string>();
                using (var cursor = await db.ListCollectionNamesAsync())
                {
                    await cursor.ForEachAsync(d => stockCollections.Add(d.ToString()));
                }


                if (!stockCollections.Contains(stock))
                {
                    MessageBox.Show($"{stock} collection doesn't exist!");
                    return;
                }

                var collection = db.GetCollection <StockData>(stock);
                var res        = (from c in collection.AsQueryable() orderby c.Date descending select c).ToList();

                var pc = new PointCollection();
                for (var i = 0; i < res.Count; ++i)
                {
                    pc.Add(new Point(i, res[i].Close - res[i].Low));
                }

                OutputPlot.Clear();
                OutputPlot.Add(stock, pc, Colors.White);
                MainTabControl_tc.SelectedItem = OutputGraph_Tab_ti;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }