Skip to content

Commit

Permalink
DownloaderDataProvider improvements (QuantConnect#5730)
Browse files Browse the repository at this point in the history
- Ignore margin files requests. Only provided by ApiDataProvider
- Reduce noise by LeanData.TryParse() call on failure
  • Loading branch information
Martin-Molinero authored Jul 2, 2021
1 parent c8d1308 commit e5a5010
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
38 changes: 25 additions & 13 deletions Common/Util/LeanData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -992,22 +992,34 @@ public static bool TryParseSecurityType(string fileName, out SecurityType securi
public static bool TryParsePath(string filePath, out Symbol symbol, out DateTime date,
out Resolution resolution, out TickType tickType, out Type dataType)
{
if (!TryParsePath(filePath, out symbol, out date, out resolution))
symbol = default;
tickType = default;
dataType = default;
date = default;
resolution = default;

try
{
tickType = TickType.Trade;
dataType = null;
return false;
}
if (!TryParsePath(filePath, out symbol, out date, out resolution))
{
return false;
}

tickType = GetCommonTickType(symbol.SecurityType);
var fileName = Path.GetFileNameWithoutExtension(filePath);
if (fileName.Contains("_"))
tickType = GetCommonTickType(symbol.SecurityType);
var fileName = Path.GetFileNameWithoutExtension(filePath);
if (fileName.Contains("_"))
{
tickType = (TickType)Enum.Parse(typeof(TickType), fileName.Split('_')[1], true);
}

dataType = GetDataType(resolution, tickType);
return true;
}
catch (Exception ex)
{
tickType = (TickType)Enum.Parse(typeof(TickType), fileName.Split('_')[1], true);
Log.Debug($"LeanData.TryParsePath(): Error encountered while parsing the path {filePath}. Error: {ex.GetBaseException()}");
}

dataType = GetDataType(resolution, tickType);
return true;
return false;
}

/// <summary>
Expand Down Expand Up @@ -1083,7 +1095,7 @@ public static bool TryParsePath(string fileName, out Symbol symbol, out DateTime
}
catch (Exception ex)
{
Log.Error($"LeanData.TryParsePath(): Error encountered while parsing the path {fileName}. Error: {ex.GetBaseException()}");
Log.Debug($"LeanData.TryParsePath(): Error encountered while parsing the path {fileName}. Error: {ex.GetBaseException()}");
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion Engine/DataFeeds/DownloaderDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ protected override bool NeedToDownload(string filePath)
if (filePath == null
|| filePath.Contains("fine", StringComparison.InvariantCultureIgnoreCase) && filePath.Contains("fundamental", StringComparison.InvariantCultureIgnoreCase)
|| filePath.Contains("map_files", StringComparison.InvariantCultureIgnoreCase)
|| filePath.Contains("factor_files", StringComparison.InvariantCultureIgnoreCase))
|| filePath.Contains("factor_files", StringComparison.InvariantCultureIgnoreCase)
|| filePath.Contains("margins", StringComparison.InvariantCultureIgnoreCase) && filePath.Contains("future", StringComparison.InvariantCultureIgnoreCase))
{
return false;
}
Expand Down

0 comments on commit e5a5010

Please sign in to comment.