Beispiel #1
0
        public async Task SetMarginTradingEnabled(string clientId, bool enabled)
        {
            var settings = await _clientAccountClient.GetMarginEnabledAsync(clientId);

            if (_marginSettings.IsLive)
            {
                settings.EnabledLive = enabled;
            }
            else
            {
                settings.Enabled = enabled;
            }

            await _clientAccountClient.SetMarginEnabledAsync(clientId, settings.Enabled, settings.EnabledLive,
                                                             settings.TermsOfUseAgreed);

            var marginEnabledChangedMessage = new MarginTradingEnabledChangedMessage
            {
                ClientId    = clientId,
                EnabledDemo = settings.Enabled,
                EnabledLive = settings.EnabledLive
            };

            _marginTradingSettingsCacheService.OnMarginTradingEnabledChanged(marginEnabledChangedMessage);
            await _eventsPublisher.ProduceAsync(marginEnabledChangedMessage);
        }
Beispiel #2
0
        private Task <EnabledMarginTradingTypes> IsMarginTradingEnabledInternal(string clientId)
        {
            async Task <EnabledMarginTradingTypes> MarginEnabled()
            {
                var marginEnabledSettings = await _clientAccountClient.GetMarginEnabledAsync(clientId);

                return(new EnabledMarginTradingTypes
                {
                    Demo = marginEnabledSettings.Enabled,
                    Live = marginEnabledSettings.EnabledLive
                });
            }

            return(_cacheProvider.GetAsync(GetClientTradingEnabledCacheKey(clientId),
                                           async() => new CachableResult <EnabledMarginTradingTypes>(await MarginEnabled(),
                                                                                                     ClientTradingEnabledCachingParameters)));
        }
Beispiel #3
0
 public Task <MarginEnabledSettingsModel> GetMarginEnabledAsync(string clientId)
 {
     return(_clientAccountsClient.GetMarginEnabledAsync(clientId));
 }