Commit Graph

44 Commits

Author SHA1 Message Date
Martin Molinero 7aafdef827 MapFile and FactorFile data feed resolution
- Moving `MapFile` and `FactorFile` resolution to the data feed stack so
that they do not add a performance overhead to the algorithm thread.
- Create logging string messaged only if required.
- Calculate `FactorFileRow.PriceScaleFactor` the least amount of times
2019-06-12 17:48:47 -03:00
Martin Molinero 08b72c5907 Overall performance improvements v2
- Adding `LazyToUpper()` implementation, that will avoid the call to
`ToUpper` if the string is already upper.
- Reduce the timezone conversions at `Time.EachTradeableDayInTimeZone`
- `TotalPortfolioValue` will iterate over all securities once
- Adding new `SecurityIdentifier` cache, significant impact for
algorithms using coarse/fine data
2019-06-05 17:06:59 -03:00
Jared cd80c70775 Merge pull request #2868 from gsalaz98/feature-2859-rdg-delistings-mappings-splits-dividends-generator
RandomDataGenerator Mapping, Delisting, Splits, and Dividends Generator
2019-05-14 15:46:24 -07:00
Martin Molinero c39638668c Overall performance improvements
- `FactorFile` will keep an ordered reversed list with the dates.
Calling `Reverse()` on the `SortedList` is expensive.
- `MapFiles` will keep first and last date, so we don't need to call
`First()` and `Last()` multiple times.
- `Liquidate` will go through all the algorithms securities only if
necessary
- `TradeBar` parsing will not call `new T` for pure `TradeBar` which is
expensive
- Removing `Lazy` hash code and security type for the
`SecurityIdentifier`, replacing for direct initialization. Accessing the
`Lazy` value adds an overhead.
- Replacing `Enum` to string for hardcoded switch statement. `Enum.ToString` is expensive.
- `DataManager` will be lazy for counting the subscriptions for
determining if its above the limit
- Adding `AlgorithmSecurityValuesProvider.GetAllValues()`, removes the
need to fetch all the security keys twice.
- During universe selection, will not try to re add already added symbol
2019-04-22 10:47:27 -03:00
Gerardo Salazar f9336514fd Parameterize probability of IPO, splits, dividends, renames, and
dividends every quarter.

Check for existing directory before attempting to write in MapFile
2019-04-09 15:01:55 -07:00
Gerardo Salazar 645bb031b3 Improved random generation to more closely match sample factor files
Fixed bug where factor file reference price output had very high
precision

Fixed bug where map file had a useless entry before the final line if
the asset was not delisted

Fixed bug where program would crash because of NextPrice reaching its
maximum attempts. Fixed by removing call to NextPrice and using another
generation method.
2019-04-02 21:25:10 -07:00
Gerardo Salazar 55f8376c53 Create mapping, IPO, delisting, splits, and dividends random generation
Created random-seed argument for rdg in order to let the user get deterministic output

Update documentation in 'FactorFileRow.cs' to accurately reflect factor
file structure

Update CSV generation for FactorFile so that it uses FactorFileRow's CSV
generator

Add FinancialCalendar to make it easier to implement logic regarding
financial quarters

Add mapping events to RandomDataGenerator

Update MapFileRow ToCsv method to correctly emit the ticker as lowercase

Fix bug in FactorFile where we would get the same initial data point twice
when we converted it to CSV

Create new method to convert a MapFile to CSV

Create new method to write MapFile to disk as CSV

Add unit test to test for successful CSV generation in MapFile

Add new files to project

Add FinancialCalendar unit tests

Create new class to handle generation of dividends, splits, and maps
2019-04-02 21:25:10 -07:00
Martin Molinero b9f2112fad Check if factor file exists on disk only once 2018-09-07 14:36:43 -03:00
Michael Handschuh d04666f690 Round factors using quantquote precision
Adds rounding of price and scale factors when writing a factor file
row to csv. The precision provided is the same that is used by quant
quote in their raw files
2018-08-27 14:10:41 -04:00
Michael Handschuh 9e306e76c7 Add FactorFileRow.ToCsv(source) and fix Apply(Dividend) bug
The time check in FactorFileRow.Apply(Dividend) was not using the previous
trading date for comparison.

Added a 'source' parameter to FactorFileRow.ToCsv() for tracking each row's
data source.
2018-08-27 13:53:04 -04:00
Michael Handschuh 8861f251f8 Adds MapFile.FirstTicker
The first ticker and first date are most commonly used to properly create
security identifiers. Currently resolution of the first ticker is strewn
about in various places and often times it doesn't take into account the
case of an empty map file, where the first (and last) ticker are assumed
to be the permtick after removing the '.<number>' specifier at the end.
It's important to also not remove '.<letter>' -- as some securities are
named as such.
2018-08-27 13:53:04 -04:00
Michael Handschuh f1960d2243 Add FactorFile.MostRecentFactorChange, bugfix for empty files
Empty factor files (whether a single 2050 line or no lines), by definition don't
have any splits or dividends.

FactorFile.MostRecentFactorChange yields the maximum date that isn't the 2050 date
2018-08-27 13:53:04 -04:00
Michael Handschuh 57affafdc2 Implement 'live' factor files
Adds reference price to dividend/split
Adds GetSplitsAndDividends to FactorFile
Adds Apply methods to FactorFile/FactorFileRow
Updates factor files to include reference prices
2018-08-14 17:58:44 -04:00
Stefano Raggi 9040f2b5fa Fix MapFileResolver with remapped and delisted symbol 2018-07-24 12:06:19 +02:00
Michael Handschuh a352ef6a60 Parallelize reading of map files
Improved time of reading all map files form ~1.7s to ~0.4s
2018-07-19 13:49:00 -04:00
Martin Molinero f7dada5aae Adding default return value for GetMappedSymbol() 2018-07-13 18:51:06 -03:00
Stefano Raggi 2ff5650b4a Add price and split factors to CoarseFundamental class 2018-06-01 12:19:06 +02:00
Michael Handschuh 43534196fa Set ZipEntryName.DataType to Auxiliary 2018-04-26 13:13:50 -04:00
Stefano Raggi 30316e19ab Skip duplicate rows in factor files
Some factor files contain duplicate rows causing a duplicate key exception when loaded. We now ignore these rows, allowing factors to be loaded and applied correctly.
2017-12-07 17:46:13 +01:00
Andrew 39728063ba Make LocalDiskMapFileProvider uses data cache folder 2017-09-15 18:10:27 -04:00
Andrew efd5845a3e Added ability to specify cache data folder 2017-09-14 16:31:43 -04:00
Stefano Raggi 301b9e14fb Handle factor files with INF values
Before this PR, backtesting some symbols fails with an error when parsing the factor file.

Some factor files have INF split values, indicating that the stock has so many splits that prices can't be calculated with correct numerical precision.

To allow backtesting these symbols, we need to move the starting date forward when reading the data.

Known symbols: GBSN, JUNI, NEWL
2017-02-17 20:35:57 +01: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
quant1729 5803115548 Option splits and renames in backtesting. Added regression tests. 2016-10-26 21:20:03 +02:00
Andrew 80dfc15fe2 Updated expected statistics for CourseFineFundamentalRegression test. Test now passes 2016-10-22 09:35:23 -04:00
Andrew 63be681027 Added IntradayDividendSplits.cs 2016-10-22 09:23:50 -04:00
Andrew Hart 75cb33f793 FactorFileGenerator now operates on BaseData 2016-10-22 09:22:58 -04:00
Andrew Hart 3fe0499d1f Added ability to create factor files from Yahoo Api Data 2016-10-22 09:22:58 -04:00
Stefano Raggi 600ee8b713 Reverts changes to ResolveMapFile calls 2016-06-14 21:03:54 +02:00
Stefano Raggi 3e4f608db8 Fixes failing regression tests for factor file resolution 2016-06-12 21:25:11 +02:00
Stefano Raggi 8336944956 Fixes split issue with mapped symbols (SPXL)
Also adds MapFileResolver test for SPXL
2016-06-10 21:42:29 +02:00
Michael Handschuh e13a117b48 Adds ZipEntryNameSubscriptionFactory
This allows one to define a subscription as the set of symbols obtained from parsing the zip entry names in a zip file. This will be used by option universes in order to determine what contracts are available and provide a data source for contract filtering.
2016-03-17 10:55:47 -04:00
Juan Manuel Alvarez b3494afc47 Constants renamed to Globals.
Globals values can be reloaded from configuration.
2016-03-12 01:07:31 -03:00
snugs 0e1c756a19 Sets a default map-file-provider in LocalDiskFactorFileProvider 2015-12-31 14:20:38 -05:00
snugs b1b7bdfb60 Changes to support IFactorFileProvider impls 2015-12-16 18:45:22 -05:00
snugs a7a6ec8185 Adds IFactorFileProvider and LocalDiskFactorFileProvider 2015-12-16 17:09:42 -05:00
snugs a0bb89301e Adds MapFileRow.ToString overload - easier debugging 2015-12-15 10:04:05 -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 35ce0342f9 Tidy up some usages of Symbol.Value/ToString
Includes other small changes from review
2015-11-19 16:23:41 -05:00
snugs 2a3f8ed294 Handle symbol serialization manually for backwards compatibility 2015-11-17 11:56:59 -05:00
snugs 810a39f91b Make MapFileResolver.Empty readonly 2015-11-16 14:23:38 -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
snugs 7b6c82841f Initial implementation of SecurityIdentifier 2015-11-12 13:55:42 -05:00
QuantConnect 785e94d209 Tidy up of the ToolBox project to reduce duplicated code 2015-10-08 17:56:49 -04:00