Exemple #1
0
        static void CreateCurrencyPairFile()
        {
            string pathname = Folders.system_path("CURRENCY_PAIRS.TXT");

            using (var f = new StreamWriter(pathname))
            {
                f.WriteLine("Exchange,Symbol,ExchangeSymbol,ExchangeLeft,ExchangeRight");
                foreach (var exchange in Crypto.Exchanges.Values)
                {
                    var symbols = exchange.SymbolList;
                    foreach (var s in symbols)
                    {
                        var exch = Crypto.GetExch(exchange.Name);
                        var zcp  = ZCurrencyPair.FromSymbol(s, exch);
                        if (zcp == null)
                        {
                            continue;
                        }
                        cout("{0},{1}", exch, zcp);
                        f.WriteLine(string.Format("{0},{1}", exch, zcp));
                    }
                    cout("--------------------------------------------------------------------");
                }
                cout("\nCurrency pairs output to file: '{0}'", pathname);
            }
        }
Exemple #2
0
        private CurrencyPair GetCurPair(string pair)
        {
            //var cp = ZCurrencyPair.GetLeftRight(pair, CryptoExch.POLONIEX);
            var zcp = ZCurrencyPair.FromSymbol(pair, CryptoExch.POLONIEX);

            Clients.Poloniex.CurrencyPair curpair = new CurrencyPair(currency_name: zcp.Right, coin_name: zcp.Left);   // NOTICE these are in reverse order (currency, coin)
            return(curpair);
        }
        // Return a dictionary that maps each Binance currency-pair symbol (string) to a ZCurrencyPair object
        public static Dictionary <string, ZCurrencyPair> GetBinancePairs()
        {
            Dictionary <string, ZCurrencyPair> result = new Dictionary <string, ZCurrencyPair>();

            foreach (var s in binance.SymbolList)
            {
                result.Add(s, ZCurrencyPair.FromSymbol(s, CryptoExch.BINANCE));
            }
            return(result);
        }
 // Given an updated set of exchange-specific symbols, update the CurrencyPairs map
 protected void UpdateCurrencyPairsFromSymbols()
 {
     //SupportedSymbols = new Dictionary<string, ZCurrencyPair>();
     CurrencyPairs.Clear();
     foreach (var s in m_symbolList)
     {
         var exch = Crypto.GetExch(Name);
         var pair = ZCurrencyPair.FromSymbol(s, exch);
         CurrencyPairs.Add(pair);
     }
 }
        public CryptoExchange(string name)
        {
            Name     = name;
            Exch     = Crypto.GetExch(name);
            Exchange = Crypto.Exchanges[Exch];
            var symbols = Exchange.GetSymbolList(false);

            foreach (var s in symbols)
            {
                var pair = ZCurrencyPair.FromSymbol(s, Exch);
                m_pairs[pair.Symbol] = pair;                            // Use the OneChain format symbol (ex: "BTC_USD")
            }
        }
Exemple #6
0
        public static void GetSymbolsOnMultipleExchanges()
        {
            var dict = new Dictionary <string, List <ZCurrencyPair> >();
            //var exchanges = new string[] { "BINANCE", "BITFINEX", "BITSTAMP", "HITBTC", "GEMINI", "ITBIT", "BITTREX", "GDAX", "POLONIEX" };
            var exchanges = new string[] { "BINANCE", "BITFINEX", "BITSTAMP", "HITBTC", "GEMINI", "ITBIT", "BITTREX", "POLONIEX" };

            foreach (var e in exchanges)
            {
                cout("\n---{0}---", e);
                var exchEnum = (CryptoExch)Enum.Parse(typeof(CryptoExch), e);
                var exch     = Exchanges[exchEnum];
                foreach (var s in exch.SymbolList)
                {
                    var zcp = ZCurrencyPair.FromSymbol(s, exchEnum);
                    //cout(zcp.Symbol);
                    Console.Write("{0}, ", zcp.Symbol);
                    if (dict.ContainsKey(zcp.Symbol))
                    {
                        dict[zcp.Symbol].Add(zcp);
                    }
                    else
                    {
                        dict[zcp.Symbol] = new List <ZCurrencyPair>()
                        {
                            zcp
                        };
                    }
                }
                Console.WriteLine();
            }
            cout("\n");
            foreach (var s in dict.Keys)
            {
                int n = dict[s].Count();
                if (n >= 4)
                {
                    decimal maxbid = decimal.MinValue;
                    decimal minask = decimal.MaxValue;
                    cout("---{0} ({1})", s, n);
                    foreach (var zcp in dict[s])
                    {
                        /*var ticker = Exchanges[zcp.Exchange].GetTicker(zcp.ExchangeSymbol);
                         * cout("{0} {1}", zcp.Exchange.ToString(), ticker.ToString());
                         * if (ticker.Bid > maxbid) maxbid = ticker.Bid;
                         * if (ticker.Ask < minask) minask = ticker.Ask;*/
                    }
                    cout("b:{0}  a:{1}     {2}\n", maxbid, minask, maxbid > minask ? (maxbid - minask).ToString() : "");
                }
            }
            return;
        }
Exemple #7
0
        // We'll cache this translation of pair (string) to GDAX ProductPair object for faster performance
        public Clients.GDAX.ProductType GetProductPair(string pair)
        {
            Clients.GDAX.ProductType productPair;
            if (m_productPairs.TryGetValue(pair, out productPair))
            {
                return(productPair);
            }

            var    zcp     = ZCurrencyPair.FromSymbol(pair, CryptoExch.GDAX);
            string strEnum = zcp.ExchangeSpecificLeft + zcp.ExchangeSpecificRight;

            //var li = ZCurrencyPair.GetLeftRight(pair, CryptoExch.GDAX);
            //string strEnum = li[0] + li[1];
            //string strEnum = "";
            productPair          = (Clients.GDAX.ProductType)Enum.Parse(typeof(Clients.GDAX.ProductType), strEnum, ignoreCase: true);
            m_productPairs[pair] = productPair;
            return(productPair);
        }