public IHttpActionResult GetPredictedStockHistory(int id) { PredictedStockHistory predictedStockHistory = db.PredictedStockHistories.Find(id); if (predictedStockHistory == null) { return(NotFound()); } return(Ok(predictedStockHistory)); }
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)); }
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)); }
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); } }