Exemple #1
0
        private async Task Handle(PriceForSpecialLiquidationCalculationFailedEvent e, ICommandSender sender)
        {
            var executionInfo = await _operationExecutionInfoRepository.GetAsync <SpecialLiquidationOperationData>(
                operationName : OperationName,
                id : e.OperationId);

            if (executionInfo?.Data == null)
            {
                return;
            }

            if (executionInfo.Data.SwitchState(SpecialLiquidationOperationState.PriceRequested,
                                               SpecialLiquidationOperationState.OnTheWayToFail))
            {
                sender.SendCommand(new FailSpecialLiquidationInternalCommand
                {
                    OperationId  = e.OperationId,
                    CreationTime = _dateService.Now(),
                    Reason       = e.Reason
                }, _cqrsContextNamesSettings.TradingEngine);

                _chaosKitty.Meow(e.OperationId);

                await _operationExecutionInfoRepository.Save(executionInfo);
            }
        }
Exemple #2
0
        private async Task Handle(PriceForSpecialLiquidationCalculationFailedEvent e, ICommandSender sender)
        {
            var executionInfo = await _operationExecutionInfoRepository.GetAsync <SpecialLiquidationOperationData>(
                operationName : OperationName,
                id : e.OperationId);

            if (executionInfo?.Data == null)
            {
                return;
            }

            if (PriceRequestRetryRequired(executionInfo.Data.RequestedFromCorporateActions))
            {
                var isDiscontinued = await FailIfInstrumentDiscontinued(executionInfo, sender);

                if (isDiscontinued)
                {
                    return;
                }

                var pauseAcknowledged = await _rfqPauseService.AcknowledgeAsync(executionInfo.Id);

                if (pauseAcknowledged)
                {
                    return;
                }

                await InternalRetryPriceRequest(e.CreationTime, sender, executionInfo,
                                                _marginTradingSettings.SpecialLiquidation.PriceRequestRetryTimeout.Value);

                return;
            }

            if (executionInfo.Data.SwitchState(SpecialLiquidationOperationState.PriceRequested,
                                               SpecialLiquidationOperationState.OnTheWayToFail))
            {
                sender.SendCommand(new FailSpecialLiquidationInternalCommand
                {
                    OperationId  = e.OperationId,
                    CreationTime = _dateService.Now(),
                    Reason       = e.Reason
                }, _cqrsContextNamesSettings.TradingEngine);

                _chaosKitty.Meow(e.OperationId);

                await _operationExecutionInfoRepository.Save(executionInfo);
            }
        }