public List <PredictionTransfer> GetPrediction(string symbol, SymbolTransfer coinTicker) { List <PredictionTransfer> predictionList = new List <PredictionTransfer>(); //1 - List models available for symbol var symbolPair = Helper.GetSymbolPair(symbol); var rootFolder = Environment.CurrentDirectory + "/aiModel/" + symbolPair + "/"; var modelPathList = Directory.GetFiles(rootFolder, symbol + "*", SearchOption.AllDirectories); if (modelPathList.Length == 0) { return(predictionList); } //3 - Iterate throw model and fire prediction foreach (var modelPath in modelPathList) { PredictionTransfer prediction = new PredictionTransfer(); var fromIndex = Path.GetFileName(modelPath).IndexOf("-") + 1; var toIndex = Path.GetFileName(modelPath).Length - fromIndex - 4; prediction.ModelName = Path.GetFileName(modelPath).Substring(fromIndex, toIndex); prediction.FuturePrice = Math.Round(CalculatePrediction(coinTicker, modelPath).FuturePrice, 2); predictionList.Add(prediction); } return(predictionList); }
public List <PredictionTransfer> GetPrediction([FromBody] System.Text.Json.JsonElement data) { //0 - Deserialize the JSON Object List <ModelInput> intradayList = JsonConvert.DeserializeObject <List <ModelInput> >(data.ToString()); List <PredictionTransfer> predictionList = new List <PredictionTransfer>(); if (intradayList.Count == 0) { return(predictionList); } //1 - Add RSI and MACD TradeIndicator.CalculateIndicator(ref intradayList); //2 - List models available var rootFolder = Environment.CurrentDirectory + "/AI/"; var modelPathList = Directory.GetFiles(rootFolder, "*", SearchOption.AllDirectories); if (modelPathList.Length == 0) { return(predictionList); } //3 - Iterate throw model and fire prediction foreach (var modelPath in modelPathList) { PredictionTransfer prediction = new PredictionTransfer(); var fromIndex = Path.GetFileName(modelPath).IndexOf("-") + 1; var toIndex = Path.GetFileName(modelPath).Length - fromIndex - 4; prediction.ModelName = Path.GetFileName(modelPath).Substring(fromIndex, toIndex); prediction.Future = CalculatePrediction(intradayList.Last(), modelPath).Future; prediction.Rsi = intradayList.Last().Rsi; prediction.Macd = intradayList.Last().Macd; prediction.MacdHist = intradayList.Last().MacdHist; prediction.MacdSign = intradayList.Last().MacdSign; predictionList.Add(prediction); } return(predictionList); }