예제 #1
0
        public BTCMarketsExchange(IDataStore _dataStore, ICurrencyPairRepository _currencyPairRepository)
        {
            wallets = new List<CurrencyWallet>();
            pairsToUpdate = new List<BTCMarketsCurrencyWalletPair>();
            syntheticPairsToUpdate = new List<BTCMarketsSyntheticCurrencyWalletPair>();

            dataStore = _dataStore;
            var btcWallet = new FixedFeeCurrencyWallet(0.001M,0.001M, CurrencyType.Bitcoin , this);
            var ltcWallet = new FixedFeeCurrencyWallet(0.01M, 0.01M, CurrencyType.Litecoin, this);
            var audWallet = new PercentageFeeCurrencyWallet(0.01M, 0.015M, CurrencyType.AUD, this);

            wallets.Add(btcWallet);
            wallets.Add(ltcWallet);
            wallets.Add(audWallet);

            var btcusd = new BTCMarketsCurrencyWalletPair(btcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick");
            var ltcusd = new BTCMarketsCurrencyWalletPair(ltcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/LTC/AUD/tick");
            var btcltc = new BTCMarketsSyntheticCurrencyWalletPair(btcWallet, ltcWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick", "https://api.btcmarkets.net/market/LTC/AUD/tick");

            pairsToUpdate.Add(btcusd);
            pairsToUpdate.Add(ltcusd);
            syntheticPairsToUpdate.Add(btcltc);

            _currencyPairRepository.Store(btcusd);
            _currencyPairRepository.Store(ltcusd);
            _currencyPairRepository.Store(btcltc);
        }
예제 #2
0
        //protected override System.Web.Http.Dependencies.IDependencyResolver BuildWebApiDependencyResolver()
        //{
        //    //get the 'default' resolver, populated from the 'main' config metadata
        //    var resolver = base.BuildWebApiDependencyResolver();

        //    //check if its castable to a SpringWebApiDependencyResolver
        //    var springResolver = resolver as SpringWebApiDependencyResolver;

        //    //return the fully-configured resolver
        //    return springResolver;
        //}

        /// <summary>
        /// Method for initializaing the single threaded application parts
        /// </summary>
        private void InitiliazeApplication()
        {
            InputDisruptorPublisher.Shutdown();
            OutputDisruptor.ShutDown();
            IEventStore inputEventStore = new RavenNEventStore(Constants.INPUT_EVENT_STORE);
            IEventStore outputEventStore = new RavenNEventStore(Constants.OUTPUT_EVENT_STORE);
            Journaler inputJournaler = new Journaler(inputEventStore);
            Journaler outputJournaler = new Journaler(outputEventStore);
            ExchangeEssentialsList exchangeEssentialsList=outputEventStore.LoadLastSnapshot();
            ICurrencyPairRepository currencyPairRepository = (ICurrencyPairRepository) ContextRegistry.GetContext()["CurrencyPairRepository"];
            IList<CurrencyPair> tradeableCurrencyPairs = currencyPairRepository.GetTradeableCurrencyPairs();
            Exchange exchange;
            if (exchangeEssentialsList != null)
            {
                //means snapshot found so initialize the exchange
                exchange = new Exchange(tradeableCurrencyPairs, exchangeEssentialsList);
                InputDisruptorPublisher.InitializeDisruptor(new IEventHandler<InputPayload>[] {exchange, inputJournaler});
                OutputDisruptor.InitializeDisruptor(new IEventHandler<byte[]>[] {outputJournaler});
                exchange.InitializeExchangeAfterSnaphot();
                LimitOrderBookReplayService service = new LimitOrderBookReplayService();
                service.ReplayOrderBooks(exchange, outputJournaler);
                exchange.EnableSnaphots(Constants.SnaphsortInterval);
            }
            else
            {
                //no snapshot found
                exchange = new Exchange(tradeableCurrencyPairs);
                InputDisruptorPublisher.InitializeDisruptor(new IEventHandler<InputPayload>[] { exchange, inputJournaler });
                OutputDisruptor.InitializeDisruptor(new IEventHandler<byte[]>[] { outputJournaler });
               // check if there are events to replay
                LimitOrderBookReplayService service = new LimitOrderBookReplayService();
                service.ReplayOrderBooks(exchange, outputJournaler);
                exchange.EnableSnaphots(Constants.SnaphsortInterval);
            }
        }
예제 #3
0
        public BTCMarketsExchange(IDataStore _dataStore, ICurrencyPairRepository _currencyPairRepository)
        {
            wallets                = new List <CurrencyWallet>();
            pairsToUpdate          = new List <BTCMarketsCurrencyWalletPair>();
            syntheticPairsToUpdate = new List <BTCMarketsSyntheticCurrencyWalletPair>();

            dataStore = _dataStore;
            var btcWallet = new FixedFeeCurrencyWallet(0.001M, 0.001M, CurrencyType.Bitcoin, this);
            var ltcWallet = new FixedFeeCurrencyWallet(0.01M, 0.01M, CurrencyType.Litecoin, this);
            var audWallet = new PercentageFeeCurrencyWallet(0.01M, 0.015M, CurrencyType.AUD, this);

            wallets.Add(btcWallet);
            wallets.Add(ltcWallet);
            wallets.Add(audWallet);

            var btcusd = new BTCMarketsCurrencyWalletPair(btcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick");
            var ltcusd = new BTCMarketsCurrencyWalletPair(ltcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/LTC/AUD/tick");
            var btcltc = new BTCMarketsSyntheticCurrencyWalletPair(btcWallet, ltcWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick", "https://api.btcmarkets.net/market/LTC/AUD/tick");

            pairsToUpdate.Add(btcusd);
            pairsToUpdate.Add(ltcusd);
            syntheticPairsToUpdate.Add(btcltc);

            _currencyPairRepository.Store(btcusd);
            _currencyPairRepository.Store(ltcusd);
            _currencyPairRepository.Store(btcltc);
        }
예제 #4
0
        public BTCeExchange(IDataStore _dataStore, ICurrencyPairRepository _currencyPairRepository)
        {
            wallets       = new List <CurrencyWallet>();
            pairsToUpdate = new List <BTCeCurrencyWalletPair>();

            dataStore = _dataStore;
            var btcWallet = new FixedFeeCurrencyWallet(0.001M, 0.001M, CurrencyType.Bitcoin, this);
            var ltcWallet = new FixedFeeCurrencyWallet(0.01M, 0.01M, CurrencyType.Litecoin, this);
            var usdWallet = new PercentageFeeCurrencyWallet(0.01M, 0.015M, CurrencyType.USD, this);

            wallets.Add(btcWallet);
            wallets.Add(ltcWallet);
            wallets.Add(usdWallet);

            var btcusd = new BTCeCurrencyWalletPair(btcWallet, usdWallet, _dataStore, "https://btc-e.com/api/2/btc_usd/ticker");
            var ltcusd = new BTCeCurrencyWalletPair(ltcWallet, usdWallet, _dataStore, "https://btc-e.com/api/2/ltc_usd/ticker");
            var btcltc = new BTCeInverseQuoteCurrencyWalletPair(btcWallet, ltcWallet, _dataStore, "https://btc-e.com/api/2/ltc_btc/ticker");

            pairsToUpdate.Add(btcusd);
            pairsToUpdate.Add(ltcusd);
            pairsToUpdate.Add(btcltc);

            _currencyPairRepository.Store(btcusd);
            _currencyPairRepository.Store(ltcusd);
            _currencyPairRepository.Store(btcltc);
        }
예제 #5
0
 public ControlHub(ICurrencyPairRepository currencyPairRepository,
                   ICurrencyPairUpdatePublisher currencyPairUpdatePublisher,
                   IPriceFeed priceFeed)
 {
     _currencyPairRepository      = currencyPairRepository;
     _currencyPairUpdatePublisher = currencyPairUpdatePublisher;
     _priceFeed = priceFeed;
 }
예제 #6
0
 public ControlHub(ICurrencyPairRepository currencyPairRepository,
     ICurrencyPairUpdatePublisher currencyPairUpdatePublisher,
     IPriceFeed priceFeed)
 {
     _currencyPairRepository = currencyPairRepository;
     _currencyPairUpdatePublisher = currencyPairUpdatePublisher;
     _priceFeed = priceFeed;
 }
예제 #7
0
 public PricingHub(
     IPriceLastValueCache priceLastValueCache,
     ICurrencyPairRepository currencyPairRepository,
     IContextHolder contextHolder)
 {
     _priceLastValueCache    = priceLastValueCache;
     _currencyPairRepository = currencyPairRepository;
     _contextHolder          = contextHolder;
 }
예제 #8
0
 public PricingHub(
     IPriceLastValueCache priceLastValueCache,
     ICurrencyPairRepository currencyPairRepository,
     IContextHolder contextHolder)
 {
     _priceLastValueCache = priceLastValueCache;
     _currencyPairRepository = currencyPairRepository;
     _contextHolder = contextHolder;
 }
예제 #9
0
 public PriceFeedSimulator(
     ICurrencyPairRepository currencyPairRepository,
     IPricePublisher pricePublisher,
     IPriceLastValueCache priceLastValueCache)
 {
     _currencyPairRepository = currencyPairRepository;
     _pricePublisher         = pricePublisher;
     _priceLastValueCache    = priceLastValueCache;
     _random = new Random(_currencyPairRepository.GetHashCode());
 }
예제 #10
0
 public PriceFeedSimulator(
     ICurrencyPairRepository currencyPairRepository,
     IPricePublisher pricePublisher,
     IPriceLastValueCache priceLastValueCache)
 {
     _currencyPairRepository = currencyPairRepository;
     _pricePublisher = pricePublisher;
     _priceLastValueCache = priceLastValueCache;
     _random = new Random(_currencyPairRepository.GetHashCode());
 }
예제 #11
0
        public MainViewModel(
            IPricePublisher pricePublisher,
            IPriceFeed priceFeed,
            ICurrencyPairRepository currencyPairRepository,
            Func <CurrencyPairInfo, ICurrencyPairViewModel> ccyViewModelFactory)
        {
            _pricePublisher         = pricePublisher;
            _priceFeed              = priceFeed;
            _currencyPairRepository = currencyPairRepository;
            _ccyViewModelFactory    = ccyViewModelFactory;

            StartStopCommand = new DelegateCommand(StartStopServer);
            CurrencyPairs    = new ObservableCollection <ICurrencyPairViewModel>();

            ObserveThroughputs();
        }
예제 #12
0
        public MainViewModel(
            IPricePublisher pricePublisher, 
            IPriceFeed priceFeed, 
            ICurrencyPairRepository currencyPairRepository, 
            Func<CurrencyPairInfo, ICurrencyPairViewModel> ccyViewModelFactory)
        {
            _pricePublisher = pricePublisher;
            _priceFeed = priceFeed;
            _currencyPairRepository = currencyPairRepository;
            _ccyViewModelFactory = ccyViewModelFactory;

            StartStopCommand = new DelegateCommand(StartStopServer);
            CurrencyPairs = new ObservableCollection<ICurrencyPairViewModel>();

            ObserveThroughputs();
        }
 public TradeApplicationService(ITradeRepository tradeRepository, ICurrencyPairRepository currencyPairRepository, IOrderRepository orderRepository)
 {
     _tradeRepository        = tradeRepository;
     _currencyPairRepository = currencyPairRepository;
     _orderRepository        = orderRepository;
 }
예제 #14
0
 public ReferenceDataHub(ICurrencyPairRepository currencyPairRepository, IContextHolder contextHolder)
 {
     _currencyPairRepository = currencyPairRepository;
     _contextHolder = contextHolder;
 }
예제 #15
0
 public ReferenceDataHub(ICurrencyPairRepository currencyPairRepository, IContextHolder contextHolder)
 {
     _currencyPairRepository = currencyPairRepository;
     _contextHolder          = contextHolder;
 }
예제 #16
0
 public Arbitrarge2TradeStrategy(INotificationEngine _notificationEngine, ICurrencyPairRepository _currencyPairRepository, IDataStore _dataStore)
 {
     currencyPairRepository = _currencyPairRepository;
     notificationEngine     = _notificationEngine;
     dataStore = _dataStore;
 }
예제 #17
0
 public RateExchanger(ICurrencyPairRepository exchangeRateRepository)
 {
     this.exchangeRateRepository = exchangeRateRepository;
 }
예제 #18
0
 public Arbitrarge2TradeStrategy( INotificationEngine _notificationEngine, ICurrencyPairRepository _currencyPairRepository, IDataStore _dataStore)
 {
     currencyPairRepository = _currencyPairRepository;
     notificationEngine = _notificationEngine;
     dataStore = _dataStore;
 }