107 var fileinfo =
new FileInfo(path);
108 var filename = fileinfo.Name;
109 var parts = path.Split(
'/',
'\\');
112 const int LowResSecurityTypeOffset = 4;
113 const int HighResSecurityTypeOffset = 5;
116 const int MarketOffset = 1;
117 const int ResolutionOffset = 2;
118 const int TickerOffset = 3;
121 if (parts.Length < LowResSecurityTypeOffset)
123 throw new FormatException($
"Unexpected path format: {path}");
126 var securityTypeOffset = LowResSecurityTypeOffset;
128 var rawValue = parts[parts.Length - securityTypeOffset];
129 if (!Enum.TryParse(rawValue,
true, out securityType))
131 securityTypeOffset = HighResSecurityTypeOffset;
132 rawValue = parts[parts.Length - securityTypeOffset];
133 if (!Enum.TryParse(rawValue,
true, out securityType))
135 throw new FormatException($
"Unexpected path format: {path}");
139 var market = parts[parts.Length - securityTypeOffset + MarketOffset];
140 var resolution = (
Resolution) Enum.Parse(typeof (
Resolution), parts[parts.Length - securityTypeOffset + ResolutionOffset],
true);
142 if (securityTypeOffset == LowResSecurityTypeOffset)
144 ticker = Path.GetFileNameWithoutExtension(path);
145 if (securityType.IsOption())
148 ticker = ticker.Substring(0, ticker.IndexOf(
"_", StringComparison.InvariantCulture));
153 ticker = ticker.Substring(0, ticker.LastIndexOfInvariant(
"_"));
159 ticker = ticker.Substring(0, ticker.LastIndexOfInvariant(
"_"));
164 ticker = parts[parts.Length - securityTypeOffset + TickerOffset];
167 var date = securityTypeOffset == LowResSecurityTypeOffset ? DateTime.MinValue : DateTime.ParseExact(filename.Substring(0, filename.IndexOf(
"_", StringComparison.Ordinal)),
DateFormat.
EightCharacter,
null);
172 var withoutExtension = Path.GetFileNameWithoutExtension(filename);
173 rawValue = withoutExtension.Substring(withoutExtension.LastIndexOf(
"_", StringComparison.Ordinal) + 1);
179 var withoutExtension = Path.GetFileNameWithoutExtension(filename);
180 rawValue = withoutExtension.Substring(withoutExtension.LastIndexOf(
"_", StringComparison.Ordinal) + 1);
195 var tickType = filename.Contains(
"_quote") ?
TickType.Quote : (filename.Contains(
"_openinterest") ?
TickType.OpenInterest :
TickType.Trade);