/// <summary> /// The subscribe to universe. /// </summary> /// <param name="execution"> /// The execution. /// </param> /// <param name="operationContext"> /// The operation context. /// </param> /// <param name="alertStream"> /// The alert stream. /// </param> /// <param name="universeDataRequestsSubscriber"> /// The universe data requests subscriber. /// </param> /// <param name="washTradeParameters"> /// The wash trade parameters. /// </param> /// <returns> /// The <see cref="IUniverseRule"/>. /// </returns> private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse( ScheduledExecution execution, ISystemProcessOperationContext operationContext, IUniverseAlertStream alertStream, IUniverseDataRequestsSubscriber universeDataRequestsSubscriber, IReadOnlyCollection <IWashTradeRuleFixedIncomeParameters> washTradeParameters) { var subscriptions = new List <IUniverseRule>(); if (washTradeParameters != null && washTradeParameters.Any()) { foreach (var param in washTradeParameters) { var paramSubscriptions = this.SubscribeToParameters( execution, operationContext, alertStream, universeDataRequestsSubscriber, param); subscriptions.Add(paramSubscriptions); } } else { const string ErrorMessage = "tried to schedule a wash trade rule execution with no parameters set"; this.logger.LogError(ErrorMessage); operationContext.EventError(ErrorMessage); } return(subscriptions); }
/// <summary> /// The subscribe to universe. /// </summary> /// <param name="execution"> /// The execution. /// </param> /// <param name="operationContext"> /// The operation context. /// </param> /// <param name="alertStream"> /// The alert stream. /// </param> /// <param name="universeDataRequestsSubscriber"> /// The universe data requests subscriber. /// </param> /// <param name="layeringParameters"> /// The layering parameters. /// </param> /// <returns> /// The <see cref="IUniverseRule"/>. /// </returns> private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse( ScheduledExecution execution, ISystemProcessOperationContext operationContext, IUniverseAlertStream alertStream, IUniverseDataRequestsSubscriber universeDataRequestsSubscriber, IReadOnlyCollection <ILayeringRuleEquitiesParameters> layeringParameters) { var subscriptions = new List <IUniverseRule>(); // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (layeringParameters != null && layeringParameters.Any()) { foreach (var param in layeringParameters) { var paramSubscriptions = this.SubscribeToParameters( execution, operationContext, alertStream, universeDataRequestsSubscriber, param); subscriptions.Add(paramSubscriptions); } } else { const string ErrorMessage = "tried to schedule a layering rule execution with no parameters set"; this.logger.LogError(ErrorMessage); operationContext.EventError(ErrorMessage); } return(subscriptions); }
/// <summary> /// The subscribe to universe. /// </summary> /// <param name="execution"> /// The execution. /// </param> /// <param name="operationContext"> /// The operation context. /// </param> /// <param name="dataRequestSubscriber"> /// The data request subscriber. /// </param> /// <param name="judgementService"> /// The judgement service. /// </param> /// <param name="highProfitParameters"> /// The high profit parameters. /// </param> /// <returns> /// The <see cref="IUniverseRule"/>. /// </returns> private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse( ScheduledExecution execution, ISystemProcessOperationContext operationContext, IUniverseDataRequestsSubscriber dataRequestSubscriber, IJudgementService judgementService, IReadOnlyCollection <IHighProfitsRuleEquitiesParameters> highProfitParameters) { var subscriptions = new List <IUniverseRule>(); if (highProfitParameters != null && highProfitParameters.Any()) { foreach (var param in highProfitParameters) { var cloneableRule = this.SubscribeParameters( execution, operationContext, dataRequestSubscriber, judgementService, param); subscriptions.Add(cloneableRule); } } else { const string ErrorMessage = "tried to schedule a high profit rule execution with no parameters set"; this.logger.LogError(ErrorMessage); operationContext.EventError(ErrorMessage); } return(subscriptions); }
/// <summary> /// The subscribe to universe. /// </summary> /// <param name="execution"> /// The execution. /// </param> /// <param name="operationContext"> /// The operation context. /// </param> /// <param name="alertStream"> /// The alert stream. /// </param> /// <param name="rampingParameters"> /// The ramping parameters. /// </param> /// <param name="dataRequestSubscriber"> /// The data request subscriber. /// </param> /// <returns> /// The <see cref="IUniverseRule"/>. /// </returns> private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse( ScheduledExecution execution, ISystemProcessOperationContext operationContext, IUniverseAlertStream alertStream, IReadOnlyCollection <IRampingRuleEquitiesParameters> rampingParameters, IUniverseDataRequestsSubscriber dataRequestSubscriber) { var subscriptions = new List <IUniverseRule>(); if (rampingParameters != null && rampingParameters.Any()) { foreach (var param in rampingParameters) { var baseSubscriber = this.SubscribeParameterToUniverse( execution, operationContext, alertStream, param, dataRequestSubscriber); subscriptions.Add(baseSubscriber); } } else { const string ErrorMessage = "tried to schedule a cancelled order rule execution with no parameters set"; this.logger.LogError(ErrorMessage); operationContext.EventError(ErrorMessage); } return(subscriptions); }
/// <summary> /// The subscribe to universe. /// </summary> /// <param name="execution"> /// The execution. /// </param> /// <param name="operationContext"> /// The operation context. /// </param> /// <param name="dataRequestSubscriber"> /// The data request subscriber. /// </param> /// <param name="highProfitParameters"> /// The high profit parameters. /// </param> /// <param name="judgementService"> /// The judgement service. /// </param> /// <returns> /// The <see cref="IUniverseRule"/>. /// </returns> private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse( ScheduledExecution execution, ISystemProcessOperationContext operationContext, IUniverseDataRequestsSubscriber dataRequestSubscriber, IReadOnlyCollection <IHighProfitsRuleFixedIncomeParameters> highProfitParameters, IJudgementService judgementService) { var subscriptions = new List <IUniverseRule>(); // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (highProfitParameters != null && highProfitParameters.Any()) { foreach (var param in highProfitParameters) { var paramSubscriptions = this.SubscribeToParameters( execution, operationContext, dataRequestSubscriber, param, judgementService); subscriptions.Add(paramSubscriptions); } } else { var errorMessage = $"tried to schedule a {nameof(FixedIncomeHighProfitsRule)} rule execution with no parameters set"; this.logger.LogError(errorMessage); operationContext.EventError(errorMessage); } return(subscriptions); }
private async Task BlockOnApisDown(ISystemProcessOperationContext opCtx) { var servicesRunning = await this._apiHeartbeat.HeartsBeating(); if (!servicesRunning) { this._logger.LogWarning("asked to executed distributed message but was unable to reach api services"); // set status here opCtx.UpdateEventState(OperationState.BlockedClientServiceDown); opCtx.EventError("asked to executed distributed message but was unable to reach api services"); } var servicesDownMinutes = 0; var exitClientServiceBlock = servicesRunning; while (!exitClientServiceBlock) { this._logger.LogInformation("APIs down on heartbeat requests. Sleeping for 30 seconds."); Thread.Sleep(30 * 1000); var apiHeartBeat = this._apiHeartbeat.HeartsBeating(); exitClientServiceBlock = apiHeartBeat.Result; servicesDownMinutes += 1; if (servicesDownMinutes == 15) { this._logger.LogError( "has been trying to process a message for 15 minutes but the api services on the client service have been down"); opCtx.EventError( "has been trying to process a message for 15 minutes but the api services on the client service have been down"); } } if (!servicesRunning) { this._logger.LogWarning("was unable to reach api services but is now able to"); opCtx.UpdateEventState(OperationState.InProcess); } }