Exemplo n.º 1
0
        private static CoinPrediction PredictFuturePrice(SymbolTransfer coin, ITransformer model)
        {
            MLContext      mlContext          = new MLContext();
            var            predictionFunction = mlContext.Model.CreatePredictionEngine <CoinData, CoinPrediction>(model);
            CoinPrediction prediction         = predictionFunction.Predict(new CoinData
            {
                Volume   = (float)coin.Volume,
                Open     = (float)coin.OpenPrice,
                Rsi      = (float)coin.Rsi,
                MacdHist = (float)coin.MacdHist,
            });

            return(prediction);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Calculate prediction with default Model (Fast tree for home page)
        /// </summary>
        /// <param name="coinList">The list of coinTicketTransfer</param>
        /// <returns>void</returns>
        internal static void CalculatePredictionDefaultModel(string symbol, ref QuotationTransfer coin)
        {
            if (CheckModelExist(symbol) == true)
            {
                string modelPath = Environment.CurrentDirectory + "/aiModel/" + symbol + "-Fast Tree.zip";

                //Load model
                ITransformer loadedModel = LoadModel(modelPath);

                //Predict future price
                MLContext      mlContext          = new MLContext();
                var            predictionFunction = mlContext.Model.CreatePredictionEngine <CoinData, CoinPrediction>(loadedModel);
                CoinPrediction prediction         = predictionFunction.Predict(new CoinData
                {
                    Volume   = (float)coin.Volume,
                    Open     = (float)coin.Open,
                    Rsi      = (float)coin.Rsi,
                    MacdHist = (float)coin.MacdHist,
                });

                coin.FuturePrice = prediction.FuturePrice;
            }
        }