Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataServer"/> class.
 /// </summary>
 /// <param name="container">The componentry container.</param>
 /// <param name="messagingAdapter">The messaging adapter.</param>
 /// <param name="headerSerializer">The header serializer.</param>
 /// <param name="requestSerializer">The inbound message serializer.</param>
 /// <param name="responseSerializer">The outbound message serializer.</param>
 /// <param name="compressor">The data compressor.</param>
 /// <param name="encryption">The encryption configuration.</param>
 /// <param name="serviceName">The service name.</param>
 /// <param name="requestPort">The inbound port.</param>
 /// <param name="responsePort">The outbound port.</param>
 public DataServer(
     IComponentryContainer container,
     IMessageBusAdapter messagingAdapter,
     ISerializer <Dictionary <string, string> > headerSerializer,
     IMessageSerializer <Request> requestSerializer,
     IMessageSerializer <Response> responseSerializer,
     ICompressor compressor,
     EncryptionSettings encryption,
     Label serviceName,
     Port requestPort,
     Port responsePort)
     : base(
         container,
         messagingAdapter,
         headerSerializer,
         requestSerializer,
         responseSerializer,
         compressor,
         encryption,
         serviceName,
         ZmqNetworkAddress.AllInterfaces(requestPort),
         ZmqNetworkAddress.AllInterfaces(responsePort))
 {
     this.RegisterHandler <DataRequest>(this.OnMessage);
     this.RegisterHandler <DataResponse>(this.OnMessage);
     this.RegisterHandler <QueryFailure>(this.OnMessage);
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandServer"/> class.
        /// </summary>
        /// <param name="container">The component setup container.</param>
        /// <param name="messagingAdapter">The message bus adapter.</param>
        /// <param name="headerSerializer">The header serializer.</param>
        /// <param name="requestSerializer">The request serializer.</param>
        /// <param name="responseSerializer">The response serializer.</param>
        /// <param name="commandSerializer">The command serializer.</param>
        /// <param name="compressor">The message compressor.</param>
        /// <param name="encryption">The encryption configuration.</param>
        /// <param name="serviceName">The service name.</param>
        /// <param name="config">The network configuration.</param>
        public CommandServer(
            IComponentryContainer container,
            IMessageBusAdapter messagingAdapter,
            ISerializer <Dictionary <string, string> > headerSerializer,
            IMessageSerializer <Request> requestSerializer,
            IMessageSerializer <Response> responseSerializer,
            IMessageSerializer <Command> commandSerializer,
            ICompressor compressor,
            EncryptionSettings encryption,
            Label serviceName,
            NetworkConfiguration config)
            : base(
                container,
                messagingAdapter,
                headerSerializer,
                requestSerializer,
                responseSerializer,
                compressor,
                encryption,
                serviceName,
                ZmqNetworkAddress.AllInterfaces(config.CommandReqPort),
                ZmqNetworkAddress.AllInterfaces(config.CommandResPort))
        {
            this.commandThrottler = new Throttler <Command>(
                container,
                this.SendToExecutionEngine,
                Duration.FromSeconds(1),
                config.CommandsPerSecond,
                nameof(Command));

            this.orderThrottler = new Throttler <Command>(
                container,
                this.commandThrottler.Endpoint.Send,
                Duration.FromSeconds(1),
                config.NewOrdersPerSecond,
                nameof(Order));

            this.RegisterSerializer(commandSerializer);
            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);

            this.commandThrottler.Start();
            this.orderThrottler.Start();
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventPublisher"/> class.
 /// </summary>
 /// <param name="container">The component setup container.</param>
 /// <param name="serializer">The event serializer.</param>
 /// <param name="compressor">The event compressor.</param>
 /// <param name="encryption">The encryption configuration.</param>
 /// <param name="serviceName">The service name.</param>
 /// <param name="port">The publisher port.</param>
 public EventPublisher(
     IComponentryContainer container,
     ISerializer <Event> serializer,
     ICompressor compressor,
     EncryptionSettings encryption,
     Label serviceName,
     Port port)
     : base(
         container,
         serializer,
         compressor,
         encryption,
         serviceName,
         ZmqNetworkAddress.AllInterfaces(port))
 {
     this.RegisterHandler <TradeEvent>(this.OnEvent);
     this.RegisterHandler <AccountStateEvent>(this.OnEvent);
 }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataPublisher"/> class.
        /// </summary>
        /// <param name="container">The componentry container.</param>
        /// <param name="dataBusAdapter">The data bus adapter.</param>
        /// <param name="instrumentSerializer">The instrument serializer.</param>
        /// <param name="compressor">The data compressor.</param>
        /// <param name="encryption">The encryption configuration.</param>
        /// <param name="port">The port.</param>
        public DataPublisher(
            IComponentryContainer container,
            IDataBusAdapter dataBusAdapter,
            IDataSerializer <Instrument> instrumentSerializer,
            ICompressor compressor,
            EncryptionSettings encryption,
            Port port)
            : base(
                container,
                dataBusAdapter,
                compressor,
                encryption,
                ZmqNetworkAddress.AllInterfaces(port))
        {
            this.instrumentSerializer = instrumentSerializer;

            this.RegisterHandler <Instrument>(this.OnMessage);

            this.Subscribe <BarData>();
            this.Subscribe <Instrument>();
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TickPublisher"/> class.
        /// </summary>
        /// <param name="container">The componentry container.</param>
        /// <param name="dataBusAdapter">The data bus adapter.</param>
        /// <param name="quoteSerializer">The quote tick serializer.</param>
        /// <param name="tradeSerializer">The trade tick serializer.</param>
        /// <param name="compressor">The data compressor.</param>
        /// <param name="encryption">The encryption configuration.</param>
        /// <param name="port">The publisher port.</param>
        public TickPublisher(
            IComponentryContainer container,
            IDataBusAdapter dataBusAdapter,
            IDataSerializer <QuoteTick> quoteSerializer,
            IDataSerializer <TradeTick> tradeSerializer,
            ICompressor compressor,
            EncryptionSettings encryption,
            Port port)
            : base(
                container,
                dataBusAdapter,
                compressor,
                encryption,
                ZmqNetworkAddress.AllInterfaces(port))
        {
            this.quoteSerializer = quoteSerializer;
            this.tradeSerializer = tradeSerializer;

            this.RegisterHandler <QuoteTick>(this.OnMessage);
            this.RegisterHandler <TradeTick>(this.OnMessage);

            this.Subscribe <QuoteTick>();
            this.Subscribe <TradeTick>();
        }