Beispiel #1
0
 public static RfqEvent ToEventContract(this OperationExecutionInfoWithPause <SpecialLiquidationOperationData> o, RfqEventTypeContract eventType, string brokerId) =>
 new RfqEvent
 {
     EventType   = eventType,
     RfqSnapshot = new RfqContract
     {
         Id                   = o.Id,
         InstrumentId         = o.Data.Instrument,
         PositionIds          = o.Data.PositionIds,
         Volume               = o.Data.Volume,
         Price                = o.Data.Price,
         ExternalProviderId   = o.Data.ExternalProviderId,
         AccountId            = o.Data.AccountId,
         CausationOperationId = o.Data.CausationOperationId,
         CreatedBy            = string.IsNullOrEmpty(o.Data.AdditionalInfo)
                 ? null
                 : Deserialize(o.Data.AdditionalInfo)?.CreatedBy,
         OriginatorType = (RfqOriginatorType)o.Data.OriginatorType,
         RequestNumber  = o.Data.RequestNumber,
         RequestedFromCorporateActions = o.Data.RequestedFromCorporateActions,
         State        = (RfqOperationState)o.Data.State,
         LastModified = o.LastModified,
         Pause        = IRfqPauseService.CalculatePauseSummary(o).ToEventContract()
     },
     BrokerId = brokerId
 };
Beispiel #2
0
        public void CalculatePauseSummary_Cannot_Be_Paused_When_ThereIsNo_Pause_But_State_IsNotAllowed()
        {
            var pauseSummary = IRfqPauseService.CalculatePauseSummary(
                new OperationExecutionInfoWithPause <SpecialLiquidationOperationData>(
                    "name",
                    "id",
                    DateTime.UtcNow,
                    new SpecialLiquidationOperationData {
                State = GetRandomOperationState(false)
            })
            {
                CurrentPause = null
            });

            Assert.IsFalse(pauseSummary.CanBePaused);
        }
Beispiel #3
0
        public void CalculatePauseSummary_Cannot_Be_Cancelled_When_ThereIsNo_Active_Pause(PauseState pauseState)
        {
            var pauseSummary = IRfqPauseService.CalculatePauseSummary(
                new OperationExecutionInfoWithPause <SpecialLiquidationOperationData>(
                    "name",
                    "id",
                    DateTime.UtcNow,
                    new SpecialLiquidationOperationData
            {
                State = GetRandomOperationState()
            })
            {
                CurrentPause = null
            });

            Assert.IsFalse(pauseSummary.CanBeResumed);
        }
Beispiel #4
0
        public void CalculatePauseSummary_Considered_As_Paused_When_Active_Or_Pending_Cancellation(PauseState pauseState)
        {
            var pauseSummary = IRfqPauseService.CalculatePauseSummary(
                new OperationExecutionInfoWithPause <SpecialLiquidationOperationData>(
                    "name",
                    "id",
                    DateTime.UtcNow,
                    new SpecialLiquidationOperationData
            {
                State = GetRandomOperationState()
            })
            {
                CurrentPause = new OperationExecutionPause {
                    State = pauseState
                }
            });

            Assert.IsTrue(pauseSummary.IsPaused);
        }
Beispiel #5
0
        public void CalculatePauseSummary_Can_Be_Paused_When_ThereIs_CancelledPause()
        {
            var pauseSummary = IRfqPauseService.CalculatePauseSummary(
                new OperationExecutionInfoWithPause <SpecialLiquidationOperationData>(
                    "name",
                    "id",
                    DateTime.UtcNow,
                    new SpecialLiquidationOperationData
            {
                State = GetRandomOperationState(true)
            })
            {
                CurrentPause = null, LatestCancelledPause = new OperationExecutionPause {
                    State = PauseState.Cancelled
                }
            });

            Assert.IsTrue(pauseSummary.CanBePaused);
        }
Beispiel #6
0
        public void CalculatePauseSummary_Cannot_Be_Paused_When_ThereIs_Pause_Already()
        {
            var pauseSummary = IRfqPauseService.CalculatePauseSummary(
                new OperationExecutionInfoWithPause <SpecialLiquidationOperationData>(
                    "name",
                    "id",
                    DateTime.UtcNow,
                    new SpecialLiquidationOperationData
            {
                State = GetRandomOperationState()
            })
            {
                CurrentPause = new OperationExecutionPause {
                    State = PauseState.Active
                }
            });

            Assert.IsFalse(pauseSummary.CanBePaused);
        }
Beispiel #7
0
 public static RfqWithPauseSummary ToRfqWithPauseSummary(this OperationExecutionInfoWithPause <SpecialLiquidationOperationData> o)
 {
     return(new RfqWithPauseSummary
     {
         Id = o.Id,
         InstrumentId = o.Data.Instrument,
         PositionIds = o.Data.PositionIds,
         Volume = o.Data.Volume,
         Price = o.Data.Price,
         ExternalProviderId = o.Data.ExternalProviderId,
         AccountId = o.Data.AccountId,
         CausationOperationId = o.Data.CausationOperationId,
         CreatedBy = string.IsNullOrEmpty(o.Data.AdditionalInfo)
             ? null
             : Deserialize(o.Data.AdditionalInfo)?.CreatedBy,
         OriginatorType = o.Data.OriginatorType,
         RequestNumber = o.Data.RequestNumber,
         RequestedFromCorporateActions = o.Data.RequestedFromCorporateActions,
         State = o.Data.State,
         LastModified = o.LastModified,
         PauseSummary = IRfqPauseService.CalculatePauseSummary(o)
     });
 }