public DatasourceModule(IMyDbContext context, IRealTimeDataBroker rtb, IHistoricalDataBroker hdb, IEconomicReleaseBroker erb) : base("/datasources") { this.RequiresAuthentication(); Get["/", runAsync : true] = async(_, token) => await context.Datasources.ToListAsync(token).ConfigureAwait(false); Get["/status"] = _ => { var realtime = rtb.DataSources.Values.ToDictionary(x => x.Name, x => x.Connected); var historical = hdb.DataSources.Values.ToDictionary(x => x.Name, x => x.Connected); var econReleases = erb.DataSources.Values.ToDictionary(x => x.Name, x => x.Connected); var names = realtime.Keys.Union(historical.Keys).Union(econReleases.Keys); var statuses = new List <DataSourceStatus>(); foreach (var name in names) { var status = new DataSourceStatus { Name = name, RealtimeConnected = realtime.ContainsKey(name) ? realtime[name] : (bool?)null, HistoricalConnected = historical.ContainsKey(name) ? historical[name] : (bool?)null, EconReleasesConnected = econReleases.ContainsKey(name) ? econReleases[name] : (bool?)null, }; statuses.Add(status); } return(statuses); }; Get["/activestreams"] = _ => rtb.ActiveStreams; }
public CustomBootstrapper(IDataStorage storage, IEconomicReleaseBroker erb, IHistoricalDataBroker hdb, IRealTimeDataBroker rtdb, string apiKey) { _storage = storage; _erb = erb; _hdb = hdb; _rtdb = rtdb; _apiKey = apiKey; }
public RealTimeDataServer(int pubPort, int reqPort, IRealTimeDataBroker broker = null) { if (pubPort == reqPort) throw new Exception("Publish and request ports must be different"); PublisherPort = pubPort; RequestPort = reqPort; Broker = broker ?? new RealTimeDataBroker(); Broker.RealTimeDataArrived += _broker_RealTimeDataArrived; }
public RealTimeDataServer(int pubPort, int reqPort, IRealTimeDataBroker broker = null) { if (pubPort == reqPort) { throw new Exception("Publish and request ports must be different"); } PublisherPort = pubPort; RequestPort = reqPort; Broker = broker ?? new RealTimeDataBroker(); Broker.RealTimeDataArrived += _broker_RealTimeDataArrived; }
public RealTimeDataServer(MqServer server, IRealTimeDataBroker broker) { if (!ServerUtils.IsPortOpen(server.HostIp, server.Port, TimeSpan.FromSeconds(2))) { throw new PortIsInUseException($"{server.GetAddress()} is in use."); } this.broker = broker ?? throw new ArgumentNullException(nameof(broker)); this.broker.RealTimeDataArrived += BrokerRealTimeDataArrived; //if (publish.GetAddress() == request.GetAddress()) //{ // throw new ArgumentException("Publish and request ports must be different"); //} //publisherConnectionString = publish.GetAddress(); requestConnectionString = server.GetAddress(); }
public CustomBootstrapper( IDataStorage storage, IEconomicReleaseBroker erb, IHistoricalDataBroker hdb, IRealTimeDataBroker rtdb, IDividendsBroker divb, IScheduler scheduler, string apiKey) { _storage = storage; _erb = erb; _hdb = hdb; _rtdb = rtdb; _divb = divb; _scheduler = scheduler; _apiKey = apiKey; }
public RealTimeDataServer(int publisherPort, int requestPort, IRealTimeDataBroker broker) { if (broker == null) { throw new ArgumentNullException(nameof(broker), $"{nameof(broker)} cannot be null"); } if (publisherPort == requestPort) { throw new ArgumentException("Publish and request ports must be different"); } _publisherConnectionString = $"tcp://*:{publisherPort}"; _requestConnectionString = $"tcp://*:{requestPort}"; _broker = broker; _broker.RealTimeDataArrived += BrokerRealTimeDataArrived; }
public RealTimeDataServer(ISettings settings, IRealTimeDataBroker broker) { if (broker == null) { throw new ArgumentNullException(nameof(broker), $"{nameof(broker)} cannot be null"); } if (settings.rtDBPubPort == settings.rtDBReqPort) { throw new ArgumentException("Publish and request ports must be different"); } _publisherConnectionString = $"tcp://*:{settings.rtDBPubPort}"; _requestConnectionString = $"tcp://*:{settings.rtDBReqPort}"; _broker = broker; _broker.RealTimeDataArrived += BrokerRealTimeDataArrived; _broker.RealTimeTickArrived += BrokerRealTimeTickArrived; }
public CustomBootstrapper( IDataStorage storage, IEconomicReleaseBroker erb, IHistoricalDataBroker hdb, IRealTimeDataBroker rtdb, IDividendsBroker divb, IEarningsAnnouncementBroker eab, IScheduler scheduler, ISettings settings) { _storage = storage; _erb = erb; _hdb = hdb; _rtdb = rtdb; _divb = divb; _eab = eab; _scheduler = scheduler; _apiKey = settings.apiKey; }
public RealTimeDataServer(int requestPort, IRealTimeDataBroker broker, string host = "localhost", string transportProtocol = "tcp") : this(new MqServer(requestPort, host, (TransportProtocol)Enum.Parse(typeof(TransportProtocol), transportProtocol)), broker) { }