Ejemplo n.º 1
0
 public Sploders()
 {
     m_api          = new ExchangeSharpApi(ExchangeSet.All);
     m_rawGainers24 = new SortedDictionary <DateTime, Dictionary <string, CoinMarketCapTicker> >();
     m_cmc          = new CoinMarketCapApi();
     m_maker        = new CandlestickMaker();
 }
Ejemplo n.º 2
0
        /*public void GainersTask()
         * {
         *  var myExchanges = new List<string>() { "Cryptopia", "YoBit", "Livecoin", "HitBTC", "Poloniex", "Bleutrade", "Kucoin", "Bittrex", "Huobi", "Binance", "Bithumb", "Kraken", "Bitfinex", "Okex", "Tux Exchange", "Nanex", "EtherDelta (ForkDelta)", "Waves Decentralized Exchange" };
         *
         *  while (true)
         *  {
         *      Console.WriteLine("\n---Biggest Gainers 1h---");
         *      var gainers1h = BiggestGainers1h();
         *      foreach (var t in gainers1h)
         *      {
         *          var mr = GetMarkets(t.name);
         *          var exchanges = mr.Select(m => m.exchange).Distinct();
         *          if (exchanges.Intersect(myExchanges).Count() > 0)
         *          {
         *              Console.WriteLine(t.ToString());
         *          }
         *      }
         *
         *      Console.WriteLine("\n---Biggest Gainers 24h---");
         *      var gainers24h = BiggestGainers24h();
         *      foreach (var t in gainers24h)
         *      {
         *          var mr = GetMarkets(t.name);
         *          var exchanges = mr.Select(m => m.exchange).Distinct();
         *          if (exchanges.Intersect(myExchanges).Count() > 0)
         *          {
         *              Console.WriteLine(t.ToString());
         *          }
         *      }
         *
         *      Thread.Sleep(60000);
         *  }
         * }*/

        private void DisplayExchangesForGainers()
        {
            var uniqueExchanges = new HashSet <string>();

            // Biggest 1-HOUR gainers from CoinMarketCap
            var gainers1h = m_cmc.GetBiggestGainers1h();

            uniqueExchanges.Clear();
            foreach (var t in gainers1h)
            {
                var mr = CoinMarketCapApi.GetMarkets(t.name);
                mr.Select(m => m.exchange).ToList().ForEach(exch => uniqueExchanges.Add(exch));
            }
            Console.WriteLine("\n---Exchanges for Biggest Gainers 1h---");
            uniqueExchanges.ToList().ForEach(exch => Console.WriteLine(exch));

            // Biggest 24-HOUR gainers from CoinMarketCap
            var gainers24h = m_cmc.GetBiggestGainers24h();

            uniqueExchanges.Clear();
            foreach (var t in gainers24h)
            {
                var mr = CoinMarketCapApi.GetMarkets(t.name);
                mr.Select(m => m.exchange).ToList().ForEach(exch => uniqueExchanges.Add(exch));
            }
            Console.WriteLine("\n---Exchanges for Biggest Gainers 24h---");
            uniqueExchanges.ToList().ForEach(exch => Console.WriteLine(exch));
        }
Ejemplo n.º 3
0
        // Display the list of CoinMarketCap rankings by MARKET CAP (ignoring any zero-market-cap coins)
        static void DisplayCoinMarketCapRankings()
        {
            // Get CoinMarketCap rankings
            var cmcap = new CoinMarketCapApi();

            cmcap.Test();
        }
Ejemplo n.º 4
0
        // Display biggest gainers from CoinMarketCap
        private void DisplayGainers(int limit = 50)
        {
            var g24 = m_cmc.GetBiggestGainers24h(limit);

            foreach (var t in g24)
            {
                var mr = CoinMarketCapApi.GetMarkets(t.name);
                var marketExchanges = mr.Select(m => m.exchange).Distinct();
                Console.WriteLine("{0,4} {1,-7}  {2,10:0}  1h:{3,6:0.00}%  24h:{4,6:0.00}%  7d:{5,6:0.00}%  {6}", t.rank, t.symbol, t.market_cap_usd, t.percent_change_1h, t.percent_change_24h, t.percent_change_7d, string.Join('|', marketExchanges));
            }
        }
Ejemplo n.º 5
0
 // Sort the CoinMarketCap coins by their % change (1h, 24h, 7d)
 static void CoinMarketCapGainersLosers()
 {
     var cmcap      = new CoinMarketCapApi();
     var rank       = cmcap.GetRankings();
     var gainers1h  = rank.OrderByDescending(t => t.percent_change_1h);
     var gainers24h = rank.OrderByDescending(t => t.percent_change_24h);
     var gainers7d  = rank.OrderByDescending(t => t.percent_change_7d);
     var losers1h   = rank.OrderBy(t => t.percent_change_1h);
     var losers24h  = rank.OrderBy(t => t.percent_change_24h);
     var losers7d   = rank.OrderBy(t => t.percent_change_7d);
 }
Ejemplo n.º 6
0
        public void GainersTask(bool display = false)
        {
            var headers = CoinMarketCapTicker.CsvHeaders + ",Exchanges";
            var writer  = GFile.CreateOutputFile("sploders_raw", headers);

            if (display)
            {
                Console.WriteLine(headers);
            }

            while (true)
            {
                var g24 = m_cmc.GetBiggestGainers24h();

                var now = DateTime.Now;
                m_rawGainers24[now] = new Dictionary <string, CoinMarketCapTicker>();
                int count = 0;
                foreach (var t in g24)
                {
                    m_rawGainers24[now][t.symbol] = t;

                    var mr = CoinMarketCapApi.GetMarkets(t.name);
                    var marketExchanges = mr.Select(m => m.exchange).Distinct();
                    //var mr = CoinMarketCapApi.GetMarkets(t.name, removeDuplicates: true);
                    //var marketExchanges = mr.Select(x => x.pair);
                    var exchanges = marketExchanges.Intersect(m_workingExchanges);
                    if (exchanges.Count() > 0)
                    {
                        var exchangesString = string.Join('|', exchanges);
                        var output          = string.Format("{0},{1}", t.ToCsv(), exchangesString);
                        if (display)
                        {
                            Console.WriteLine(output);
                        }
                        writer.WriteLine(output);
                        ++count;
                    }
                }
                writer.FlushAsync();
                var timeString = now.ToString("yyyy-MM-dd HH:mm:ss");
                Console.WriteLine("     {0}  {1} symbols output", timeString, count);

                Thread.Sleep(40000);
            }
        }
Ejemplo n.º 7
0
        static Dictionary <string, List <CoinMarketCapTicker> > m_cmcTickers;      // CoinMarketCap tickers
        static void ThreadUpdateCoinMarketCapRankings()
        {
            var cmcapi = new CoinMarketCapApi();     // create CoinMarketCap API object

            var g1 = cmcapi.GetGlobalData();

            Console.WriteLine(g1);

            while (true)
            {
                var rank = cmcapi.GetRankings();
                //var gainers1h = rank.OrderByDescending(t => t.percent_change_1h);
                if (m_cmcTickers == null)           // first time through, create the dictionary to store CoinMarketCap data
                {
                    m_cmcTickers = new Dictionary <string, List <CoinMarketCapTicker> >();
                    foreach (var t in rank)
                    {
                        m_cmcTickers[t.id] = new List <CoinMarketCapTicker>();
                        m_cmcTickers[t.id].Add(t);
                    }
                }
                else
                {
                    Console.WriteLine(new string('=', 180));
                    foreach (var t in rank)
                    {
                        if (!m_cmcTickers.ContainsKey(t.id))                        // if we have not yet stored this symbol...
                        {
                            m_cmcTickers[t.id] = new List <CoinMarketCapTicker>();  // create a new list for this symbol's tickers
                            m_cmcTickers[t.id].Add(t);
                        }
                        else
                        {
                            var last = m_cmcTickers[t.id].Last();       // check the last ticker we added to the list for this symbol
                            if (last.last_updated != t.last_updated)    // only add to our stored tickers if the "last_updated" field has changed
                            {
                                m_cmcTickers[t.id].Add(t);
                                Console.WriteLine("{0} {1} {2}", last.last_updated, t.last_updated, t);
                            }
                        }
                    }
                }
                Thread.Sleep(20000);                // sleep for 20 seconds
            }
        }
Ejemplo n.º 8
0
        // Display market cap rank (CoinMarketCap) for each trade symbol (both ACTIVE and INACTIVE) in "marketmaker_xsynbols.DF.csv" file
        // where maxRank is the maximum rank # (by market cap) used to filter the returned/displayed CoinMarketCapTicker objects
        public CoinMarketCapTickerList DisplayRanks(int maxRank = 500)
        {
            var tickers = new CoinMarketCapTickerList();
            var cmc     = new CoinMarketCapApi();

            foreach (var ts in m_tradeSymbols)
            {
                var currency = ApiHelper.GetBaseCurrency(ts.GlobalSymbol);
                var t        = cmc.GetRankingTicker(currency);
                if (t == null)
                {
                    Console.WriteLine("*** Rank not found for {0}", currency);
                }
                else
                {
                    if (t.rank <= maxRank)
                    {
                        t.Print();
                        tickers.Add(t);
                    }
                }
            }
            return(tickers);
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            Console.WriteLine("\n*** WELCOME TO AGGREGATOR ***\n");

            var apiXS = new ExchangeSharpRestApi();

            //apiXS.Gator("ETH-USD", amountRequested: 200, bips:125);
            apiXS.Test();

            //CryptoWebSocketApis.GeminiWebSocket.TestGeminiTickers_marketdata();
            Console.WriteLine("(Back in MAIN)");
            Console.ReadKey();
            return;

            //CryptoTools.Cryptography.Cryptography.EncryptFile("X:/Users/Trader/Documents/hat_apis.json", "/Users/michael/Documents/hat_apis.enc", pw);    // encrypt api key file
            m_credentialsFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "system.apis.enc");   // read ".enc" file from application path
            m_pw = @"myKey123";

            m_factory = new ApiFactory(m_credentialsFile, m_pw);


            /*TradeBittrexArbs.InitializeApi(credentialsFile, pw);
             * TradeBittrexArbs.Test();
             * TradeBinanceArbs.InitializeApi(credentialsFile, pw);
             * TradeBinanceArbs.Test();
             * TradeGdaxArbs.InitializeApi(credentialsFile, pw);
             * TradeGdaxArbs.Test();
             * TradeKraken.InitializeApi(credentialsFile, pw);
             * TradeKraken.Test();
             * TradeGemini.InitializeApi(credentialsFile, pw);
             * TradeGemini.Test();*/

            // Get CoinMarketCap rankings
            var cmcap = new CoinMarketCapApi();

            cmcap.Test();

            /*var rank = cmcap.GetRankings();
             * var gainers1h = rank.OrderByDescending(t => t.percent_change_1h);
             * var gainers24h = rank.OrderByDescending(t => t.percent_change_24h);
             * var gainers7d = rank.OrderByDescending(t => t.percent_change_7d);
             * var losers1h = rank.OrderBy(t => t.percent_change_1h);
             * var losers24h = rank.OrderBy(t => t.percent_change_24h);
             * var losers7d = rank.OrderBy(t => t.percent_change_7d);*/

            //BinanceTotals();
            //var mgr = new CryptoTools.SymbolManager();
            //SellBinance(0.50M, "bnb");

            /*DisplayBalances("KRAKEN", "btcusd");
             * DisplayBalances("BITFINEX", "btcusd");
             * DisplayBalances("BINANCE", "btcusdt");
             * DisplayBalances("BITTREX", "btcusdt");
             * DisplayBalances("POLONIEX", "btcusdt");
             * DisplayBalances("GDAX", "btcusd");
             *
             * try
             * {
             *  GdaxRestApi api = m_factory.Get("GDAX") as GdaxRestApi;
             *  api.PrintCoinbaseAccounts().Wait();
             * }
             * catch (Exception ex)
             * {
             *  Console.WriteLine("\nGDAX Coinbase Error: {0}", ex.Message);
             * }*/



            Console.Write("\n\nPress any key to exit... ");
            Console.ReadKey();
            return;

            //BinanceArbs.InitializeApi();

            TradeBinanceArbs.GetBalances(out decimal initTotalBtc, out decimal initTotalUsdt, true);
            Console.WriteLine("\n{0}    {1} BTC   {2} USDT\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), initTotalBtc, initTotalUsdt);

            // [LocalTime, exch1UpdateTime, exch1BitCoinPrice, exch2UpdateTime, exch2BitCoinPrice]

            List <string> symbols = new List <string>();

            symbols.AddRange(new List <string>()
            {
                "ethusdt", "btcusdt"
            });
            symbols.AddRange(new List <string>()
            {
                "neousdt", "neoeth", "neobtc"
            });
            symbols.AddRange(new List <string>()
            {
                "bnbusdt", "bnbeth", "bnbbtc"
            });
            symbols.AddRange(new List <string>()
            {
                "qtumusdt", "qtumeth", "qtumbtc"
            });
            symbols.AddRange(new List <string>()
            {
                "ltcusdt", "ltceth", "ltcbtc"
            });
            symbols.AddRange(new List <string>()
            {
                "bccusdt", "bcceth", "bccbtc"
            });
            symbols.AddRange(new List <string>()
            {
                "adausdt", "adaeth", "adabtc"
            });

            List <string> streams = new List <string>();

            streams.Add("ticker");
            streams.Add("aggTrade");
            TradeBinanceArbs.BinanceStreams(streams.ToArray(), symbols.ToArray());

            //GdaxTickers();
            //GeminiTickers();
            //BinanceTickers();
            //BitfinexTickers();
        }