Ejemplo n.º 1
0
        public async Task DeleteAccountAsync(string clientId, string accountId)
        {
            var orders = _ordersCache.GetAll().Where(o => o.AccountId == accountId).ToArray();

            if (orders.Any())
            {
                throw new Exception(
                          $"Account [{accountId}] has not closed orders: [{orders.Select(o => $"{o.Id}:{o.Status.ToString()}").ToJson()}]");
            }

            var account = _accountsCacheService.Get(clientId, accountId);

            if (_marginSettings.IsLive && account.Balance > 0)
            {
                throw new Exception(
                          $"Account [{accountId}] balance is higher than zero: [{account.Balance}]");
            }

            await _clientAccountClient.DeleteWalletAsync(accountId);

            await _repository.DeleteAsync(clientId, accountId);

            await ProcessAccountsSetChange(clientId);

            await _rabbitMqNotifyService.AccountDeleted(account);
        }
Ejemplo n.º 2
0
        private async Task DumpToRepository()
        {
            try
            {
                var orders = _orderCache.GetAll();

                if (orders != null)
                {
                    await _marginTradingBlobRepository.Write(LykkeConstants.StateBlobContainer, BlobName, orders);
                }
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(OrdersCache), "Save orders", "", ex);
            }
        }