Commit Graph

68 Commits

Author SHA1 Message Date
Martin Molinero ed5f7ab58c Moving price scale factoring to new enumerator
- Adding new `PriceScaleFactorEnumerator` that will scale raw prices
based on a provided `SubscriptionDataConfig` and update the
`SubscriptionDataConfig.PriceScaleFactor`. Adding unit tests.
- `BaseData` factories (`TradeBar.cs`, `QuoteBar.cs`, `Tick.cs`) will
no longer scale factor prices, they will generate data points in raw
mode.
- `SubscriptionDataReader` will no longer update the
`SuscriptionDataConfig.PriceScaleFactor`
- Fix `BrokerageTransactionHandlerTests` unit test that was having a
race condition.
2019-02-27 15:11:34 -03:00
Stefano Raggi 4e241dec52 Add missing list materialization in AuxiliaryDataEnumerator
- restored includeAuxiliaryData to false in SubscriptionDataReaderHistoryProvider
2019-01-17 20:22:49 +01:00
Stefano Raggi 24ccda8b9a Update SubscriptionDataReaderHistoryProvider to handle symbol changes 2019-01-17 12:49:16 +01:00
Martin Molinero 0933da9303 Refactor previous commits
- Removing `AccountCurrency` from `Cash` and `Brokerage` classes.
`ICurrencyConverter` will now provide the `AccountCurrency`
- Adding new static `OrderFee.Zero` which will return a 0 order fee in
`NullCurrency`
- Adding static `Currencies.USD` value, replacing all "USD".
- Addin new static `Currencies.NullCurrency`
- Updating Bitfinex `FeeModel` so it return fees in quote currency.
Adding unit tests
2018-12-13 11:30:40 -03:00
Martin Molinero 75ffa300f1 Adding new IAlgorithm.AccountCurrency
- Adding new `IAlgorithm.AccountCurrency { get; }` that will point to the
`Portfolio.CashBook.AccountCurrency`. Setter will be added in a
following PR.
- Base `Brokerage` class will now have a `AccountCurrency { get }`
pointing to the `IAccountCurrencyProvider`. Will be used by the different
brokerages implementations.
2018-12-10 11:59:02 -03:00
Jared 54fbf36be8 Merge pull request #2671 from Martin-Molinero/refactor-2429-corporate-events-own-enumerator
Move corporate events to new enumerators
2018-12-03 10:45:44 -08:00
Martin Molinero dea0fe2674 Implementing composition over inheritance
- Mappings, splits, delisting and dividends will be
`ITradableDateEventProvider` that will be handled by
the `AuxiliaryDataEnumerator`.
2018-11-20 16:17:44 -03:00
Martin Molinero 6db7f13dca Addressing reviews
- Will now use the `SynchronizingEnumerator` and avoid the duplicated
synchronization logic.
- Slightly modified the `SynchronizingEnumerator` implementation to
avoid removing enumerators with current `null` returning `true`. Adding unit tests
- Adding unit tests for `DelistingEnumerator`
- Fixing issue where price was not correctly set. Adding new check for
`HourSplitRegressionAlgorithm`
2018-11-20 15:50:19 -03:00
Martin Molinero a746dd0137 Move corporate events to enumerators
- Moving `Splits`, `Dividends`, `Mappings`, `Delistings`, from the
`SubscriptionDataReader` into there own enumerator, inheriting from
new `CorporateEventBaseEnumerator`
- Adding new helper `static class CorporateEventEnumeratorFactory` to
create the new enumerators
- Adding unit tests for new `CorporateEventBaseEnumerator`
- Adding some extra checks to `HourSplitRegressionAlgorithm` and
`DelistingEventsAlgorithm`
2018-11-20 15:50:19 -03:00
Martin Molinero 7ab6a374cf Addressing reviews
- `TimeSliceFactory` `TimeZone` will now be a constructor parameter
2018-11-14 19:12:45 -03:00
Martin Molinero 251071ee73 Remove Security from Subscription
- Removing unneeded `CashBook` instance to create a new `TimeSlice`
- Adding new `TimeSliceFactory`, an instance base class that will
provide methods to create a new `TimeSlice`. Will own the `DateTimeZone`
property.
- Adding new `ISecurityPrice` and `IOptionPrice` that will provide a
reduced interface for accessing price properties and methods used when
creating a new `TimeSlice`
2018-11-14 18:28:18 -03:00
Martin Molinero ee2dc32710 Subscriptions will track Universe requests
- The class `Subscription` will internally track each `Universe`
`SubscriptionRequest` added or removed
- Adding regression test in which two different `Universe` request the
same `SubscriptionDataConfig` and one of them removes/adds it in a
toggle fashion (fails on current master)
- `UniverseSelection` pending removals will also be tracked by
`Universe`
- `UniverseDecorator` will overwrite the `Universe` member of
`SubscriptionsRequests` at `GetSubscriptionRequests()`. This is due to
`this != this,Universe`
- Adding `Subscription` unit tests covering expected behavior
- Extracting pending removals logic from `UniverseSelection` class into
a new helper class `PendingRemovalsManager`. This new class will keep
track of the `universes` requesting to remove a security. Adding unit tests
2018-11-08 13:02:11 -03:00
Stefano Raggi 44412f2273 Move HistoryProviderBase to QuantConnect.Common project 2018-10-14 23:07:09 +02:00
Stefano Raggi dbaf109c78 Post-review updates
- Renamed events in SubscriptionDataReader and IHistoryProvider
- Added HistoryProvider base class with events and event invocators
2018-10-14 22:29:06 +02:00
Stefano Raggi 9fad26bc8f Add events to IHistoryProvider and SubscriptionDataReader
The SubscriptionDataReaderHistoryProvider was using StubResultHandler, so no error messages were being shown or logged. By adding events to IHistoryProvider and SubscriptionDataReader, the dependency on IResultHandler could be removed completely and error messages are now pushed up the stack.
2018-10-14 22:29:04 +02:00
Stefano Raggi 77b37f4dfd Update IHistoryProvider.Initialize to use HistoryProviderInitializeParameters
This is only a mechanical refactor for the updated IHistoryProvider.Initialize method in all IHistoryProvider implementations, call sites and unit tests.
2018-10-14 22:29:02 +02:00
Martin Molinero 60a36b58d4 SineHistoryProvider wont use Security Config Prop
- Modifying `SineHistoryProvider` so it does not use `Security`
configurations properties, including `Security.Subscriptions`.
   - `SineHistoryProvider` will create SDC based on the `HistoryRequests`,
   as done in other HistoryProviders
2018-10-11 18:00:45 -03:00
Michael Handschuh 20133d40d1 Add ICurrencyConverter to Security constructors
Security instances will require private access to this value in order to
compute close profit.

NOTE: The extent of these changes for simply adding a constructor argument
insinuates that we're missing an abstraction to manage the construction of
these objects, such as a factor object for Security. This will need some
careful TLC in the near future.
2018-10-10 11:17:12 -04:00
Michael Handschuh a5179bc6ab Add universe data to TimeSlice
Pipes universe data from the data feed, through TimeSlice.Create and adds
TimeSlice.UniverseData dictionary property for read access from the algo
manager, where the data will be placed onto the correct security object.
2018-04-24 18:23:00 -04:00
AlexCatarino 6799558d0d Adds SineHistoryProvider
This toy HistoryProvider implements a history provider that always return a IEnumerable of Slice with prices following a sine function.
2018-04-11 11:11:32 +01:00
Michael Handschuh cee7ff7766 Move clone and tz conversion operations to DF thread
A large percentage of synchronization time is spent performing time zone conversions.
Previously, it was possible that we may compute the same tz conversion multiple times
on the same piece of data until it's emitted. This change moves the time zone conversion
logic onto the data feed thread right before it puts the data into enqueueable enumerator.
In addition, we're not performing the clone operation at the same moment. This removes
unnecessary computation while moving the necessary computation to the data feed thread to
lighten the load on the synchronization/algorithm thread.
2018-02-13 15:59:56 -05:00
Jared Broad aefdfcc411 Add the cashbook to the result packet 2017-10-23 17:00:28 -04:00
Michael Handschuh 6f1c07d488 Add dataTimeZone to FillForwardEnumerator 2017-10-02 12:16:06 -04:00
Michael Handschuh 6292f1e286 Clean white space 2017-10-02 12:16:05 -04:00
Andrew 08bb34a1eb Add TickType field to the HistoryRequest class 2017-08-22 09:42:42 -04:00
Andrew a855a7c545 Renamed HistoryRequest.TimeZone to DataTimeZone 2017-08-21 15:06:29 -04:00
Stefano Raggi e4509d1a5c Add QuoteBarFillForwardEnumerator 2017-08-15 12:22:41 +02:00
Andrew b77502f35b All Results handler inherit from the BaseResultsHandler 2017-08-08 12:52:12 -04:00
Stefano Raggi cf2673f700 Synchronization of GetHistory results with multiple symbols in Live mode
Previously, in Live mode, requesting History for multiple symbols in a single call returned an IEnumerable<Slice> concatenating the results of each request, so every Slice only had one data point and the list was not sorted by time.

This problem has been solved in the following steps:
- Added a new BrokerageHistoryProvider, to be used in live mode with all brokerages
- Removed IHistoryProvider implementations from IB, Oanda, FXCM brokerages
- Added new GetHistory(request) method to IBrokerage interface and implementations
- Moved CreateSliceEnumerableFromSubscriptions method from SubscriptionDataReaderHistoryProvider to the new abstract base class SynchronizingHistoryProvider, to enable reuse in BrokerageHistoryProvider
2017-03-13 00:56:42 +01:00
Andrew 05ec92349e Added SystemDebugPacket 2017-02-24 17:51:57 -05: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
Stefano Raggi ed4a7efefc Add missing DataNormalizationMode in history requests
Previously, DataNormalizationMode in history requests was always being set to the Adjusted default value, so SetDataNormalizationMode calls were not being respected in SubscriptionDataReaderHistoryProvider.GetHistory and warmup.
2017-01-31 23:50:52 +01:00
Andrew fdea52a933 Renamed XxxFileProvider to XxxDataFileProvider 2016-10-20 08:36:36 -04:00
Andrew bcd3cb6b10 FileProvider can now be configured in config.json
The DefaultFileProvider is now configured as by default as the file-provider in config.json and passed in the the engine through the leanAlgorithmHandlers object.

The FileProvider is now passed into the TextSubscriptionDataSourceReader and ZipEntryNameSubscriptionDataSourceReader.  Most of the changes in this commit are just getting the FileProvider to those two methods.
2016-10-17 15:52:11 -04:00
Michael Handschuh 14776c6c21 Adds subscription configuration to DataFeedPacket ctor 2016-04-12 19:06:55 -04:00
Michael Handschuh 70a56ab8bc Adds subscription configuration to Subscription ctor 2016-04-12 19:06:51 -04:00
Michael Handschuh a3d7d66554 Converts cache list kvp to list DataFeedPacket 2016-03-02 20:36:20 -05:00
Michael Handschuh 38248d641e Adds symbol properties to Security ctor 2016-02-16 13:26:02 -05:00
Michael Handschuh 0042586b6a Adds quote currency to Security ctor 2016-02-16 13:26:00 -05:00
Michael Handschuh 96a5e76729 Adds IBrokerageModel.GetLeverage(Security)
Also removes leverage as Security ctor parameter
2016-01-19 14:20:23 -05:00
snugs f1968d1217 Remove algo id from IResultHandler.SendStatusUpdate
IResultHandler has an Initialize method which accepts a job, so all instances should know
they job (algo id, proj id, user id) and so these methods shouldn't be requiring the field
2016-01-11 15:11:08 -05:00
snugs 7276626c98 Use IFactorFileProvider in SubscriptionDataReader 2015-12-16 17:09:43 -05:00
QuantConnect 2d9f8cb9e3 Updated charting lib to use series indexes instead of chart types. Obsolete ChartType enum 2015-12-10 13:03:50 -05:00
snugs e3d1c1dbb7 Only fetch map files for equities 2015-12-02 15:37:34 -05:00
snugs 95bfe729a8 Adds ExchangeTimeZone to SubscriptionDataConfig 2015-12-01 12:03:00 -05:00
snugs 1546f25898 Review usages of config.TimeZone 2015-12-01 11:30:36 -05:00
snugs 6f15d4e569 Rename SubDataConfig.TimeZone to DataTimeZone
Also reviewed usages to check for data time zone vs exchange time zone
2015-11-30 18:43:41 -05:00