private void CheckCountGenerated(ICandleHistoryRepository repo, DateTime from, DateTime to, dynamic[] requirements) { foreach (var req in requirements) { IEnumerable <IFeedCandle> candles = repo.GetCandlesAsync(req.Asset, req.Interval, req.PriceType, from, to).Result; Assert.Equal(req.CountExpected, candles.Count()); } }
public AssetPairsController( CachedDataDictionary <string, IAssetPair> assetPairDictionary, ICandleHistoryRepository feedCandlesRepository, IFeedHistoryRepository feedHistoryRepository, IMarketProfileService marketProfileService) { _assetPairDictionary = assetPairDictionary; _feedCandlesRepository = feedCandlesRepository; _feedHistoryRepository = feedHistoryRepository; _marketProfileService = marketProfileService; }
private async Task ProcessQuotesForAsset(ICandleHistoryRepository repo, IEnumerable <QuoteExt> quotes, string asset) { if (quotes.Count() != 0) { // For each asset and interval generate candles from quotes and write them to storage. // foreach (var interval in REQUIRED_INTERVALS) { await this.Insert(repo, quotes, asset, interval); } } }
private async Task Insert(ICandleHistoryRepository repo, IEnumerable <QuoteExt> quotes, string asset, TimeInterval interval) { CandleGenerator candleGenerator = new CandleGenerator(); foreach (var type in REQUIRED_TYPES) { var data = candleGenerator.Generate(quotes, interval, type); await Retry(() => { return(repo.InsertOrMergeAsync(data, asset, interval, type)); }); } }
private static void ProcessAllQuotes(IEnumerable <Quote> quotes, ICandleHistoryRepository repo, LoggerStub logger) { var env = new EnvironmentStub(new List <AssetPair>() { new AssetPair() { Id = "btcusd", Accuracy = 3 }, //new AssetPair() { Id = "btcrub", Accuracy = 3 } }); var controller = new CandleGenerationController(repo, logger, "test component", env); var tasks = new List <Task>(); foreach (var quote in quotes) { var task = controller.HandleQuote(quote); tasks.Add(task); } Task.WaitAll(tasks.ToArray()); // ... signal controller to process quotes controller.Tick(); int counter = 0; while (counter < 5) { Task.Delay(1000).Wait(); // Wait while produce task is finished. if (controller.QueueLength == 0) { break; } counter++; } Assert.Equal(0, controller.QueueLength); }
public CandlesController(ICandleHistoryRepository feedCandlesRepository) { _feedCandlesRepository = feedCandlesRepository; }
public CandleGenerationController(ICandleHistoryRepository candlesRepo, ILog logger, string componentName, IEnvironment env) : this(logger, componentName, env) { this.candleRepository = candlesRepo; }