private static PipeDataProcessor AddResolution(string dataDirectory, TickType tickType, PipeDataProcessor root, Resolution resolution, bool sourceIsTick) { var second = new CsvDataProcessor(dataDirectory, resolution, tickType); var secondRoot = new PipeDataProcessor(second); var aggregator = new ConsolidatorDataProcessor(secondRoot, data => CreateConsolidator(resolution, tickType, data, sourceIsTick)); root.PipeTo(aggregator); return(secondRoot); }
/// <summary> /// Creates a data processor that will aggregate and zip the requested resolutions of data /// </summary> public static IDataProcessor Zip(string dataDirectory, IEnumerable <Resolution> resolutions, TickType tickType, bool sourceIsTick) { var set = resolutions.ToHashSet(); var root = new PipeDataProcessor(); // only filter tick sources var stack = !sourceIsTick ? root : (IDataProcessor) new FilteredDataProcessor(root, x => ((Tick)x).TickType == tickType); if (set.Contains(Resolution.Tick)) { // tick is filtered via trade/quote var tick = new CsvDataProcessor(dataDirectory, Resolution.Tick, tickType); root.PipeTo(tick); } if (set.Contains(Resolution.Second)) { root = AddResolution(dataDirectory, tickType, root, Resolution.Second, sourceIsTick); sourceIsTick = false; } if (set.Contains(Resolution.Minute)) { root = AddResolution(dataDirectory, tickType, root, Resolution.Minute, sourceIsTick); sourceIsTick = false; } if (set.Contains(Resolution.Hour)) { root = AddResolution(dataDirectory, tickType, root, Resolution.Hour, sourceIsTick); sourceIsTick = false; } if (set.Contains(Resolution.Daily)) { AddResolution(dataDirectory, tickType, root, Resolution.Daily, sourceIsTick); } return(stack); }