Exemplo n.º 1
0
        /*public ZCurrencyPair(string symbol, CryptoExch exchange)
         * {
         *  ExchangeSymbol = symbol;
         *  Exchange = exchange;
         *  var lr = GetLeftRight(symbol, exchange);
         *  Left = lr[0];
         *  Right = lr[1];
         * }*/


        // Given a currency-pair symbol and an exchange
        // Return the ZCurrencyPair for that symbol/exchange combo
        public static ZCurrencyPair FromSymbol(string symbol, CryptoExch exchange)
        {
            ZCurrencyPair zcp;

            if (exchange == CryptoExch.KRAKEN)
            {
                zcp = ParseKrakenSymbol(symbol);
            }
            else if (exchange == CryptoExch.BITFLYER)
            {
                zcp = ParseBitFlyerSymbol(symbol);
            }
            else
            {
                var lr = GetLeftRight(symbol, exchange);
                if (lr == null)
                {
                    return(null);
                }
                else
                {
                    zcp        = new ZCurrencyPair();
                    zcp.Symbol = lr[0] + "_" + lr[1];
                    zcp.Left   = lr[0];
                    zcp.Right  = lr[1];
                    zcp.ExchangeSpecificSymbol = symbol;
                    zcp.ExchangeSpecificLeft   = zcp.Left;
                    zcp.ExchangeSpecificRight  = zcp.Right;
                }
            }

            //if (zcp != null) dout("ZCurrencyPair::FromSymbol=> {0}", zcp.ToString());

            return(zcp);
        }
Exemplo n.º 2
0
        public void Add(ZCurrencyPair pair)
        {
            if (pair == null)
            {
                return;
            }

            if (!m_pairs.ContainsKey(pair.Symbol))
            {
                m_pairs.Add(pair.Symbol, pair);
            }
        }
Exemplo n.º 3
0
 // Parse BITFLYER symbol (ignore symbols that don't match "XXX_XXX")
 // Return ZCurrencyPair
 public static ZCurrencyPair ParseBitFlyerSymbol(string symbol)
 {
     if (symbol.Length == 7 && symbol[3] == '_')
     {
         var zcp = new ZCurrencyPair();
         zcp = new ZCurrencyPair();
         zcp.ExchangeSpecificSymbol = symbol;
         zcp.Left   = symbol.Substring(0, 3);
         zcp.Right  = symbol.Substring(4);
         zcp.Symbol = zcp.Left + "_" + zcp.Right;
         return(zcp);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 4
0
 public bool ContainsValue(ZCurrencyPair currencyPair)
 {
     return(m_pairs.ContainsValue(currencyPair));
 }
Exemplo n.º 5
0
        // Parse KRAKEN symbol
        // REturn ZCurrencyPair
        public static ZCurrencyPair ParseKrakenSymbol(string symbol)
        {
            if (symbol.EndsWith(".d"))
            {
                return(null);
            }

            var zcp = new ZCurrencyPair();

            zcp.ExchangeSpecificSymbol = symbol;

            if (symbol.EndsWith("ZCAD") || symbol.EndsWith("ZEUR") || symbol.EndsWith("ZJPY") || symbol.EndsWith("ZUSD"))
            {
                zcp.ExchangeSpecificLeft  = symbol.Substring(0, symbol.Length - 4);
                zcp.ExchangeSpecificRight = symbol.Substring(symbol.Length - 4);
            }
            else if (symbol.EndsWith("CAD") || symbol.EndsWith("EUR") || symbol.EndsWith("JPY") || symbol.EndsWith("USD"))
            {
                zcp.ExchangeSpecificLeft  = symbol.Substring(0, symbol.Length - 3);
                zcp.ExchangeSpecificRight = symbol.Substring(symbol.Length - 3);
            }
            else if (symbol.EndsWith("XXBT"))
            {
                zcp.ExchangeSpecificLeft  = symbol.Substring(0, symbol.Length - 4);
                zcp.ExchangeSpecificRight = "BTC";
            }
            else if (symbol.EndsWith("XBT"))
            {
                zcp.ExchangeSpecificLeft  = symbol.Substring(0, symbol.Length - 3);
                zcp.ExchangeSpecificRight = "BTC";
            }
            else if (symbol.Length == 6)
            {
                zcp.ExchangeSpecificLeft  = symbol.Substring(0, 3);
                zcp.ExchangeSpecificRight = symbol.Substring(3);
            }
            else if (symbol.Length == 8 && symbol[0] == 'X' && symbol[4] == 'X')
            {
                zcp.ExchangeSpecificLeft  = symbol.Substring(1, 3);
                zcp.ExchangeSpecificRight = symbol.Substring(5, 3);
            }
            else if (symbol.Length == 8 && symbol[0] == 'X' && symbol[4] == 'Z')
            {
                zcp.ExchangeSpecificLeft  = symbol.Substring(1, 3);
                zcp.ExchangeSpecificRight = symbol.Substring(5, 3);
            }
            else
            {
                ErrorMessage("No valid translation for '{0}' on exchange KRAKEN", symbol);
                return(null);
            }

            zcp.Left  = zcp.ExchangeSpecificLeft;
            zcp.Right = zcp.ExchangeSpecificRight;

            if (zcp.ExchangeSpecificLeft == "XXBT")
            {
                zcp.Left = "BTC";
            }
            else if (zcp.ExchangeSpecificLeft == "XXDG")
            {
                zcp.Left = "DOGE";
            }
            else if (zcp.ExchangeSpecificLeft == "XETC")
            {
                zcp.Left = "ETC";
            }
            else if (zcp.ExchangeSpecificLeft == "XICN")
            {
                zcp.Left = "ICN";
            }
            else if (zcp.ExchangeSpecificLeft == "XLTC")
            {
                zcp.Left = "LTC";
            }
            else if (zcp.ExchangeSpecificLeft == "XREP")
            {
                zcp.Left = "REP";
            }
            else if (zcp.ExchangeSpecificLeft == "XMLN")
            {
                zcp.Left = "MLN";
            }
            else if (zcp.ExchangeSpecificLeft == "XETH")
            {
                zcp.Left = "ETH";
            }
            else if (zcp.ExchangeSpecificLeft == "XXLM")
            {
                zcp.Left = "XLM";
            }
            else if (zcp.ExchangeSpecificLeft == "XXMR")
            {
                zcp.Left = "XMR";
            }
            else if (zcp.ExchangeSpecificLeft == "XXRP")
            {
                zcp.Left = "XRP";
            }
            else if (zcp.ExchangeSpecificLeft == "XZEC")
            {
                zcp.Left = "ZEC";
            }

            if (zcp.ExchangeSpecificRight == "ZCAD")
            {
                zcp.Right = "CAD";
            }
            else if (zcp.ExchangeSpecificRight == "ZEUR")
            {
                zcp.Right = "EUR";
            }
            else if (zcp.ExchangeSpecificRight == "ZJPY")
            {
                zcp.Right = "JPY";
            }
            else if (zcp.ExchangeSpecificRight == "ZUSD")
            {
                zcp.Right = "USD";
            }

            zcp.Symbol = zcp.Left + "_" + zcp.Right;

            return(zcp);
        }