Ejemplo n.º 1
0
        public async Task UpdateAsync(Quote quote)
        {
            if (!await _instrumentService.IsAssetPairExistAsync(quote.AssetPairId))
            {
                return;
            }

            if (quote.Ask == 0 || quote.Bid == 0 || quote.Mid == 0)
            {
                _log.WarningWithDetails("Invalid quote received", quote);
                return;
            }

            Quote currentQuote = _cache.Get(GetKey(quote));

            if (currentQuote != null)
            {
                QuoteThresholdSettings quoteThresholdSettings = await _quoteThresholdSettingsService.GetAsync();

                if (quoteThresholdSettings.Enabled &&
                    Math.Abs(currentQuote.Mid - quote.Mid) / currentQuote.Mid > quoteThresholdSettings.Value)
                {
                    _log.WarningWithDetails("Invalid quote", new
                    {
                        Quote        = quote,
                        CurrentQuote = currentQuote,
                        Threshold    = quoteThresholdSettings.Value
                    });
                }
                else
                {
                    _exchanges.Add(quote.Source);
                    _cache.Set(quote);
                }
            }
            else
            {
                _exchanges.Add(quote.Source);
                _cache.Set(quote);
            }
        }
Ejemplo n.º 2
0
        public async Task SetAsync(Quote quote)
        {
            Quote currentQuote = _cache.Get(GetKey(quote));

            if (currentQuote != null)
            {
                QuoteThresholdSettings quoteThresholdSettings = await _quoteThresholdSettingsService.GetAsync();

                if (quoteThresholdSettings.Enabled &&
                    Math.Abs(currentQuote.Mid - quote.Mid) / currentQuote.Mid > quoteThresholdSettings.Value)
                {
                    _quoteThresholdLogService.Error(currentQuote, quote, quoteThresholdSettings.Value);
                }
                else
                {
                    _cache.Set(quote);
                }
            }
            else
            {
                _cache.Set(quote);
            }
        }
Ejemplo n.º 3
0
        public async Task <QuoteThresholdSettingsModel> GetQuoteThresholdSettingsAsync()
        {
            QuoteThresholdSettings quoteThresholdSettings = await _quoteThresholdSettingsService.GetAsync();

            return(Mapper.Map <QuoteThresholdSettingsModel>(quoteThresholdSettings));
        }