示例#1
0
        public void Start()
        {
            Action <BaseExchange> subscribeRestExchange = client =>
            {
                client.Logon();
                foreach (var ins in _restInstruments.Values)
                {
                    ins.SubscribeOrderBook(client, (n, o) => OrderBookRestHandler(n, o));
                }
            };

            var config     = (BotcoinConfigSection)ConfigurationManager.GetSection("botcoin");
            var connection = config.FindConnectionElement("Arbitrage");

#if true
            var domainName = connection.DomainName;
            if (Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString() == "185.226.113.60")
            {
                var str = domainName.Split('.');
                domainName = String.Format("{0}-test.{1}.{2}", str[0], str[1], str[2]);
            }
#endif
            _endPoint = new IPEndPoint(DbGatewayService.GetAddressByHost(domainName), connection.Port);
            _ticker   = new TickerService(_restInstruments, /*_wsInstruments,*/ _dbGateway.GetExchangeSettings(), _log);

            CreateExchanges();

            try
            {
                _ticker.Update();

                foreach (var client in _restExchanges.Values)
                {
                    subscribeRestExchange(client);
                }

                foreach (var client in _wsExchanges.Values)
                {
                    subscribeWsExchange(client);
                }

                _ticker.Start();
                _restSubscriber.Start();
            }
            catch (Exception ex)
            {
                _log.WriteError(ex.Message);
            }
        }
示例#2
0
        public PricesPublisher(ServiceEventLogger log)
        {
            _restInstruments = new Dictionary <CurrencyName, Instrument>();
            _restExchanges   = new Dictionary <ExchangeName, BaseExchange>();
            _wsExchanges     = new Dictionary <ExchangeName, BaseExchange>();
            _wsInstruments   = new Dictionary <CurrencyName, Instrument>();
            _dbGateway       = (DbGatewayService)log.DbRepository;
            _dbRepo          = new DbRepositoryService();
            _restSubscriber  = new RestExchangeListener(_dbGateway, log);
            _tcp             = new TcpService();
            _log             = log;

            Instrument.InitWebsocketInstruments(_wsInstruments);
            Instrument.InitRestInstruments(_restInstruments);

            _restSubscriber.ExchangePricesUpdate += RestRequestHandler;
        }