Commit Graph

85 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
Stefano Raggi 0a046699fc Consolidate SharpZipLib library usage 2020-05-28 11:18:44 +02:00
Martin Molinero 9631cd6749 Fix nuget QC dependency version 2020-05-21 16:21:59 -03:00
Martin Molinero 09c17b71ed Add assembly description to nuspec
- Due to bug in nuget failing to replace description and copyright token, setting
  .nuspec description to match assembly description
2020-05-21 14:42:12 -03:00
Martin-Molinero 1d0d4f4d7b Add assembly descriptions (#4442)
Add assembly descriptions
2020-05-21 09:35:12 -07:00
Martin Molinero 891cf4d69b Update to .Net 4.6.2 2020-05-15 17:32:46 -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
Stefano Raggi e0a08cbb8d Add XML documentation generation for release builds 2019-12-14 13:50:10 +01: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
Michael Handschuh c7df4e9fb3 Add StringExtensions and Parse utilizing CultureInfo.InvariantCulture
Adds static methods of the form Parse.<TypeName>(string str) that use
CultureInfo.InvariantCulture. These are to be used when parsing strings.
It's still safe (from the CA1304/CA1305 perspective) to use the ToDecimal
extension method for decimals.

Adds string extension methods for common operations that will now require
CultureInfo.InvariantCulture. These are to be used when converting values
to strings, such as ToStringInvariant()/ToStringInvariant(format), but also
useful for searching within strings, StartsWithInvariant, EndsWithInvariant
 and IndexOfInvariant.
2019-08-16 18:08:28 -03:00
Michael Handschuh 703f915182 Configure QuantConnect.ruleset in all projects
The initial ruleset is specifically aimed at addressing #3045. When we'd like
to start addressing other issues available via the FxCopAnalyzers, we can update
the action in QuantConnect.ruleset. A nice way to do it is to first set it to
warning, then go through the solution, project-by-project, fixing each warning.
At the end you can flip it to error and ensure it still builds. Moving forward,
any changes will fail if they violate the rule.

In support of #3045, we'll be configuring the following rules:
> CA1304: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304-specify-cultureinfo?view=vs-2017
> CA1305: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305-specify-iformatprovider?view=vs-2017
2019-08-16 18:08:18 -03:00
Michael Handschuh c42057809d Add Microsoft.CodeAnalysis.FxCopAnalyzers to all projects
FxCop has various rulesets for enforcing things within our codebase.
For this particular issue, we'll be enforcing CA1304 and CA1305 to
ensure we're always using an IFormatProvider or a CultureInfo where
applicable.

Linked Issue: #3045
2019-08-16 18:08:05 -03:00
Michael Handschuh 3e93158713 Use proper exception types
The `NullReferenceException` type is intended to only be thrown by the CLR.
In most cases, it should be converted to an `ArgumentException` or an
`InvalidOperationException`, depending on if the null value is a parameter
to the current method or not.

The `Exception` type should never really be thrown as it doesn't provide any
additional information or hints as to the issue. It also forces users that
would like to handle expected exceptions to catch all exceptions. These are
converted to an exception type that more accurately describes the reason for
raising the exception: `KeyNotFoundException`, `InvalidOperationException`
2019-08-16 18:07:30 -03:00
Gerardo Salazar 2033c7873b Update outdated DotNetZip dependency in nuspec files 2019-07-02 18:02:23 -07:00
Martin Molinero f6b5e92a96 Add conditional optimization flag 2019-06-19 16:11:15 -03:00
Gerardo Salazar 340cc3a330 Upgrade dependency DotNetZip to version 1.13.3 to fix security issue 2019-06-11 11:03:37 -07: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
Juan José D'Ambrosio bda5b11cc2 Nuspec files added for all projects.
Launcher project is packed as `QuantConnect.Lean`but as a mean ot having all Lean features just calling one package. 

In the same sense, `QuantConnect.Algorithm.CSharp` is included as package and added as dependecy in the `QuantConnect.Lean` package just to have a working example aailable out-of-the-box.
2018-04-13 07:28:34 -03:00
Jared Broad 0eae2e3da9 Path encoding 2017-10-24 03:50:47 -04:00
andrewhart098 ba565e2b11 Merge pull request #1047 from QuantConnect/option-chain-provider
Option Chain Providers
2017-08-08 11:15:53 -04:00
Andrew e116709b24 Specify <LangVersion> of 6 in all csproj files 2017-08-07 15:27:26 -04:00
Stefano Raggi e6ba94b102 Add GetZipEntryFileNames method to QuantConnect.Compression 2017-08-02 22:43:10 +02:00
Stefano Raggi 6d160533c3 Upgrade DotNetZip to version 1.10.1 2017-07-07 23:37:09 +02:00
Stefano Raggi e463ccf088 Upgrade all projects to target .NET Framework 4.5.2
In the advanced build settings, Language version was also upgraded from C# 5.0 to C# 6.0. The minimum Visual Studio version required will now be VS2015.
2017-07-07 22:49:17 +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