Beispiel #1
0
        public async Task <Repository <Candle> > GetCandleRepositoryAsync(string exchangeName, Instrument instrument, TimePeriod period)
        {
            var repo = new Repository <Candle>(_logger);

            var tableName = ExchangeUtils.GetCandleDataKey(exchangeName, instrument, period);

            if (_availableTables.All(x => x != tableName))
            {
                throw new IndexOutOfRangeException();
            }

            await repo.CreateTable(GetConnectionString(), ExchangeUtils.GetCandleDataKey(exchangeName, instrument, period));

            return(repo);
        }
Beispiel #2
0
        private void RegisterTableNames(IReadOnlyCollection <ExchangeConfig> exchangeConfigs)
        {
            _availableTables = new List <string>();

            var instruments = Enum.GetValues(typeof(Instrument)).Cast <Instrument>();
            var periods     = Enum.GetValues(typeof(TimePeriod)).Cast <TimePeriod>();

            foreach (var instrument in instruments)
            {
                foreach (var exchange in exchangeConfigs)
                {
                    var supportedPeriods = exchange.SupportedTimePeriods;

                    foreach (var period in supportedPeriods)
                    {
                        _availableTables.Add(ExchangeUtils.GetCandleDataKey(exchange.ExchangeName, instrument, period.Key));
                    }
                }
            }
        }