예제 #1
0
        public async Task <OrderBookViewModel> GetMarketAsync(int exchangeId, string baseCurrency, string quoteCurrency)
        {
            OrderBookViewModel orderbook;

            orderbook = await Task.Run(() =>
            {
                if (String.IsNullOrEmpty(baseCurrency) || String.IsNullOrEmpty(quoteCurrency))
                {
                    throw new ArgumentNullException("Market isn't provided.");
                }
                if (exchangeId.ToString() == "0")
                {
                    if (quoteCurrency.ToUpper() == "USD")
                    {
                        quoteCurrency = "USDT";
                    }

                    return(_marketData.GetMarketData(exchangeId.ToString(), baseCurrency.ToUpper(), quoteCurrency.ToUpper()));
                }
                else if (exchangeId.ToString() == "1")
                {
                    if (quoteCurrency.ToUpper() == "USD")
                    {
                        quoteCurrency = "USDT";
                    }

                    return(_marketData.GetMarketData(exchangeId.ToString(), baseCurrency.ToUpper(), quoteCurrency.ToUpper()));
                }
                else if (exchangeId.ToString() == "3")
                {
                    return(_marketData.GetMarketData(exchangeId.ToString(), baseCurrency.ToUpper(), quoteCurrency.ToUpper()));
                }
                else if (exchangeId.ToString() == "4")
                {
                    return(_marketData.GetMarketData(exchangeId.ToString(), baseCurrency.ToUpper(), quoteCurrency.ToUpper()));
                }
                else if (exchangeId.ToString() == "5")
                {
                    if (quoteCurrency.ToUpper() == "USD")
                    {
                        quoteCurrency = "USDT";
                    }
                    return(_marketData.GetMarketData(exchangeId.ToString(), baseCurrency.ToUpper(), quoteCurrency.ToUpper()));
                }
                return(null);
            });

            return(orderbook);
        }
예제 #2
0
        static public ExchangeCallback CreateCallback(IExchangeMarketData exchangeMarketData, IEventBus eventBus)
        {
            return((exchangeId, baseCurrency, quoteCurrency, info) =>
            {
                WriteMarketData(exchangeId, baseCurrency, quoteCurrency, info, exchangeMarketData).Wait();

                try
                {
                    if (!String.IsNullOrEmpty(exchangeId))
                    {
                        var @event = new ExchangeOrderBookUpdatedIntegrationEvent(
                            Int32.Parse(exchangeId),
                            baseCurrency,
                            quoteCurrency,
                            exchangeMarketData.GetMarketData(exchangeId, baseCurrency, quoteCurrency)
                            );

                        eventBus.Publish(@event);
                        //.Publish(new TimeForUpdateBalanceIntegrationEvent());
                    }
                }

                catch (Exception ex)
                {
                    Debug.WriteLine("Publish Event: ExchangeOrderBookUpdatedIntegrationEvent. \n" +
                                    "Error message: " + ex.Message);
                }
            });
        }