Beispiel #1
0
        public ExchangeExtPriceSettings Add(string assetPairId, string exchangeName, string reason)
        {
            var newExchange = GetDefaultExchange();

            Update(assetPairId, old => AssetPairExtPriceSettings.Change(old,
                                                                        old.Exchanges.Add(exchangeName, newExchange)), reason);
            return(newExchange);
        }
Beispiel #2
0
        public void Delete(string assetPairId, string exchangeName, string reason)
        {
            if (TryGetExchange(assetPairId, exchangeName) == null)
            {
                throw new Exception($"Exchange {exchangeName} not exist for asset pair {assetPairId}");
            }

            Update(assetPairId, old => AssetPairExtPriceSettings.Change(old,
                                                                        old.Exchanges.Remove(exchangeName)), reason);
        }
Beispiel #3
0
        private void UpdateExchanges(string assetPairId, IEnumerable <string> exchangeNames,
                                     Func <ExchangeExtPriceSettings, ExchangeExtPriceSettings> changeFunc, string reason)
        {
            var exchangesHashSet = exchangeNames.ToImmutableHashSet();

            Update(assetPairId, old =>
            {
                var newExchanges = old.Exchanges
                                   .SetItems(old.Exchanges.Where(o => exchangesHashSet.Contains(o.Key))
                                             .Select(s => KeyValuePair.Create(s.Key, changeFunc(s.Value))));
                return(AssetPairExtPriceSettings.Change(old, newExchanges));
            }, reason);
        }
Beispiel #4
0
 public void UpdateWithoutExchanges(string assetPairId, AssetPairExtPriceSettings setting, string reason)
 {
     Update(assetPairId, old => AssetPairExtPriceSettings.Change(setting, old.Exchanges), reason);
 }