- 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`
- Removing usages of Security.Configuration properties from existing
Volatility Models, without modifying existing interfaces. Adding unit
tests for existing behavior
- Adding new BaseVolatilityModel, which will have a setter for a
ISubscriptionDataConfigProvider which will be called by the system.
Adding unit tests for this behavior.
- Adding new `SubscriptionDataConfigExtensions` static class which will
provide methods used to determine different configuration properties for
a given set of `SubscriptionDataConfigs`. The behavior was extracted
from current `Security` class behavior regarding the `SubscriptionBag`.
Adding unit tests covering exepected behavior here.
- Creating new `Synchronizer` which will consolidate and combine `TimeSlice`
streaming for both live and backtests modes. Will live in front of the
`DataManager`
- `SubscriptionSynchronizer` will be the `FrontierTimeProvider` exposed,
and owned, by the new `Synchronizer`
- Updating existing tests
LEAN currently lacks support for dividend payable dates, and as such
it's incorrect to apply the dividend on the ex-date (backtesting behavior).
We'll pick up the additional cash in the account by means of the daily
cash sync performed by the BrokerageTransactionHandler
It's important we see the before/after and the data used to make the change.
This will aid in debugging potential misapplications of split/dividend events.
This change allows the universe selection model to select different universe
definitions as time proceeds. This enables the definition of a universe model
that, for example, could add option chains for securities selected by a different
universe model.
The BasicTemplateOptionsFrameworkAlgorithm was added to showcase and provide
regression for a universe model that selects different universes.
The previous implementation had some issues and introduced undue
complexity. This implementation follows established patterns of
having the algorithm manager apply changes to the algorithm that
result from universe selection.
We never want universe data to impact a security's price or other cache
properties. To that end, this change adds another way of adding data to
the cache that simply stores the data for retrieval and does NOT update
any of the security cache properties. The check for aux data was left in
to prevent aux data from setting security prices as well.
Universe data is piped through the TimeSlice and saved in the
security cache in the algorithm manager for consumption by the
algorithm.
This change includes an update to SecurityCache.AddData to preclude
us from setting the security price using auxiliary data. Tests were
updated accordingly.
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.
Universe.Configuration.Resoluton is intended to describe the resolution of the universe data
and NOT the resolution of any subscriptions added by the universe. Universe subscription
resolutions are defined by either Universe.UniverseSettings.Resolution or if null,
IAlgorithm.UniverseSettings.Resolution
We had an issue with the data feed picking up universe/security changes
too quickly, thereby preventing user code from being able to configure the
security object properly. Specifically, users were having an issue setting
the data normalization mode of options and underlying equity securities. By
the time the user code had set the data mode, the data feed had already
created a subscription and began processing it, so the changes were never
seen in the data feed.
This change moves all security/universe changes into pending lists and at
the end of the time step applies those changes. Security objects are still
added directly to the SecurityManager for instance access, but we delay in
adding the security to the universe and the universe to the UniverseManager.
Once added to the universe manager, an event is fired and the data feed will
process the new subscriptions.
The term 'alpha' is used to describe the entire algorithm. Therefore, 'alpha'
produces insights. From this we have things like IAlphaModel, which is the model
defining how insights are produced. We have IAlphaHandler, which defines how the
insights from a single 'alpha' (the algorithm) are managed, analyzed, and stored.
Types closer to the individual prediction level, such as InsightDirection, or
InsightScore relate directly to exactly 1 insight. The distinction between the
two became more clear as we developed the insights API, and from that effort it
was decided to harmonize alpha/insight terminology across the various QC systems.
When creating time slices for warmup history requests, data for security types with multiple tick types (Crypto, Futures, Options) were being matched to the configuration for the first subscription, instead of using the correct data type.
For example, with the Crypto security type, historical data of type TradeBar was passed to TimeSlice.Create with a SubscriptionDataConfig object for the QuoteBar data type.
Instead of tracking just the security's symbol in the cash object we're now
maintaining a reference to the actual security object. This removes the need
to worry about cash update data in the time slice create method.
The logic for margin calls was previously split between SecurityPortfolioManager.ScanForMarginCall and IMarginCallModel methods, now it is entirely contained within margin call model implementations.
One of the margin call model tests was also testing against the Null model, it has been updated to use the DefaultMarginCallModel.
Using the newly added split warnings, submit market on close order at the last
possible moment to liquidate option contract holdings. After the liquidate order
has been submitted, we now mark the option contract as non-tradable, thereby
preventing any further trading in post-split option contracts.
This is added because we currently do not properly support option contract splits.
To properly support, we'll need some extra data sources defining how the contracts
are rewritten due to the split event. This data is freely available via the OCC in
pdf format.
This method was not removing the symbol dictionary entry when removing the last subscription, allowing the collection to grow excessively over time (especially with universe selection algorithms).
This PR also includes a few minor performance fixes.
This PR is an attempt to reduce contention in concurrent dictionaries, replacing method calls using full locks with lock-free equivalents:
- dictionary.Count -> dictionary.Skip(0).Count()
- dictionary.Keys -> dictionary.Select(x => x.Key)
- dictionary.Values -> dictionary.Select(x => x.Value)
The most frequent usages of these methods are: CashBook, SecurityManager, UniverseManager and indirectly, SecurityPortfolioManager.
The reasons for this update are explained very clearly in this article:
https://arbel.net/2013/02/03/best-practices-for-using-concurrentdictionary/
Provides estimates of alpha value as well as performs online computations of
alpha scores and other KPIs.
Sends alpha stats to result handler
Update live result with framework flag