Example #1
0
        static ResponseParser()
        {
            _messageCtors.Add(Channels.FuturePositions(), () => new FuturePositionsUpdate()
            {
            });
            Action <Product> Subscribe = (Product product) =>
            {
                _messageCtors.Add(Channels.MarketData(product, MarketData.Depth60),
                                  () => new ProductDepth()
                {
                    Product = product.Clone()
                });
                _messageCtors.Add(Channels.MarketData(product, MarketData.Trades),
                                  () => new ProductTrades()
                {
                    Product = product.Clone()
                });
            };

            foreach (var currency in Util.Enum.Values <Currency>())
            {
                foreach (var req in Util.Enum.Values <RequestType>())
                {
                    _messageCtors.Add(Channels.SpotPositions(currency, req),
                                      () => new SpotPositionsUpdate()
                    {
                        Currency = currency, RequestType = req
                    });
                }
                foreach (var product in Util.Enum.Values <ProductType>())
                {
                    _messageCtors.Add(Channels.NewOrder(product, currency),
                                      () => new NewOrderResponse()
                    {
                        ProductType = product, Currency = currency
                    });
                    _messageCtors.Add(Channels.CancelOrder(product, currency),
                                      () => new CancelOrderResponse()
                    {
                        ProductType = product, Currency = currency
                    });
                    _messageCtors.Add(Channels.MyOrders(product, currency),
                                      () => new MyOrderUpdate()
                    {
                        ProductType = product, Currency = currency
                    });
                }
                foreach (var coin in Util.Enum.Values <CoinType>())
                {
                    Subscribe(new Spot()
                    {
                        Currency = currency, CoinType = coin
                    });
                    foreach (var ft in Util.Enum.Values <FutureType>())
                    {
                        Subscribe(new Future()
                        {
                            Currency = currency, CoinType = coin, FutureType = ft
                        });
                    }
                }
            }
        }