Esempio n. 1
0
        public SymbolTransfer GetSymbolData(string symbol, string interval)
        {
            string apiUrl = string.Format("https://api.binance.com/api/v1/ticker/24hr?symbol={0}", symbol);

            //Get data from Binance API
            SymbolTransfer coin = HttpHelper.GetApiData <SymbolTransfer>(new Uri(apiUrl));

            //Add indicator RSI / MACD
            QuotationTransfer ct = GetIndicator(symbol, "1d");

            coin.Rsi      = ct.Rsi;
            coin.Macd     = ct.Macd;
            coin.MacdSign = ct.MacdSign;
            coin.MacdHist = ct.MacdHist;

            //Add Prediction sub list
            AIController aiController = new AIController();

            coin.Prediction = aiController.GetPrediction(symbol, coin);

            //Add short symbol
            Misc.Helper.ShortenSymbol(ref coin);

            return(coin);
        }
Esempio n. 2
0
        public List <QuotationTransfer> GetChartData(string symbol, string interval)
        {
            List <QuotationTransfer> quotation = new List <QuotationTransfer>();
            string apiUrl = string.Format("https://api.binance.com/api/v1/klines?symbol={0}&interval={1}&limit=1000", symbol, interval);

            //Get data from Binance API
            List <List <double> > coinQuotation = HttpHelper.GetApiData <List <List <double> > >(new Uri(apiUrl));

            foreach (var item in coinQuotation)
            {
                QuotationTransfer newQuotation = new QuotationTransfer()
                {
                    OpenTime            = item[0],
                    Open                = item[1],
                    High                = item[2],
                    Low                 = item[3],
                    Close               = item[4],
                    Volume              = item[5],
                    CloseTime           = item[6],
                    QuoteAssetVolume    = item[7],
                    NumberOfTrades      = item[8],
                    BuyBaseAssetVolume  = item[9],
                    BuyQuoteAssetVolume = item[10],
                    Ignore              = item[11],
                };
                quotation.Add(newQuotation);
            }

            //Add Indicators to the list
            TradeIndicator.CalculateIndicator(ref quotation);

            return(quotation);
        }
Esempio n. 3
0
        private bool GetTopIndicator(SymbolTransfer symbolTransfer)
        {
            symbolTransfer.Prediction = new List <PredictionTransfer>();
            QuotationTransfer ct = GetIndicator(symbolTransfer.Symbol, "1d");

            symbolTransfer.Rsi      = ct.Rsi;
            symbolTransfer.Macd     = ct.Macd;
            symbolTransfer.MacdSign = ct.MacdSign;
            symbolTransfer.MacdHist = ct.MacdHist;
            symbolTransfer.Prediction.Add(new PredictionTransfer()
            {
                FuturePrice = ct.FuturePrice
            });
            return(true);
        }
Esempio n. 4
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;
            }
        }