public async Task <HedgeSettings> GetAsync()
        {
            HedgeSettings hedgeSettings = _cache.Get(CacheKey);

            if (hedgeSettings == null)
            {
                hedgeSettings = await _hedgeSettingsRepository.GetAsync();

                if (hedgeSettings == null)
                {
                    hedgeSettings = new HedgeSettings
                    {
                        MarketOrderMarkup = .02m,
                        ThresholdDown     = 1000,
                        ThresholdUp       = 5000,
                        ThresholdDownBuy  = 1000,
                        ThresholdDownSell = 1000,
                        ThresholdUpBuy    = 5000,
                        ThresholdUpSell   = 5000,
                        ThresholdCritical = 10000
                    };
                }

                _cache.Initialize(new[] { hedgeSettings });

                bool isDirty = false;

                if (hedgeSettings.ThresholdDownBuy == default(decimal))
                {
                    hedgeSettings.ThresholdDownBuy = hedgeSettings.ThresholdDown;
                    isDirty = true;
                }

                if (hedgeSettings.ThresholdDownSell == default(decimal))
                {
                    hedgeSettings.ThresholdDownSell = hedgeSettings.ThresholdDown;
                    isDirty = true;
                }

                if (hedgeSettings.ThresholdUpBuy == default(decimal))
                {
                    hedgeSettings.ThresholdUpBuy = hedgeSettings.ThresholdUp;
                    isDirty = true;
                }

                if (hedgeSettings.ThresholdUpSell == default(decimal))
                {
                    hedgeSettings.ThresholdUpSell = hedgeSettings.ThresholdUp;
                    isDirty = true;
                }

                if (isDirty)
                {
                    await UpdateAsync(hedgeSettings);
                }
            }

            return(hedgeSettings);
        }
示例#2
0
        public async Task <HedgeSettings> GetAsync()
        {
            HedgeSettings hedgeSettings = _cache.Get(CacheKey);

            if (hedgeSettings == null)
            {
                hedgeSettings = await _hedgeSettingsRepository.GetAsync();

                if (hedgeSettings == null)
                {
                    hedgeSettings = new HedgeSettings
                    {
                        MarketOrderMarkup = .02m,
                        ThresholdDown     = 1000,
                        ThresholdUp       = 5000,
                        ThresholdCritical = 10000
                    };
                }

                _cache.Initialize(new[] { hedgeSettings });
            }

            return(hedgeSettings);
        }