/// <summary> /// Generates the zip file name for the specified date of data. /// </summary> public static string GenerateZipFileName(Symbol symbol, DateTime date, Resolution resolution, TickType tickType) { var tickTypeString = tickType.TickTypeToLower(); var formattedDate = date.ToStringInvariant(DateFormat.EightCharacter); var isHourOrDaily = resolution == Resolution.Hour || resolution == Resolution.Daily; switch (symbol.ID.SecurityType) { case SecurityType.Base: case SecurityType.Index: case SecurityType.Equity: case SecurityType.Forex: case SecurityType.Cfd: if (isHourOrDaily) { return($"{symbol.Value.ToLowerInvariant()}.zip"); } return($"{formattedDate}_{tickTypeString}.zip"); case SecurityType.Crypto: if (isHourOrDaily) { return($"{symbol.Value.ToLowerInvariant()}_{tickTypeString}.zip"); } return($"{formattedDate}_{tickTypeString}.zip"); case SecurityType.Option: case SecurityType.IndexOption: if (isHourOrDaily) { var optionPath = symbol.Underlying.Value.ToLowerInvariant(); return($"{optionPath}_{tickTypeString}_{symbol.ID.OptionStyle.ToLower()}.zip"); } return($"{formattedDate}_{tickTypeString}_{symbol.ID.OptionStyle.ToLower()}.zip"); case SecurityType.FutureOption: if (isHourOrDaily) { var futureOptionPath = symbol.ID.Symbol.ToLowerInvariant(); return($"{futureOptionPath}_{tickTypeString}_{symbol.ID.OptionStyle.ToLower()}.zip"); } return($"{formattedDate}_{tickTypeString}_{symbol.ID.OptionStyle.ToLower()}.zip"); case SecurityType.Future: if (isHourOrDaily) { return($"{symbol.ID.Symbol.ToLowerInvariant()}_{tickTypeString}.zip"); } return($"{formattedDate}_{tickTypeString}.zip"); case SecurityType.Commodity: default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Generate's the zip entry name to hold the specified data. /// </summary> public static string GenerateZipEntryName(Symbol symbol, DateTime date, Resolution resolution, TickType tickType) { var formattedDate = date.ToStringInvariant(DateFormat.EightCharacter); var isHourOrDaily = resolution == Resolution.Hour || resolution == Resolution.Daily; switch (symbol.ID.SecurityType) { case SecurityType.Base: case SecurityType.Equity: case SecurityType.Index: case SecurityType.Forex: case SecurityType.Cfd: case SecurityType.Crypto: if (resolution == Resolution.Tick && symbol.SecurityType == SecurityType.Equity) { return(Invariant($"{formattedDate}_{symbol.Value.ToLowerInvariant()}_{tickType}_{resolution}.csv")); } if (isHourOrDaily) { return($"{symbol.Value.ToLowerInvariant()}.csv"); } return(Invariant($"{formattedDate}_{symbol.Value.ToLowerInvariant()}_{resolution.ResolutionToLower()}_{tickType.TickTypeToLower()}.csv")); case SecurityType.Option: case SecurityType.IndexOption: var optionPath = symbol.Underlying.Value.ToLowerInvariant(); if (isHourOrDaily) { return(string.Join("_", optionPath, tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); } return(string.Join("_", formattedDate, optionPath, resolution.ResolutionToLower(), tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); case SecurityType.FutureOption: // We want the future option ticker as the lookup name inside the ZIP file var futureOptionPath = symbol.ID.Symbol.ToLowerInvariant(); if (isHourOrDaily) { return(string.Join("_", futureOptionPath, tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); } return(string.Join("_", formattedDate, futureOptionPath, resolution.ResolutionToLower(), tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); case SecurityType.Future: var expiryDate = symbol.ID.Date; var monthsToAdd = FuturesExpiryUtilityFunctions.GetDeltaBetweenContractMonthAndContractExpiry(symbol.ID.Symbol, expiryDate.Date); var contractYearMonth = expiryDate.AddMonths(monthsToAdd).ToStringInvariant(DateFormat.YearMonth); if (isHourOrDaily) { return(string.Join("_", symbol.ID.Symbol.ToLowerInvariant(), tickType.TickTypeToLower(), contractYearMonth, expiryDate.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); } return(string.Join("_", formattedDate, symbol.ID.Symbol.ToLowerInvariant(), resolution.ResolutionToLower(), tickType.TickTypeToLower(), contractYearMonth, expiryDate.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); case SecurityType.Commodity: default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Generates the zip file name for the specified date of data. /// </summary> public static string GenerateZipFileName(Symbol symbol, DateTime date, Resolution resolution, TickType tickType) { var tickTypeString = tickType.TickTypeToLower(); var formattedDate = date.ToString(DateFormat.EightCharacter); var isHourOrDaily = resolution == Resolution.Hour || resolution == Resolution.Daily; switch (symbol.ID.SecurityType) { case SecurityType.Base: case SecurityType.Equity: case SecurityType.Forex: case SecurityType.Cfd: if (isHourOrDaily) { return(string.Format("{0}.zip", symbol.Value.ToLower() )); } return(string.Format("{0}_{1}.zip", formattedDate, tickTypeString )); case SecurityType.Crypto: if (isHourOrDaily) { return(string.Format("{0}_{1}.zip", symbol.Value.ToLower(), tickTypeString )); } return(string.Format("{0}_{1}.zip", formattedDate, tickTypeString )); case SecurityType.Option: if (isHourOrDaily) { return(string.Format("{0}_{1}_{2}.zip", symbol.Underlying.Value.ToLower(), // underlying tickTypeString, symbol.ID.OptionStyle.ToLower() )); } return(string.Format("{0}_{1}_{2}.zip", formattedDate, tickTypeString, symbol.ID.OptionStyle.ToLower() )); case SecurityType.Future: if (isHourOrDaily) { return(string.Format("{0}_{1}.zip", symbol.ID.Symbol.ToLower(), tickTypeString)); } return(string.Format("{0}_{1}.zip", formattedDate, tickTypeString)); case SecurityType.Commodity: default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Generate's the zip entry name to hold the specified data. /// </summary> public static string GenerateZipEntryName(Symbol symbol, DateTime date, Resolution resolution, TickType tickType) { var formattedDate = date.ToStringInvariant(DateFormat.EightCharacter); var isHourOrDaily = resolution == Resolution.Hour || resolution == Resolution.Daily; switch (symbol.ID.SecurityType) { case SecurityType.Base: case SecurityType.Equity: case SecurityType.Forex: case SecurityType.Cfd: case SecurityType.Crypto: if (resolution == Resolution.Tick && symbol.SecurityType == SecurityType.Equity) { return(Invariant($"{formattedDate}_{symbol.Value.ToLowerInvariant()}_{tickType}_{resolution}.csv")); } if (isHourOrDaily) { return($"{symbol.Value.ToLowerInvariant()}.csv"); } return(Invariant($"{formattedDate}_{symbol.Value.ToLowerInvariant()}_{resolution.ResolutionToLower()}_{tickType.TickTypeToLower()}.csv")); case SecurityType.Option: if (isHourOrDaily) { return(string.Join("_", symbol.Underlying.Value.ToLowerInvariant(), // underlying tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); } return(string.Join("_", formattedDate, symbol.Underlying.Value.ToLowerInvariant(), // underlying resolution.ResolutionToLower(), tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); case SecurityType.Future: var expiryDate = symbol.ID.Date; var monthsToAdd = FuturesExpiryUtilityFunctions.ExpiresInPreviousMonth(symbol.ID.Symbol); var contractYearMonth = expiryDate.AddMonths(monthsToAdd).ToStringInvariant(DateFormat.YearMonth); if (isHourOrDaily) { return(string.Join("_", symbol.ID.Symbol.ToLowerInvariant(), tickType.TickTypeToLower(), contractYearMonth, expiryDate.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); } return(string.Join("_", formattedDate, symbol.ID.Symbol.ToLowerInvariant(), resolution.ResolutionToLower(), tickType.TickTypeToLower(), contractYearMonth, expiryDate.ToStringInvariant(DateFormat.EightCharacter) ) + ".csv"); case SecurityType.Commodity: default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Generate's the zip entry name to hold the specified data. /// </summary> public static string GenerateZipEntryName(Symbol symbol, DateTime date, Resolution resolution, TickType tickType) { var formattedDate = date.ToString(DateFormat.EightCharacter); var isHourOrDaily = resolution == Resolution.Hour || resolution == Resolution.Daily; switch (symbol.ID.SecurityType) { case SecurityType.Base: case SecurityType.Equity: case SecurityType.Forex: case SecurityType.Cfd: case SecurityType.Crypto: if (resolution == Resolution.Tick && symbol.SecurityType == SecurityType.Equity) { return(string.Format("{0}_{1}_{2}_{3}.csv", formattedDate, symbol.Value.ToLower(), tickType, resolution )); } if (isHourOrDaily) { return(string.Format("{0}.csv", symbol.Value.ToLower() )); } return(string.Format("{0}_{1}_{2}_{3}.csv", formattedDate, symbol.Value.ToLower(), resolution.ResolutionToLower(), tickType.TickTypeToLower() )); case SecurityType.Option: if (isHourOrDaily) { return(string.Join("_", symbol.Underlying.Value.ToLower(), // underlying tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToString(DateFormat.EightCharacter) ) + ".csv"); } return(string.Join("_", formattedDate, symbol.Underlying.Value.ToLower(), // underlying resolution.ResolutionToLower(), tickType.TickTypeToLower(), symbol.ID.OptionStyle.ToLower(), symbol.ID.OptionRight.ToLower(), Scale(symbol.ID.StrikePrice), symbol.ID.Date.ToString(DateFormat.EightCharacter) ) + ".csv"); case SecurityType.Future: if (isHourOrDaily) { return(string.Join("_", symbol.ID.Symbol.ToLower(), tickType.TickTypeToLower(), symbol.ID.Date.ToString(DateFormat.YearMonth) ) + ".csv"); } return(string.Join("_", formattedDate, symbol.ID.Symbol.ToLower(), resolution.ResolutionToLower(), tickType.TickTypeToLower(), symbol.ID.Date.ToString(DateFormat.YearMonth) ) + ".csv"); case SecurityType.Commodity: default: throw new ArgumentOutOfRangeException(); } }