public ActualPairsController(PoloniexMarket poloniexMarket, BittrexMarket bittrexMarket, ExmoMarket exmoMarket, PairsAnalysator pairsAnalysator, BinanceMarket binanceMarket, LivecoinMarket livecoinMarket)
 {
     Console.WriteLine("HELLO FROM Controller");
     _exmoMarket      = exmoMarket;
     _poloniexMarket  = poloniexMarket;
     _bittrexMarket   = bittrexMarket;
     _pairsAnalysator = pairsAnalysator;
     _binanceMarket   = binanceMarket;
     _livecoinMarket  = livecoinMarket;
 }
Ejemplo n.º 2
0
        private static void CreateCsv(string symbol)
        {
            //0 - Create a StringBuilder output
            var csv = new StringBuilder();

            //1 - Add header to output csv
            PropertyInfo[] propertyInfos;
            propertyInfos = typeof(CoinTransfer).GetProperties();
            var headerLine = "";

            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                headerLine += propertyInfo.Name + ",";
            }
            headerLine = headerLine.Substring(0, headerLine.Length - 1);
            csv.Append(headerLine);
            csv.AppendLine();

            //2-Actract data from Binance API and push to output
            List <CoinTransfer> binanceData = BinanceMarket.GetCoin(symbol, "1h");

            foreach (var ticker in binanceData)
            {
                csv.Append(ticker.OpenTime + "," +
                           ticker.Open.ToString().Replace(",", ".") + "," +
                           ticker.High.ToString().Replace(",", ".") + "," +
                           ticker.Low.ToString().Replace(",", ".") + "," +
                           ticker.Close.ToString().Replace(",", ".") + "," +
                           ticker.Volume.ToString().Replace(",", ".") + "," +
                           ticker.CloseTime + "," +
                           ticker.QuoteAssetVolume.ToString().Replace(",", ".") + "," +
                           ticker.NumberOfTrades.ToString().Replace(",", ".") + "," +
                           ticker.BuyBaseAssetVolume.ToString().Replace(",", ".") + "," +
                           ticker.BuyQuoteAssetVolume.ToString().Replace(",", ".") + "," +
                           ticker.Ignore.ToString().Replace(",", ".") + "," +
                           ticker.Rsi.ToString().Replace(",", ".") + "," +
                           ticker.Macd.ToString().Replace(",", ".") + "," +
                           ticker.MacdSign.ToString().Replace(",", ".") + "," +
                           ticker.MacdHist.ToString().Replace(",", ".") + "," +
                           ticker.FuturePrice.ToString().Replace(",", "."));

                csv.AppendLine();
            }

            //3 - Create output name
            string resultFileName = string.Format("{0}-TrainData.csv", symbol);

            //4 - save file to drive
            File.WriteAllText(resultFileName, csv.ToString());

            //3-save csv and print the file name
            Console.WriteLine(resultFileName);
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("press 0 to create new csv from binance API");
            Console.WriteLine("press 1 to create csv from all binance coin for specified market");
            Console.WriteLine("press 2 to create and save all model");
            Console.WriteLine("press 3 to create and save one model");
            var userEntry = Console.ReadLine();

            if (userEntry == "0")
            {
                Console.WriteLine("############ Create csv for allcoin!!! ###########");
                Console.WriteLine("Enter market : USDT or BNB or BTC ?");
                var           market     = Console.ReadLine();
                List <string> symbolList = BinanceMarket.GetSymbolList(market);
                foreach (var coinName in symbolList)
                {
                    CreateCsv(coinName);
                }
            }

            if (userEntry == "1")
            {
                Console.WriteLine("############ Create csv ###########");
                Console.WriteLine("Enter valide coin pair value");
                var coin = Console.ReadLine();
                CreateCsv(coin);
            }


            if (userEntry == "2")
            {
                Console.WriteLine("############ Create and save all model ###########");
                Console.ReadLine();

                //List all csv available
                var rootFolder    = Environment.CurrentDirectory + "/Csv/";
                var modelPathList = Directory.GetFiles(rootFolder, "*", SearchOption.AllDirectories);
                foreach (var coinPath in modelPathList)
                {
                    if (Path.GetFileName(coinPath).IndexOf("-") < 0)
                    {
                        continue;
                    }
                    CreateModel(coinPath);
                }

                Console.WriteLine("Models completed, press any key to exit....");
                Console.ReadLine();
            }

            if (userEntry == "3")
            {
                Console.WriteLine("############ Create and save one model ###########");
                Console.WriteLine("Enter valide coin pair value");
                var coin = Console.ReadLine();

                //List all csv available
                var rootFolder    = Environment.CurrentDirectory + "/Csv/";
                var modelPathList = Directory.GetFiles(rootFolder, "*", SearchOption.AllDirectories);

                foreach (var coinPath in modelPathList)
                {
                    var fileName = Path.GetFileName(coinPath);
                    var symbol   = fileName.Substring(0, fileName.IndexOf("-"));
                    if (symbol == coin)
                    {
                        CreateModel(coinPath);
                    }
                }

                Console.WriteLine("Models completed, press any key to exit....");
                Console.ReadLine();
            }
        }