Exemplo n.º 1
0
        //public static BitstampExchange Create(string key,string secret,string uid,string username)
        //{
        //    if (_instance == null)
        //    {
        //        _instance = new BitstampExchange(key, secret, uid, username);
        //    }
        //    else
        //    {
        //        if (_key == key && _secret == secret && _uid == uid && _username == username)
        //        {
        //            return _instance;
        //        }
        //        else
        //        {

        //        }
        //    }
        //    return _instance;

        //}

        public bool Subscribe(CommonLab.TradePair tp, SubscribeTypes st)
        {
            //throw new NotImplementedException();
            //订阅
            string tradingpairs = GetLocalTradingPairString(tp, st);

            if (st == SubscribeTypes.WSS)
            {
                if (_subscribedtradingpairs == null)
                {
                    _subscribedtradingpairs = new Dictionary <string, KFCC.ExchangeInterface.SubscribeInterface>();
                }
                if (_subscribedtradingpairs.ContainsKey(tradingpairs))
                {
                    //有这个订阅
                }
                else
                {
                    string raw;
                    Ticker t = GetTicker(GetLocalTradingPairString(tp), out raw);
                    Depth  d = GetDepth(GetLocalTradingPairString(tp), out raw);
                    _subscribedtradingpairs.Add(tradingpairs, new PusherHelper(tradingpairs, t, d, tp));
                    _subscribedtradingpairs[tradingpairs].TradeInfoEvent += BitstampExchange_TradeInfoEvent;
                }
            }
            if (SubscribedEvent != null)
            {
                SubscribedEvent(this, st, tp);
            }
            return(true);
        }
Exemplo n.º 2
0
 public string GetLocalTradingPairString(TradePair t, SubscribeTypes st = CommonLab.SubscribeTypes.RESTAPI)
 {
     if (t.FromSymbol.ToLower() == "bch")
     {
         return("BCC" + t.ToSymbol.ToUpper());
     }
     if (t.ToSymbol.ToLower() == "bch")
     {
         return(t.FromSymbol.ToUpper() + "BCC");
     }
     return(t.FromSymbol.ToUpper() + t.ToSymbol.ToUpper());
 }
Exemplo n.º 3
0
        public bool Subscribe(CommonLab.TradePair tp, SubscribeTypes st)
        {
            //throw new NotImplementedException();
            //订阅
            string tradingpairs = GetLocalTradingPairString(tp, st);

            if (st == SubscribeTypes.WSS)
            {
                //throw new Exception("This exchange does not support wss subscribing");
                if (_subscribedtradingpairs == null)
                {
                    _subscribedtradingpairs = new Dictionary <string, KFCC.ExchangeInterface.SubscribeInterface>();
                }
                if (_subscribedtradingpairs.ContainsKey(tradingpairs))
                {
                    //有这个订阅
                }
                else
                {
                    string raw;
                    Ticker t = GetTicker(GetLocalTradingPairString(tp), out raw);
                    Depth  d = GetDepth(GetLocalTradingPairString(tp), out raw);
                    _subscribedtradingpairs.Add(tradingpairs, new RESTHelper(tp, t, d));
                    //这里根据循环给出假事件
                    //_subscribedtradingpairs[tradingpairs].TradeInfoEvent += OkCoinExchange_TradeInfoEvent;
                }
            }
            else if (st == SubscribeTypes.RESTAPI)
            {
                if (_subscribedtradingpairs == null)
                {
                    _subscribedtradingpairs = new Dictionary <string, KFCC.ExchangeInterface.SubscribeInterface>();
                }
                if (_subscribedtradingpairs.ContainsKey(tradingpairs))
                {
                    //有这个订阅
                }
                else
                {
                    string raw;
                    Ticker t = GetTicker(GetLocalTradingPairString(tp), out raw);
                    Depth  d = GetDepth(GetLocalTradingPairString(tp), out raw);
                    _subscribedtradingpairs.Add(tradingpairs, new RESTHelper(tp, t, d));
                    //_subscribedtradingpairs[tradingpairs].TradeInfoEvent += OkCoinExchange_TradeInfoEvent;
                }
            }
            if (SubscribedEvent != null)
            {
                SubscribedEvent(this, st, tp);
            }
            return(true);
        }
Exemplo n.º 4
0
 public string GetLocalTradingPairString(TradePair t, SubscribeTypes st = CommonLab.SubscribeTypes.RESTAPI)
 {
     if (st == SubscribeTypes.WSS)
     {
         if (t.FromSymbol.ToLower() == "btc" && t.ToSymbol.ToLower() == "usd")
         {
             return("");
         }
         return(t.FromSymbol.ToLower() + t.ToSymbol.ToLower());
     }
     else if (st == SubscribeTypes.RESTAPI)
     {
         return(t.FromSymbol.ToLower() + t.ToSymbol.ToLower());
     }
     return(t.FromSymbol.ToLower() + t.ToSymbol.ToLower());
 }
Exemplo n.º 5
0
 public string GetLocalTradingPairString(TradePair t, SubscribeTypes st = CommonLab.SubscribeTypes.RESTAPI)
 {
     //if (st == SubscribeTypes.WSS)
     //{
     //    if (t.FromSymbol.ToLower() == "btc" && t.ToSymbol.ToLower() == "usd")
     //        return "";
     //    return "_" + t.FromSymbol.ToLower() + t.ToSymbol.ToLower();
     //}
     //else if (st == SubscribeTypes.RESTAPI)
     //{
     //    return t.FromSymbol.ToLower() + "_" + t.ToSymbol.ToLower();
     //}
     //if (t.FromSymbol.ToLower() == "bch")
     //    return "bcc" + t.ToSymbol.ToLower();
     //if (t.ToSymbol.ToLower() == "bch")
     //    return t.FromSymbol.ToLower()+ "bcc" ;
     return(t.FromSymbol.ToLower() + t.ToSymbol.ToLower());
 }
Exemplo n.º 6
0
 public void DisSubcribe(TradePair tp, SubscribeTypes st)
 {
     throw new NotImplementedException();
 }