public async Task HandleMarketMakerStateAsync(MarketMakerStatus marketMakerStatus, string comment, string userId) { await _marketMakerStateService.UpdateAsync(marketMakerStatus, comment, userId); if (marketMakerStatus != MarketMakerStatus.Active) { IReadOnlyCollection <IndexSettings> indicesSettings = await _indexSettingsService.GetAllAsync(); foreach (IndexSettings indexSettings in indicesSettings) { await _marketMakerService.CancelLimitOrdersAsync(indexSettings.Name); } } }
public StateOperationContext( MarketMakerStatus currentStatus, MarketMakerStatus targetStatus, string comment, string userId, MarketMakerError error = MarketMakerError.None, string errorMessage = null) { CurrentStatus = currentStatus; TargetStatus = targetStatus; Error = error; ErrorMessage = errorMessage; Comment = comment; UserId = userId; }
public async Task UpdateAsync(MarketMakerStatus marketMakerStatus, string comment, string userId) { MarketMakerState marketMakerState = await GetAsync(); marketMakerState.Status = marketMakerStatus; marketMakerState.Timestamp = DateTime.UtcNow; await _marketMakerStateRepository.InsertOrReplaceAsync(marketMakerState); _cache.Set(marketMakerState); _log.InfoWithDetails("Market maker status updated", new { marketMakerState, comment, userId }); }
private async Task SetStateAsync(MarketMakerStatus status, MarketMakerError marketMakerError, string errorMessages, string comment, string userId) { var marketMakerState = new MarketMakerState { Time = DateTime.UtcNow, Status = status, Error = marketMakerError, ErrorMessage = errorMessages }; MarketMakerState currentMarketMakerState = await GetStateAsync(); await _marketMakerStateRepository.InsertOrReplaceAsync(marketMakerState); _cache.Set(marketMakerState); _log.InfoWithDetails("Market maker state is changed.", new StateOperationContext(currentMarketMakerState.Status, marketMakerState.Status, comment, userId, marketMakerState.Error, marketMakerState.ErrorMessage)); }
public Task SetStateAsync(MarketMakerStatus status, string comment, string userId) => SetStateAsync(status, MarketMakerError.None, null, comment, userId);