예제 #1
0
        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;
        }
예제 #2
0
 public CustomBootstrapper(IDataStorage storage, IEconomicReleaseBroker erb, IHistoricalDataBroker hdb, IRealTimeDataBroker rtdb, string apiKey)
 {
     _storage = storage;
     _erb     = erb;
     _hdb     = hdb;
     _rtdb    = rtdb;
     _apiKey  = apiKey;
 }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }
예제 #5
0
        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();
        }
예제 #6
0
 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;
 }
예제 #7
0
        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;
        }
예제 #8
0
        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;
        }
예제 #10
0
 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;
 }
예제 #11
0
 public RealTimeDataServer(int requestPort, IRealTimeDataBroker broker, string host = "localhost", string transportProtocol = "tcp")
     : this(new MqServer(requestPort, host, (TransportProtocol)Enum.Parse(typeof(TransportProtocol), transportProtocol)), broker)
 {
 }