private ApiCredentials GetCredentials(CexIoAdapterSettings settings, string token)
        {
            var s = settings.Clients.FirstOrDefault(x => x.InternalApiKey == token);

            if (s == null)
            {
                return(null);
            }

            return(new ApiCredentials
            {
                ApiKey = s.ApiKey,
                ApiSecret = s.ApiSecret,
                UserId = s.UserId
            });
        }
Example #2
0
        public OrderbookPublishingService(
            ILogFactory lf,
            CexIoAdapterSettings settings)
        {
            _log               = lf.CreateLog(this);
            _logFactory        = lf;
            _orderBookSettings = settings.OrderBooks;

            var rawOrderBooks = GetRawOrderBooks();

            Session = OrderBooksSession.FromRawOrderBooks(
                rawOrderBooks,
                settings.ToCommonSettings(),
                lf);

            Session.TickPrices.Subscribe(x =>
            {
                foreach (var tickPrice in x)
                {
                    InternalMetrics.QuoteOutCount
                    .WithLabels(tickPrice.Asset)
                    .Inc();

                    InternalMetrics.QuoteOutSidePrice
                    .WithLabels(tickPrice.Asset, "ask")
                    .Set((double)tickPrice.Ask);

                    InternalMetrics.QuoteOutSidePrice
                    .WithLabels(tickPrice.Asset, "bid")
                    .Set((double)tickPrice.Bid);

                    InternalMetrics.OrderBookOutCount
                    .WithLabels(tickPrice.Asset)
                    .Inc();

                    InternalMetrics.OrderBookOutDelayMilliseconds
                    .WithLabels(tickPrice.Asset)
                    .Set((DateTime.UtcNow - tickPrice.Timestamp).TotalMilliseconds);
                }
            });
        }
Example #3
0
 public SpotController(CexIoAdapterSettings settings, ILogFactory logFactory)
 {
     _currencyMapping = settings.OrderBooks.CurrencyMapping;
     _log             = logFactory.CreateLog(this);
 }