Esempio n. 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");
            }
        }
Esempio n. 2
0
        public SpreadIOTA(MatchingEngine matching, DbRepositoryService dbRepo)
        {
            _dbRepo = dbRepo;

            matching.BTC += (s, e) =>
            {
                if (e.Exchange == ExchangeName.Binance)
                {
                    btcBinance[0] = e.BidPrice;
                    btcBinance[1] = e.AskPrice;
                    binanceFee    = e.TradingFee;
                }
                else if (e.Exchange == ExchangeName.OkEx)
                {
                    btcOkex[0] = e.BidPrice;
                    btcOkex[1] = e.AskPrice;
                    okexFee    = e.TradingFee;
                }
                SaveSpreadOkexBinance();
            };
            matching.IOTA += (s, e) =>
            {
                if (e.Exchange == ExchangeName.Binance)
                {
                    iotaBinance[0] = e.BidPrice;
                    iotaBinance[1] = e.AskPrice;
                    binanceFee     = e.TradingFee;
                }
                else if (e.Exchange == ExchangeName.OkEx)
                {
                    if (e.Instrument2 == CurrencyName.USDT)
                    {
                        iotaOkex[0] = e.BidPrice;
                        iotaOkex[1] = e.AskPrice;
                        okexFee     = e.TradingFee;
                    }
                }
                SaveSpreadOkexBinance();
            };
        }
Esempio n. 3
0
        public SpreadMono(MatchingEngine matching, DbRepositoryService dbRepo, ExchangeName exchange)
        {
            _dbRepo = dbRepo;

            matching.BTC += (s, e) =>
            {
                if (e.Exchange == exchange)
                {
                    btc[0]     = e.BidPrice;
                    btc[1]     = e.AskPrice;
                    tradingFee = e.TradingFee;
                }
                SaveSpread();
            };
            matching.IOTA += (s, e) =>
            {
                if (e.Exchange == exchange)
                {
                    if (e.Instrument2 == CurrencyName.Undefined)
                    {
                        throw new InvalidOperationException("SpreadMono");
                    }

                    if (e.Instrument2 == CurrencyName.BTC)
                    {
                        iotaBtc[0] = e.BidPrice;
                        iotaBtc[1] = e.AskPrice;
                    }
                    else if (e.Instrument2 == CurrencyName.USDT)
                    {
                        iotaUsd[0] = e.BidPrice;
                        iotaUsd[1] = e.AskPrice;
                    }
                    tradingFee = e.TradingFee;
                }
                SaveSpread();
            };
        }
        public InstrumentSpreadBTC(MatchingEngine matching, DbRepositoryService dbRepo)
        {
            _dbRepo = dbRepo;

            matching.BTC += (s, e) =>
            {
                if (e.Exchange == ExchangeName.Binance)
                {
                    ex1[0] = e.BidPrice;
                    ex1[1] = e.AskPrice;
                }
                else if (e.Exchange == ExchangeName.HitBtc)
                {
                    ex2[0] = e.BidPrice;
                    ex2[1] = e.AskPrice;
                }
                else
                {
                    return;
                }
                SaveSpread();
            };
        }
Esempio n. 5
0
        public InstrumentSpread(MatchingEngine matching, DbRepositoryService dbRepo)
        {
            _dbRepo = dbRepo;

            matching.XRP += (s, e) =>
            {
                if (e.Instrument2 == CurrencyName.ETH)
                {
                    xrp[0] = e.BidPrice;
                    xrp[1] = e.AskPrice;
                }
                SaveSpreadOkexBinance();
            };
            matching.DASH += (s, e) =>
            {
                if (e.Instrument2 == CurrencyName.ETH)
                {
                    dash[0] = e.BidPrice;
                    dash[1] = e.AskPrice;
                }
                SaveSpreadOkexBinance();
            };
        }