예제 #1
0
        public SelfHost()
        {
            var log = new ServiceEventLogger(DataType.ServiceName.Arbitrage, new DbRepositoryService());

            _msgHandling = new MessageHandling(log, new RestScheduler(log));
            _matching    = new MatchingEngine(log, _msgHandling);
            _rateService = new CurrencyRateService();
            _tcp         = new TcpService();

            _msgHandling.MatchingEngine  = _matching;
            _msgHandling.ExchangePrices += _matching.OnExchangePrices;

            if (!EventLog.SourceExists(ServiceName))
            {
                EventLog.CreateEventSource(ServiceName, ServiceName + "Log");
            }
        }
예제 #2
0
        public MatchingEngine(ServiceEventLogger log, MessageHandling msgHandling)
        {
            _singleInstrument = new CancellationPattern();
            _manyInstruments  = new CancellationPattern();
            _orderPlacement   = new OrderPlacement();
            _cancelMonitoring = new CancellationPattern();
            _wsExchanges      = new Dictionary <ExchangeName, BaseExchange>();
            _exchanges        = new Dictionary <ExchangeName, IExchange>();
            _profitRatios     = new Dictionary <ExchangeName, double>();
            _instruments      = new Dictionary <CurrencyName, Instrument>();
            _wsInstruments    = new Dictionary <CurrencyName, Instrument>();
            _balance          = new BalanceManagement();
            _matchingEvent    = new AutoResetEvent(false);
            _stopEvent1       = new AutoResetEvent(false);
            _stopEvent2       = new AutoResetEvent(false);
            _bittrex          = new BittrexArbitrage(log);
            _orderBook        = new OrderBook();
            _obj         = new object();
            _dbRepo      = (DbRepositoryService)log.DbRepository;
            _syncService = new SyncBalanceService(log);
            _msgHandling = msgHandling;
            _log         = log;

            Instrument.InitWebsocketInstruments(_wsInstruments);

            _instruments.Add(CurrencyName.BTC, new InstrumentBTC());
            _instruments.Add(CurrencyName.BCH, new InstrumentBCH());
            _instruments.Add(CurrencyName.LTC, new InstrumentLTC());
            _instruments.Add(CurrencyName.ETH, new InstrumentETH());
            _instruments.Add(CurrencyName.XRP, new InstrumentXRP());
            _instruments.Add(CurrencyName.DSH, new InstrumentDASH());
            _instruments.Add(CurrencyName.IOTA, new InstrumentIOTA());

            _spreadMono = new SpreadMono(this, _dbRepo, ExchangeName.OkEx);
            _spreadIota = new SpreadIOTA(this, _dbRepo);
            _spread     = new InstrumentSpreadBTC(this, _dbRepo);
        }