Commit Graph

58 Commits

Author SHA1 Message Date
michael-sena a128f8bb2e Allow LeanDataWriter to create zip files for futures data (#4569)
* Allow LeanDataWriter to append to zip data files

* Use the data directory provided to the writer instead of the global value

* Disregard the time-portion of an input date

* Overwrite zip entries when creating futures data files

* Minor tweak and adding unit test

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2020-08-18 17:44:02 -03:00
Martin Molinero 69194bfbe9 Minor improvements
- Makeing FactorFileRow.Parse private to avoid wrong usages
- Avoid end of stream check while unzipping
2020-06-08 14:33:52 -03:00
Martin Molinero 5c721b1248 Add missing dispose call for MemoryStream
- Add missing dispose call for MemoryStream. Covered by existing tests
2020-05-11 15:44:22 -03:00
Michael Handschuh 9d5ee05826 Support encoding in Compression.UnzipData 2019-12-10 19:20:26 -05:00
Michael Handschuh 30c8772a7e Update Compression/Jupyter/Launcher/Queues/UserInterface to respect CA1304 and CA1305
Updates all occurrences of parsing/ToString-ing to go through the new
StringExtensions methods that use CultureInfo.InvariantCulture

See #3045
2019-09-12 15:30:44 -04:00
Martin Molinero 357b045a13 Fix Compression.UnzipToFolder 2019-08-29 19:06:02 -03:00
Stefano Raggi 28ee5026af Fix incorrect return value in Compression.GetBytes 2019-02-14 12:13:20 +01:00
Michael Handschuh 58c384509b Keep directory structure in Compression.UnzipToFolder
The implementation here was stripping out the directories and unzipping to
a flat structure. This is not required and was breaking python algorithms by
messing up their folder based imports. Also, all consumers currently utilize
the return value which is a full list of the unzipped files including the sub
directories, so no changes were needed elsewhere.
2018-06-19 12:42:43 -04:00
Jared Broad 0eae2e3da9 Path encoding 2017-10-24 03:50:47 -04:00
Stefano Raggi e6ba94b102 Add GetZipEntryFileNames method to QuantConnect.Compression 2017-08-02 22:43:10 +02:00
Andrew 63ac67f3b7 Added method for testing whether a zip archive is corrupted 2017-03-24 16:59:24 -04:00
Andrew 672e134939 Removed ApiDataProvider
Refactored IHistoryProvider interface order of parameters
2017-02-16 15:47:06 -05:00
Andrew b6171cc9d5 Renamed IDataFileProvider to IDataProvider using resharper
Refactored IDataProvider interface to return stream. The IDataProvider
Fetch method now only takes a key.  The IDataProvider
has been reshuffled to be at the bottom of the LeanDataStack.  It provides
data to the rest of the Lean stack. The default implementation of IDataProvider reads
data from disc.

All IDataCacheProviders now have constructors which take IDataProviders
and use them to find data on disc.

Renamed DataCacheProvider to ZipDataCacheProvider

Added comments to IDataProvider and it's implementations

Added comments to IDataCacheProvider and it's implementations
2017-02-15 12:16:50 -05:00
Andrew ed2107132e IHistoryProvider.Initialize() requires a DataCacheProvider
Fixed bug where DataCacheProvider was returning a stream without closing
the stream.  Also, ZipFiles returned from ZipFileCacheProvider are
effectively disposed.

Removed date field from IDataCacheProvider interface
2017-02-15 12:16:49 -05:00
Andrew 952e1d19e3 Added interface IDataCacheProvider that defines a mechanism for caching data
This interface was built around the existing implementation of the
DataCacheProvider.  It's purpose is to define a method for caching data
files.  Currently, most data files are either read from disc or retrieved
remotely. The IDataChceProvider returns returns a Stream and can handle
many types of data. The IDataFileCacheProvider is needed because keeping data in memory will improve performance and overcome certain File read/write limitations (such as sharing violations) currently experienced by Lean.

There are two implementations of this interface.  The first is the
SingleZipEntryDataCache.  This is the default implementation. It does not
cache and returns the first entry found within a ZipFile.  The second is
the ZipEntryCacheProvider.  This is a rework of the existing
DataCachePrivider.  It caches ZipFiles for up to 10 seconds.  It can
return specific entries for option and future ZipFiles.  Otherwise, it
returns the first entry in a ZipFile.

Added IDataFileCacheProvider as parameter to IHistoryProvider.Initialize()

The IDataFileCacheProvider is very useful for the IHistoryProvider in that it can eliminate the need for history request to touch disc.  This can greatly improve peerformance and eliminate disc bugs associated with disc read/writes. To minimize changes throughtout Lean, the default value for the IDataFileCacheProvider is null in the IHistoryProvider.Initialize method.

IDataCacheProviders are passed down the Lean stack. Each instance of a Subscription Enumerator factory decides what cache it
will use.  In other words, the IDataCacheProvider is not configurable from
config.json.  The IDataCacheProvider is passwed down the stack form the
Enumerator factory to the IStreamReader where it is used to retrieve data.

Added useful helper method to Unizp files into a Stream.
2017-02-15 12:16:49 -05:00
quant1729 4382821ae7 Removed reference to System.IO.Compression zip library in Compression.Unzip() and DataFileCacheProvider.cs, as in mono this namespace is implemented using SharpCompress. Reverted back to Ionic zip library. 2017-01-22 00:20:57 +08:00
quant1729 6ba1ae899a Removed UnzipCached() method and its usages. Updated Zip() method. 2017-01-11 12:57:03 +08:00
quant1729 48721125dc Revert "Fixed bug with static zip archive caching. Added new caching data file provider. Refactored IDataFileProvider interface."
This reverts commit c59743dc42.
2017-01-11 11:27:28 +08:00
quant1729 c59743dc42 Fixed bug with static zip archive caching. Added new caching data file provider. Refactored IDataFileProvider interface. 2017-01-08 09:25:26 +08:00
quant1729 f2f93ef85c Better cache for ZipArchive 2016-12-27 15:18:39 +01:00
quant1729 705024cd89 Merge branch 'futures'
Conflicts:
	Common/QuantConnect.csproj
2016-12-20 15:53:24 +01:00
quant1729 2570f4c99f Optimizing options backtesting (zipper). First cut. 2016-12-19 16:41:42 +01:00
Michael Handschuh 0bf79b901c Refactor overload of Compression.Zip
This new overload allows the caller to specify every piece of data used by the
zip routine, allowing specification of the entry name, destination path, and
whether or not to delete the original file.
2016-12-08 21:16:41 -05:00
quant1729 1141cd21e6 Merge branch 'futures' into master
Conflicts:
	Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj
	Algorithm/QCAlgorithm.cs
	Brokerages/InteractiveBrokers/InteractiveBrokersBrokerage.cs
	Common/QuantConnect.csproj
	Common/Securities/Option/Option.cs
	Data/equity/usa/factor_files/aapl.csv
	Data/symbol-properties/symbol-properties-database.csv
	Engine/DataFeeds/Enumerators/Factories/BaseDataSubscriptionEnumeratorFactory.cs
	Engine/DataFeeds/Enumerators/Factories/OptionChainUniverseSubscriptionEnumeratorFactory.cs
	Engine/DataFeeds/SubscriptionDataReader.cs
	ToolBox/QuantConnect.ToolBox.csproj
2016-11-07 16:18:11 +01:00
Michael Handschuh 8062cdf108 Use .NET zip implementation
The replaced zip implementation had issues in high performance,
multi-threaded scenarios. The exact cause of the issue was not
determined, but invalid zip were being generated when using this
method directly.

The replacement uses the built in .NET zip archive implementation
which should (in theory) have better cross-platform characteristics
than 3rd party implementations.

The unit test was also update as it made incorrect usage of the
Compression.Unzip routine. It has been replaced with a more reliable
method that unzips the first entry and returns a stream reader.
2016-10-30 20:32:01 -04:00
quant1729 5803115548 Option splits and renames in backtesting. Added regression tests. 2016-10-26 21:20:03 +02:00
jaredbroad 9453118e2e Tidy create zip from file collection 2016-09-07 19:26:18 -04:00
Stefano Raggi 1e7536a333 Merge pull request #524 from QuantConnect/fundamental
Fundamental data support and coarse/fine universe selection
2016-08-16 00:05:36 +02:00
jaredbroad 99b634e9f2 Added CNY currency, added .gz unzipper 2016-08-02 21:16:20 -04:00
Stefano Raggi ce6001bb75 Added filename in Compression.Unzip log error message 2016-06-28 23:15:39 +02:00
Michael Handschuh 35158c4677 Log error instead of throwing if zip entry not found
This follows the behavior of logging when the file doesn't exist as well.
This is very common in options trade data, since it's often there are no trades for a contract
2016-04-07 14:18:17 -04:00
Michael Handschuh a6d263bed9 Adds Compression.Unzip overload supporting zip entry name 2016-03-17 09:47:45 -04:00
Michael Handschuh 5639909de5 Adds Compression.ZipBytes - in memory zip 2016-02-11 23:46:27 -05:00
Michael Handschuh cf1258708a Move zip file name gen to LeanData 2016-02-09 18:20:54 -05:00
Stefano Raggi 84eef2ee43 Fixes zip file naming for CFD support 2016-01-13 15:51:02 -05:00
snugs c31cdde376 Adds overwrite to Compression.Unzip 2016-01-05 16:04:20 -05:00
snugs 6b4465f18d Adds Compression.Unzip to folder 2015-12-30 17:58:27 -05:00
snugs 4edb40fc13 Adds include root flag Compression.ZipDirectory 2015-12-29 23:53:20 -05:00
snugs 7caae8c8ee Use .Net zip for Compression.ZipDirectory 2015-12-29 19:58:48 -05:00
snugs 49e09bbc36 Adds Compression.ZipDirectory 2015-12-29 14:35:03 -05:00
snugs be950e756a Log full errors/stack traces
Many places in the code used Log.Error(err.Message) or equivalent which
strips out all the really useful information, such as the stack trace
and inner exceptions. Using Log.Error(exception) is the correct way to
log an error as it will correctly write all the message details, also,
by passing the full Exception object we can improve the logging in this
one place and all call sites will automatically benefit from the improvements
2015-12-02 12:35:33 -05:00
snugs 64bdfaf42c Adds overload for Compression.Zip accepting entry name 2015-11-17 16:51:44 -05:00
snugs bb241899fb Implements IMapFileProvider
An IMapFileProvider instance is used to cache/retrieve
MapFileResolver instances for equity symbol resolution
2015-11-16 12:06:15 -05:00
QuantConnect f526322df1 Version Bump 2.1.5.0 New LEAN data writer and update to compression get zip entry name 2015-10-15 16:49:47 -04:00
snugs 51a9be1906 Adds more streaming compression options 2015-10-01 12:15:37 -04:00
QuantConnect 901c5a319c IEnumerable Tar Iterator for Compression Library 2015-09-22 14:36:27 -04:00
snugs 001821adce Use symbol.ToLower() in paths 2015-09-18 12:17:18 -04:00
snugs e1938baafe Clean up using directives 2015-09-01 22:17:35 -04:00
QuantConnect a3222599d2 Added support for local file 2015-07-13 20:42:48 -04:00
Stefano Raggi 81e3afc31e Added missing Dispose on streaming ZipFile 2015-06-20 23:55:17 +02:00