public void VerifyConfiguration(IExchangeConfiguration configuration)
 {
     Assert.NotNull(configuration);
     Assert.NotNull(configuration.BaseUri);
     Assert.NotNull(configuration.SupportedCurrencies);
     Assert.NotNull(configuration.SupportedPairs);
     Assert.IsTrue(TestCandidate.ExchangeSourceType == configuration.ExchangeSourceType);
 }
Example #2
0
 private static IExchange CreateExchangeConfiguration(IExchangeConfiguration exchangeConfiguration)
 {
     return(new Exchange(
                name: exchangeConfiguration.Name,
                type: exchangeConfiguration.Type,
                durable: exchangeConfiguration.Durable,
                autoDelete: exchangeConfiguration.AutoDelete,
                arguments: exchangeConfiguration.Arguments));
 }
Example #3
0
        internal Exchange(
            IExchangeConfiguration configuration,
            IExchangeCommandFactory commands)
        {
            _configuration = configuration;
            _commands      = commands;
            SetupSocket();

            _executor = new ExecutionEngine(configuration);
        }
Example #4
0
 public ModelTranslationBase(
     IExchangeConfiguration configuration,
     TradingPair pair,
     IExchangeCommandFactory commands)
 {
     _configuration = configuration;
     _translator    = new ResultTranslation(configuration);
     _commands      = commands;
     _pair          = pair;
 }
Example #5
0
 internal AccountBalance(
     IEnumerable <IExchangeResponseIntermediate <Balance> > balances,
     TradingPair pair,
     IExchangeConfiguration configuration)
     : base(DateTime.UtcNow, configuration.ExchangeSourceType)
 {
     BalanceByCurrency = CreateDictionary(
         balances
         .Select(x => x.Convert(pair)),
         configuration);
 }
Example #6
0
 public JfdOrderBooksHarvester(
     JfdExchangeConfiguration configuration,
     JfdModelConverter modelConverter,
     ILog log,
     IHandler <OrderBook> orderBookHandler)
     : base(JfdExchange.Name, configuration, new JfdQuotesSessionConnector(GetConnectorConfig(configuration), log),
            log, orderBookHandler)
 {
     _configuration  = configuration;
     _modelConverter = modelConverter;
     HeartBeatPeriod = TimeSpan.FromSeconds(90); // Just in case if QuickFix doesn't detect connection failure.
 }
Example #7
0
        internal Exchange(
            IExchangeConfiguration configuration,
            IExchangeCommandFactory commands,
            IExchangeAuthenticator authenticator)
        {
            _configuration = configuration;
            _commands      = commands;
            SetupSocket();

            _executor = new ExecutionEngine(
                authenticator,
                configuration);
        }
Example #8
0
        internal UserTransactions(
            IEnumerable <IExchangeResponseIntermediate <UserTransaction> > transactions,
            TradingPair pair,
            IExchangeConfiguration configuration)
            : base(DateTime.UtcNow, configuration.ExchangeSourceType)
        {
            Pair = pair;

            TransactionsCollection =
                transactions
                .Select(x => x.Convert(pair))
                .Where(x => x != default(UserTransaction))
                .ToList()
                .AsReadOnly();
        }
        protected Exchange(string name, IExchangeConfiguration config,
                           TranslatedSignalsRepository translatedSignalsRepository, ILog log)
        {
            Name     = name;
            Config   = config;
            State    = ExchangeState.Initializing;
            LykkeLog = log;

            Instruments = config.SupportedCurrencySymbols?.Select(x => new Instrument(Name, x.LykkeSymbol)).ToList() ?? new List <Instrument>();

            if (!Instruments.Any() && config.UseSupportedCurrencySymbolsAsFilter != false)
            {
                throw new ArgumentException($"There is no instruments in the settings for {Name} exchange");
            }
        }
Example #10
0
        /*
         * internal Transactions(IEnumerable<Transaction> transactions, TradingPair pair,
         *  ExchangeType sourceExchange)
         *  : base(DateTime.UtcNow, sourceExchange)
         * {
         *  Pair = pair;
         *
         *  TransactionsCollection =
         *      transactions
         *          .Where(x => x != default(Transaction))
         *          .OrderByDescending(x => x.UnixCompletedTimeStamp)
         *          .ToList()
         *          .AsReadOnly();
         * }*/

        internal Transactions(
            IEnumerable <IExchangeResponseIntermediate <Transaction> > transactions,
            TradingPair pair,
            IExchangeConfiguration configuration)
            : base(DateTime.UtcNow, configuration.ExchangeSourceType)
        {
            Pair = pair;

            TransactionsCollection =
                transactions
                .Select(x => x.Convert(pair))
                .Where(x => x != default(Transaction))
                .OrderByDescending(x => x.UnixCompletedTimeStamp)
                .ToList()
                .AsReadOnly();
        }
Example #11
0
        protected Exchange(string name, IExchangeConfiguration config,
                           TranslatedSignalsRepository translatedSignalsRepository, ILog log)
        {
            Name     = name;
            Config   = config;
            State    = ExchangeState.Initializing;
            LykkeLog = log;

            if (config.SupportedCurrencySymbols == null ||
                config.SupportedCurrencySymbols.Count == 0)
            {
                throw new ArgumentException($"There is no instruments in the settings for {Name} exchange");
            }

            Instruments = config.SupportedCurrencySymbols
                          .Select(x => new Instrument(Name, x.LykkeSymbol)).ToList();
        }
        protected OrderBooksHarvesterBase(string exchangeName, IExchangeConfiguration exchangeConfiguration, ILog log,
                                          IHandler <OrderBook> newOrderBookHandler)
        {
            ExchangeConfiguration = exchangeConfiguration;
            _newOrderBookHandler  = newOrderBookHandler;
            ExchangeName          = exchangeName;

            Log = log.CreateComponentScope(GetType().Name);

            _converters = new ExchangeConverters(exchangeConfiguration.SupportedCurrencySymbols,
                                                 string.Empty, exchangeConfiguration.UseSupportedCurrencySymbolsAsFilter);

            _orderBookSnapshots      = new ConcurrentDictionary <string, OrderBookSnapshot>();
            _cancellationTokenSource = new CancellationTokenSource();
            CancellationToken        = _cancellationTokenSource.Token;

            _heartBeatMonitoringTimer = new Timer(s => RestartMessenger("No messages from the exchange"));
            _snapshotRefreshTimer     = new Timer(s => RestartMessenger("Refresh order book snapshot"));
        }
Example #13
0
        internal OpenOrders(
            IEnumerable <IExchangeResponseIntermediate <Order> > orders,
            TradingPair pair,
            IExchangeConfiguration configuration)
            : base(DateTime.UtcNow, configuration.ExchangeSourceType)
        {
            var allOrders = orders
                            .Select(x => x.Convert(pair))
                            .Distinct();

            BuyOrders =
                new ReadOnlyDictionary <string, Order>(
                    allOrders
                    .Where(x => x.IsBuyOrder)
                    .ToDictionary(x => x.Id, x => x));

            SellOrders = new ReadOnlyDictionary <string, Order>(
                allOrders
                .Where(x => x.IsSellOrder)
                .ToDictionary(x => x.Id, x => x));
        }
Example #14
0
        protected OrderBooksHarvesterBase(string exchangeName, IExchangeConfiguration exchangeConfiguration, ILog log,
                                          OrderBookSnapshotsRepository orderBookSnapshotsRepository, OrderBookEventsRepository orderBookEventsRepository,
                                          IHandler <OrderBook> newOrderBookHandler)
        {
            ExchangeConfiguration        = exchangeConfiguration;
            OrderBookSnapshotsRepository = orderBookSnapshotsRepository;
            OrderBookEventsRepository    = orderBookEventsRepository;
            _newOrderBookHandler         = newOrderBookHandler;
            ExchangeName = exchangeName;

            Log = log.CreateComponentScope(GetType().Name);

            _converters = new ExchangeConverters(exchangeConfiguration.SupportedCurrencySymbols,
                                                 string.Empty);

            _orderBookSnapshots      = new ConcurrentDictionary <string, OrderBookSnapshot>();
            _cancellationTokenSource = new CancellationTokenSource();
            CancellationToken        = _cancellationTokenSource.Token;

            _heartBeatMonitoringTimer = new Timer(RestartMessenger);
        }
Example #15
0
 internal ExecutionEngine(IExchangeConfiguration configuration)
 {
     _configuration = configuration;
     _dispatcher    = new RequestDispatcher(_configuration.BaseUri);
     _translator    = new ResultTranslation(_configuration);
 }
Example #16
0
        private ReadOnlyDictionary <Currency, Balance> CreateDictionary(IEnumerable <Balance> balances, IExchangeConfiguration configuration)
        {
            var dict = new Dictionary <Currency, Balance>();

            foreach (var currency in configuration.SupportedCurrencies)
            {
                var balance = balances.FirstOrDefault(x => x.BalanceCurrency == currency);

                if (balance == default(Balance))
                {
                    balance = new Balance(
                        0.00m,
                        currency,
                        0.00m,
                        DateTime.UtcNow,
                        configuration.ExchangeSourceType,
                        0.00m);
                }

                dict[currency] = balance;
            }
            return(new ReadOnlyDictionary <Currency, Balance>(dict));
        }
Example #17
0
#pragma warning disable RECS0154 // Parameter is never used
        internal AccountBalance(IEnumerable <Balance> balances, TradingPair pair, IExchangeConfiguration configuration)
#pragma warning restore RECS0154 // Parameter is never used
            : base(DateTime.UtcNow, configuration.ExchangeSourceType)
        {
            BalanceByCurrency = CreateDictionary(balances, configuration);
        }
Example #18
0
 public EndPointConfigurator(IExchangeConfiguration exchange, IQueueConfiguration queue, string routingKey)
 {
     RoutingKey            = routingKey;
     ExchangeConfiguration = exchange;
     QueueConfiguration    = queue;
 }
Example #19
0
 internal ResultTranslation(IExchangeConfiguration configuration)
 {
     _configuration = configuration;
 }
Example #20
0
        public SocketObservable(IExchangeConfiguration configuration, object subscribe)
        {
            _socketUri = configuration.WebSocketUri;

            _observable = MessageBuffer(subscribe);
        }
Example #21
0
 internal ExecutionEngine(IExchangeAuthenticator authenticator, IExchangeConfiguration configuration)
 {
     _dispatcher    = new RequestDispatcher(configuration.BaseUri, authenticator);
     _translator    = new ResultTranslation(configuration);
     _configuration = configuration;
 }
 protected OrderBooksWebSocketHarvester(string exchangeName, IExchangeConfiguration exchangeConfiguration, IMessenger <TRequest, TResponse> messanger, ILog log,
                                        IHandler <OrderBook> orderBookHandler)
     : base(exchangeName, exchangeConfiguration, log, orderBookHandler)
 {
     Messenger = messanger;
 }