forked from QuantConnect/Lean
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: find different Ticker data download parameters (QuantConnect…
…#7845) * refactor: map files in lean/data folder * feat: Indexers in MapFile * feat: extension for mapFile and downloader param * refactor: getAllTickers from MapFiles * feat: addition out variable in TryParsePath fix: tests with new variable * refactor: DownloadDataProvider with getting all ticker with different DateTime Ranges feat: test * revert: "refactor: map files in lean/data folder" This reverts commit 41fa26e. * revert: "feat: addition out variable in TryParsePath" refactor: some actual changing This reverts commit 9de482b. * revert: "feat: Indexers in MapFile" fix: actual changes This reverts commit 393181c. * remove: high performance Any validation feat: validation on ticker start with specific sign fix: option test * feat: validation on mapping refactor: when resolution less hour test: new test cases + validation of SecurityType * refactor: add additional day when return date range from MapFile fix: FirstTicker instead of Permtick when generate new Equity feat: validation of request Date in DownloaderDataProvider refactor: by style proj DownloaderDataProvider test:fix: starting Date in TestCases * remove: duplicate code * fix: check of income data.Time with requested Start/End-Date * test:fix: download test cuz we can not get/write future data * remove: extra Symbol Create mthd * test:feat: validate of TryParse returns correct symbol * remove: excess if condition * test:remove: extra chaning connected # 3a62adf * refactor: split big method to small ones (add readability) * fix: typo in xml description * refactor: get the correct symbol value * refactor: use local time instead of Utc in download Param extension refactor: use struct instead of class * test:fix: convert time to Utc from local time
- Loading branch information
Showing
8 changed files
with
398 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. | ||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace QuantConnect.Data.Auxiliary | ||
{ | ||
/// <summary> | ||
/// Represents security identifier within a date range. | ||
/// </summary> | ||
#pragma warning disable CA1815 // Override equals and operator equals on value types | ||
public readonly struct SymbolDateRange | ||
{ | ||
/// <summary> | ||
/// Represents a unique security identifier. | ||
/// </summary> | ||
public Symbol Symbol { get; } | ||
|
||
/// <summary> | ||
/// Ticker Start Date Time in Local | ||
/// </summary> | ||
public DateTime StartDateTimeLocal { get; } | ||
|
||
/// <summary> | ||
/// Ticker End Date Time in Local | ||
/// </summary> | ||
public DateTime EndDateTimeLocal { get; } | ||
|
||
/// <summary> | ||
/// Create the instance of <see cref="SymbolDateRange"/> struct. | ||
/// </summary> | ||
/// <param name="symbol">The unique security identifier</param> | ||
/// <param name="startDateTimeLocal">Start Date Time Local</param> | ||
/// <param name="endDateTimeLocal">End Date Time Local</param> | ||
public SymbolDateRange(Symbol symbol, DateTime startDateTimeLocal, DateTime endDateTimeLocal) | ||
{ | ||
Symbol = symbol; | ||
StartDateTimeLocal = startDateTimeLocal; | ||
EndDateTimeLocal = endDateTimeLocal; | ||
} | ||
} | ||
#pragma warning restore CA1815 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. | ||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
using QuantConnect.Interfaces; | ||
using System.Collections.Generic; | ||
using QuantConnect.Data.Auxiliary; | ||
using NodaTime; | ||
|
||
namespace QuantConnect.Data | ||
{ | ||
/// <summary> | ||
/// Contains extension methods for the Downloader functionality. | ||
/// </summary> | ||
public static class DownloaderExtensions | ||
{ | ||
/// <summary> | ||
/// Get <see cref="DataDownloaderGetParameters"/> for all mapped <seealso cref="Symbol"/> with appropriate ticker name in specific date time range. | ||
/// </summary> | ||
/// <param name="dataDownloaderParameter">Generated class in "Lean.Engine.DataFeeds.DownloaderDataProvider"</param> | ||
/// <param name="mapFileProvider">Provides instances of <see cref="MapFileResolver"/> at run time</param> | ||
/// <param name="exchangeTimeZone">Provides the time zone this exchange</param> | ||
/// <returns> | ||
/// Return DataDownloaderGetParameters with different | ||
/// <see cref="DataDownloaderGetParameters.StartUtc"/> - <seealso cref="DataDownloaderGetParameters.EndUtc"/> range | ||
/// and <seealso cref="Symbol"/> | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException">Thrown when <paramref name="dataDownloaderParameter"/> is null.</exception> | ||
public static IEnumerable<DataDownloaderGetParameters> GetDataDownloaderParameterForAllMappedSymbols( | ||
this DataDownloaderGetParameters dataDownloaderParameter, | ||
IMapFileProvider mapFileProvider, | ||
DateTimeZone exchangeTimeZone) | ||
{ | ||
if (dataDownloaderParameter == null) | ||
{ | ||
throw new ArgumentNullException(nameof(dataDownloaderParameter)); | ||
} | ||
|
||
if (dataDownloaderParameter.Symbol.SecurityType != SecurityType.Future | ||
&& dataDownloaderParameter.Symbol.RequiresMapping() | ||
&& dataDownloaderParameter.Resolution >= Resolution.Hour) | ||
{ | ||
var yieldMappedSymbol = default(bool); | ||
foreach (var symbolDateRange in mapFileProvider.RetrieveAllMappedSymbolInDateRange(dataDownloaderParameter.Symbol)) | ||
{ | ||
var endDateTimeUtc = symbolDateRange.EndDateTimeLocal.ConvertToUtc(exchangeTimeZone); | ||
|
||
// The first start date returns from mapFile like IPO (DateTime) and can not be greater then request StartTime | ||
// The Downloader doesn't know start DateTime exactly, it always download all data | ||
var startDateTime = symbolDateRange.StartDateTimeLocal.ConvertToUtc(exchangeTimeZone); | ||
var endDateTime = endDateTimeUtc > dataDownloaderParameter.EndUtc ? dataDownloaderParameter.EndUtc : endDateTimeUtc; | ||
|
||
yield return new DataDownloaderGetParameters( | ||
symbolDateRange.Symbol, dataDownloaderParameter.Resolution, startDateTime, endDateTime, dataDownloaderParameter.TickType); | ||
yieldMappedSymbol = true; | ||
} | ||
|
||
if (!yieldMappedSymbol) | ||
{ | ||
yield return dataDownloaderParameter; | ||
} | ||
} | ||
else | ||
{ | ||
yield return dataDownloaderParameter; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.