コード例 #1
0
        public IHttpActionResult GetPredictedStockHistory(int id)
        {
            PredictedStockHistory predictedStockHistory = db.PredictedStockHistories.Find(id);

            if (predictedStockHistory == null)
            {
                return(NotFound());
            }

            return(Ok(predictedStockHistory));
        }
コード例 #2
0
        public IHttpActionResult PostPredictedStockHistory(PredictedStockHistory predictedStockHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PredictedStockHistories.Add(predictedStockHistory);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = predictedStockHistory.Id }, predictedStockHistory));
        }
コード例 #3
0
        public IHttpActionResult DeletePredictedStockHistory(int id)
        {
            PredictedStockHistory predictedStockHistory = db.PredictedStockHistories.Find(id);

            if (predictedStockHistory == null)
            {
                return(NotFound());
            }

            db.PredictedStockHistories.Remove(predictedStockHistory);
            db.SaveChanges();

            return(Ok(predictedStockHistory));
        }
コード例 #4
0
        private void savePredictedStockHistory(List <StockHistory> history, int id, NNPredictor predictor)
        {
            int size = parameters.LagWindowSize;

            for (int i = 0; i < history.Count - size; i++)
            {
                var output    = predictor.Predict(history.GetRange(i, size));
                var predicted = new PredictedStockHistory
                {
                    Date    = history[i + size].Date,
                    Close   = output[0][0],
                    StockId = id
                };
                db.PredictedStockHistories.Add(predicted);
            }
        }