Exemple #1
0
        public AssetFees GetAssetFees(string brokerId, string groupId, string assetId, OperationType operationType)
        {
            var entity = _assetFeesReader.Get(AssetFeesNoSqlEntity.GeneratePartitionKey(brokerId, groupId),
                                              AssetFeesNoSqlEntity.GenerateRowKey(assetId, operationType));

            if (entity == null)
            {
                return(new AssetFees {
                    FeeType = FeeType.NoFee
                });
            }

            var result = entity.AssetFees;

            if (string.IsNullOrEmpty(result.AccountId) ||
                string.IsNullOrEmpty(result.WalletId))
            {
                var settings = _feesSettingsReader.Get(FeesSettingsNoSqlEntity.GeneratePartitionKey(brokerId),
                                                       FeesSettingsNoSqlEntity.GenerateRowKey());
                if (settings != null)
                {
                    result.BrokerId  = settings.FeesSettings.BrokerId;
                    result.AccountId = settings.FeesSettings.AccountId;
                    result.WalletId  = settings.FeesSettings.WalletId;
                }
            }

            return(entity?.AssetFees);
        }
        public async Task RemoveFeesSettings(RemoveFeesSettingsRequest request)
        {
            using var action = MyTelemetry.StartActivity("Remove Fees Settings Settings");
            request.AddToActivityAsJsonTag("request");
            try
            {
                _logger.LogInformation("Remove Fees Settings Setting: {jsonText}",
                                       JsonConvert.SerializeObject(request));

                var entity = await _writer.DeleteAsync(FeesSettingsNoSqlEntity.GeneratePartitionKey(request.BrokerId),
                                                       FeesSettingsNoSqlEntity.GenerateRowKey());

                if (entity != null)
                {
                    _logger.LogInformation("Removed Fees Settings Settings: {jsonText}",
                                           JsonConvert.SerializeObject(entity));
                }
                else
                {
                    _logger.LogInformation("Unable to remove Fees Settings Setting, do not exist: {jsonText}",
                                           JsonConvert.SerializeObject(request));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Cannot remove ExternalMarketSettings: {requestJson}",
                                 JsonConvert.SerializeObject(request));
                ex.FailActivity();
                throw;
            }
        }
        public SpotInstrumentFees GetSpotInstrumentFees(string brokerId, string spotInstrumentId)
        {
            var entity = _spotInstrumentsReader.Get(SpotInstrumentFeesNoSqlEntity.GeneratePartitionKey(brokerId),
                                                    SpotInstrumentFeesNoSqlEntity.GenerateRowKey(spotInstrumentId));

            if (entity == null)
            {
                entity = _spotInstrumentsReader.Get(SpotInstrumentFeesNoSqlEntity.GeneratePartitionKey(brokerId),
                                                    SpotInstrumentFeesNoSqlEntity.GenerateRowKey(SpotInstrumentFeesNoSqlEntity.DEFAULT_FEES));
                if (entity == null)
                {
                    return(new SpotInstrumentFees {
                        FeeType = FeeType.NoFee
                    });
                }
            }

            var result = entity.SpotInstrumentFees;

            if (string.IsNullOrEmpty(result.AccountId) ||
                string.IsNullOrEmpty(result.WalletId))
            {
                var settings = _feesSettingsReader.Get(FeesSettingsNoSqlEntity.GeneratePartitionKey(brokerId),
                                                       FeesSettingsNoSqlEntity.GenerateRowKey());
                if (settings != null)
                {
                    result.BrokerId  = settings.FeesSettings.BrokerId;
                    result.AccountId = settings.FeesSettings.AccountId;
                    result.WalletId  = settings.FeesSettings.WalletId;
                }
            }

            return(result);
        }
Exemple #4
0
        public FeesSettings GetFeesSettings(string brokerId)
        {
            var entity = _reader.Get(FeesSettingsNoSqlEntity.GeneratePartitionKey(brokerId),
                                     FeesSettingsNoSqlEntity.GenerateRowKey());

            return(entity?.FeesSettings);
        }