/// <summary> /// Calculates the next <see cref="FactorFileRow"/> /// </summary> /// <param name="factorFileRows">The current list of factorFileRows</param> /// <param name="nextEvent">The next dividend, split or intradayDividendSplit</param> /// <returns>A single factor file row</returns> private FactorFileRow CalculateNextFactorFileRow(List<FactorFileRow> factorFileRows, BaseData nextEvent) { FactorFileRow nextFactorFileRow; var t = nextEvent.GetType(); switch (t.Name) { case "Dividend": nextFactorFileRow = CalculateNextDividendFactor(nextEvent, factorFileRows.Last()); break; case "Split": nextFactorFileRow = CalculateNextSplitFactor(nextEvent, factorFileRows.Last()); break; case "IntraDayDividendSplit": nextFactorFileRow = CalculateIntradayDividendSplit((IntraDayDividendSplit)nextEvent, factorFileRows.Last()); break; default: throw new ArgumentException("Unhandled BaseData type for FactorFileGenerator."); } return nextFactorFileRow; }
public LeanDataLineTestParameters(BaseData data, SecurityType securityType, Resolution resolution, string expectedLine) { Data = data; SecurityType = securityType; Resolution = resolution; ExpectedLine = expectedLine; if (data is Tick) { var tick = (Tick) data; TickType = tick.TickType; } else if (data is TradeBar) { TickType = TickType.Trade; } else if (data is QuoteBar) { TickType = TickType.Quote; } else { throw new NotImplementedException(); } // override for forex/cfd if (data.Symbol.ID.SecurityType == SecurityType.Forex || data.Symbol.ID.SecurityType == SecurityType.Cfd) { TickType = TickType.Quote; } Config = new SubscriptionDataConfig(Data.GetType(), Data.Symbol, Resolution, TimeZones.Utc, TimeZones.Utc, false, true, false, false, TickType); Name = SecurityType + "_" + data.GetType().Name; if (data.GetType() != typeof (Tick) || Resolution != Resolution.Tick) { Name += "_" + Resolution; } if (data is Tick) { Name += "_" + ((Tick) data).TickType; } }