Exemplo n.º 1
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Exchange(IList <CurrencyPair> currencyPairs)
        {
            /*_currencyPairs.Add(CurrencyConstants.BtcLtc);
             * _currencyPairs.Add(CurrencyConstants.XbtLtc);
             * _currencyPairs.Add(CurrencyConstants.BtcLtcSeparated);
             * _currencyPairs.Add(CurrencyConstants.XbtLtcSeparated);
             * _currencyPairs.Add(CurrencyConstants.BtcDoge);
             * _currencyPairs.Add(CurrencyConstants.XbtDoge);
             * _currencyPairs.Add(CurrencyConstants.BtcDogeSeparated);
             * _currencyPairs.Add(CurrencyConstants.XbtDogeSeparated);*/
            ExtractCurrencyPairs(currencyPairs);
            foreach (var currencyPair in _currencyPairs)
            {
                LimitOrderBook orderBook      = new LimitOrderBook(currencyPair);
                DepthOrderBook depthOrderBook = new DepthOrderBook(currencyPair, 5);

                TradeListener      tradeListener     = new TradeListener();
                IOrderListener     orderListener     = new OrderListener();
                IOrderBookListener orderBookListener = new OrderBookListener();
                IBBOListener       bboListener       = new BBOListener();
                IDepthListener     depthListener     = new DepthListener();

                orderBook.OrderAccepted -= OnAccept;
                orderBook.OrderAccepted -= depthOrderBook.OnOrderAccepted;

                orderBook.OrderAccepted += OnAccept;
                orderBook.OrderAccepted += depthOrderBook.OnOrderAccepted;

                orderBook.OrderCancelled -= depthOrderBook.OnOrderCancelled;
                orderBook.OrderCancelled += depthOrderBook.OnOrderCancelled;

                orderBook.OrderBookChanged -= depthOrderBook.OnOrderBookChanged;
                orderBook.OrderBookChanged -= orderBookListener.OnOrderBookChanged;

                orderBook.OrderBookChanged += depthOrderBook.OnOrderBookChanged;
                orderBook.OrderBookChanged += orderBookListener.OnOrderBookChanged;

                orderBook.OrderChanged -= depthOrderBook.OnOrderChanged;
                orderBook.OrderChanged -= orderListener.OnOrderChanged;

                orderBook.OrderChanged += depthOrderBook.OnOrderChanged;
                orderBook.OrderChanged += orderListener.OnOrderChanged;

                orderBook.OrderFilled -= depthOrderBook.OnOrderFilled;
                orderBook.OrderFilled += depthOrderBook.OnOrderFilled;

                orderBook.TradeExecuted -= tradeListener.OnTrade;
                orderBook.TradeExecuted += tradeListener.OnTrade;

                depthOrderBook.BboChanged   -= bboListener.OnBBOChange;
                depthOrderBook.DepthChanged -= depthListener.OnDepthChanged;

                depthOrderBook.BboChanged   += bboListener.OnBBOChange;
                depthOrderBook.DepthChanged += depthListener.OnDepthChanged;

                _exchangeEssentialsList.AddEssentials(new ExchangeEssentials(orderBook, depthOrderBook, tradeListener,
                                                                             orderListener, depthListener, bboListener));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// parameterized constructor
        /// </summary>
        public Exchange(IList <CurrencyPair> currencyPairs, ExchangeEssentialsList exchangeEssentialsList)
        {
            //_currencyPairs.Add(CurrencyConstants.BtcLtc);
            //_currencyPairs.Add(CurrencyConstants.XbtLtc);
            //_currencyPairs.Add(CurrencyConstants.BtcLtcSeparated);
            //_currencyPairs.Add(CurrencyConstants.XbtLtcSeparated);
            ExtractCurrencyPairs(currencyPairs);
            _exchangeEssentialsList = exchangeEssentialsList;
            foreach (var exchangeEssential in _exchangeEssentialsList)
            {
                //TradeListener tradeListener = new TradeListener();
                //IOrderListener orderListener = new OrderListener();
                IOrderBookListener orderBookListener = new OrderBookListener();
                //IBBOListener bboListener = new BBOListener();
                //IDepthListener depthListener = new DepthListener();

                exchangeEssential.LimitOrderBook.OrderAccepted -= OnAccept;
                exchangeEssential.LimitOrderBook.OrderAccepted -= exchangeEssential.DepthOrderBook.OnOrderAccepted;

                exchangeEssential.LimitOrderBook.OrderAccepted += OnAccept;
                exchangeEssential.LimitOrderBook.OrderAccepted += exchangeEssential.DepthOrderBook.OnOrderAccepted;

                exchangeEssential.LimitOrderBook.OrderCancelled -= exchangeEssential.DepthOrderBook.OnOrderCancelled;
                exchangeEssential.LimitOrderBook.OrderCancelled += exchangeEssential.DepthOrderBook.OnOrderCancelled;

                exchangeEssential.LimitOrderBook.OrderBookChanged -= exchangeEssential.DepthOrderBook.OnOrderBookChanged;
                exchangeEssential.LimitOrderBook.OrderBookChanged -= orderBookListener.OnOrderBookChanged;

                exchangeEssential.LimitOrderBook.OrderBookChanged += exchangeEssential.DepthOrderBook.OnOrderBookChanged;
                exchangeEssential.LimitOrderBook.OrderBookChanged += orderBookListener.OnOrderBookChanged;

                exchangeEssential.LimitOrderBook.OrderChanged -= exchangeEssential.DepthOrderBook.OnOrderChanged;
                exchangeEssential.LimitOrderBook.OrderChanged -= exchangeEssential.OrderListener.OnOrderChanged;

                exchangeEssential.LimitOrderBook.OrderChanged += exchangeEssential.DepthOrderBook.OnOrderChanged;
                exchangeEssential.LimitOrderBook.OrderChanged += exchangeEssential.OrderListener.OnOrderChanged;

                exchangeEssential.LimitOrderBook.OrderFilled -= exchangeEssential.DepthOrderBook.OnOrderFilled;
                exchangeEssential.LimitOrderBook.OrderFilled += exchangeEssential.DepthOrderBook.OnOrderFilled;

                exchangeEssential.LimitOrderBook.TradeExecuted -= exchangeEssential.TradeListener.OnTrade;
                exchangeEssential.LimitOrderBook.TradeExecuted += exchangeEssential.TradeListener.OnTrade;

                exchangeEssential.DepthOrderBook.BboChanged   -= exchangeEssential.BBOListener.OnBBOChange;
                exchangeEssential.DepthOrderBook.DepthChanged -= exchangeEssential.DepthListener.OnDepthChanged;

                exchangeEssential.DepthOrderBook.BboChanged   += exchangeEssential.BBOListener.OnBBOChange;
                exchangeEssential.DepthOrderBook.DepthChanged += exchangeEssential.DepthListener.OnDepthChanged;
                //exchangeEssential.Update(tradeListener,orderListener,depthListener,bboListener);
            }
        }