/// <summary> /// Initializes a new instance of the <see cref="ExecutionEngine"/> class. /// </summary> /// <param name="container">The componentry container.</param> /// <param name="messagingAdapter">The message bus adapter.</param> /// <param name="database">The execution database.</param> /// <param name="gateway">The trading gateway.</param> /// <param name="eventPublisher">The event publisher endpoint.</param> /// <param name="gtdExpiryBackups">The option flag for GTD order expiry cancel backups.</param> public ExecutionEngine( IComponentryContainer container, IMessageBusAdapter messagingAdapter, IExecutionDatabase database, ITradingGateway gateway, IEndpoint eventPublisher, bool gtdExpiryBackups = true) : base(container, messagingAdapter) { this.database = database; this.gateway = gateway; this.eventPublisher = eventPublisher; this.bufferModify = new Dictionary <OrderId, ModifyOrder>(); this.cancelJobs = new Dictionary <OrderId, JobKey>(); this.GtdExpiryBackups = gtdExpiryBackups; // Commands this.RegisterHandler <SubmitOrder>(this.OnMessage); this.RegisterHandler <SubmitBracketOrder>(this.OnMessage); this.RegisterHandler <CancelOrder>(this.OnMessage); this.RegisterHandler <ModifyOrder>(this.OnMessage); this.RegisterHandler <AccountInquiry>(this.OnMessage); // Events this.RegisterHandler <OrderSubmitted>(this.OnMessage); this.RegisterHandler <OrderAccepted>(this.OnMessage); this.RegisterHandler <OrderRejected>(this.OnMessage); this.RegisterHandler <OrderWorking>(this.OnMessage); this.RegisterHandler <OrderModified>(this.OnMessage); this.RegisterHandler <OrderCancelReject>(this.OnMessage); this.RegisterHandler <OrderExpired>(this.OnMessage); this.RegisterHandler <OrderCancelled>(this.OnMessage); this.RegisterHandler <OrderPartiallyFilled>(this.OnMessage); this.RegisterHandler <OrderFilled>(this.OnMessage); this.RegisterHandler <AccountStateEvent>(this.OnMessage); // Order Events this.Subscribe <OrderSubmitted>(); this.Subscribe <OrderAccepted>(); this.Subscribe <OrderRejected>(); this.Subscribe <OrderWorking>(); this.Subscribe <OrderModified>(); this.Subscribe <OrderCancelReject>(); this.Subscribe <OrderExpired>(); this.Subscribe <OrderCancelled>(); this.Subscribe <OrderPartiallyFilled>(); this.Subscribe <OrderFilled>(); this.Subscribe <AccountStateEvent>(); this.Logger.LogInformation(LogId.Component, $"{nameof(this.GtdExpiryBackups)} is {this.GtdExpiryBackups}"); }
/// <summary> /// Initializes a new instance of the <see cref="ExecutionService"/> class. /// </summary> /// <param name="container">The componentry container.</param> /// <param name="messagingAdapter">The messaging adapter.</param> /// <param name="tradingGateway">The execution gateway.</param> /// <param name="config">The execution service configuration.</param> /// <exception cref="ArgumentException">If the addresses is empty.</exception> public ExecutionService( IComponentryContainer container, MessageBusAdapter messagingAdapter, ITradingGateway tradingGateway, ServiceConfiguration config) : base( container, messagingAdapter, config.FixConfig) { this.tradingGateway = tradingGateway; this.managedComponents = new List <Address> { ComponentAddress.CommandServer, ComponentAddress.EventPublisher, }; this.RegisterConnectionAddress(ComponentAddress.TradingGateway); }
/// <summary> /// The initializes the FIX trading gateway. /// </summary> /// <param name="gateway">The trading gateway.</param> public void InitializeGateway(ITradingGateway gateway) { this.FixMessageHandler.InitializeGateway(gateway.Endpoint); }