Commit Graph

38 Commits

Author SHA1 Message Date
Martin Molinero 14c779733b Address reviews 2019-06-04 17:16:52 -03:00
Martin Molinero ee4f8fee82 Overall performance improvements
- `TimeSliceFactory` will avoid creating empty collections
- `ExecutionModels` will check target collection count before trying to
enumerate
- Reduce calls to .`TotalPortfolioValue`
- `SecurityValues` will only be created when required
- `TimeKeeper` will use TimeZone unique Id as dictionary key. The
TimeZone hash is expensive.
- `AlgorithmManager` will avoid calling `DateTime.UtcNow`,
`ConvertFromUtc()` and `RoundDownInTimeZone()`
2019-06-03 15:09:02 -03:00
Martin Molinero 177d786ac5 Removing internal currency subscriptions
- `UniverseSelection` class will now keep track and remove internal
currency subscriptions through the usage of new class
`CurrencySubscriptionDataConfigManager`
- Modifying existing regression tests to assert bug 2773.
- Adding new regression test that fixes the case where a new cash is set
after initialization. This could happen during cash sync performed by
the `BrokerageTransactionHandler`.
    - Adding new `CashAdded` event for the `CashBook` to solve the
    issue.
2018-12-21 17:31:47 -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 70b370ef25 Addressing reviews
- Removing `Subscription.HasSubscriptionRequests`
2018-11-08 13:02:12 -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
Martin Molinero 9bdf702c41 Creating new Synchronizer - TimeSlice streamer
- 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
2018-10-19 15:36:08 -03:00
Martin Molinero ff2ef7962c SubscriptionSynchronizer will depend on a Time Provider for determining next frontier.
Adding new SubscriptionFrontierTimeProvider which updates current time based on the current data emit time of all subscriptions.
2018-09-06 15:48:07 -03:00
Michael Handschuh 80e01e0d1f Add support for removing universes
Adds the concept of universe disposal which is requested by an algorithm
through invocation of UniverseManager.Remove, which is invoked via
algorithm.RemoveSecurity. This instructs the data feed that the algorithm
has requested to completely remove the universe and any child subscriptions
from the feed. Security changes are fired for all removed securities.
2018-05-30 15:55:33 -04:00
Stefano Raggi 50ab5178e2 Fix threading bug in EnqueueableEnumerator.MoveNext
With the enumerator in blocking mode (backtesting), MoveNext was returning true while Current was being set to null.
This was causing a NullReferenceException in SubscriptionSynchronizer.Sync.
2018-05-25 22:04:35 +02:00
Michael Handschuh 5d69b2a5e2 Remove disposed security data from TimeSlice
If we pull data and on the same time step that security gets removed,
we can still get that data in OnData(Slice) even though it was removed.
This change filters out removed securities by tracking a reference to
the subscription's disposed flag. Another change was made to wait until
the end of the time step to dispose of subscriptions.

Add IDataFeed.GetSubscription(SubscriptionDataConfig)
2018-05-24 17:40:29 -04:00
Michael Handschuh 891ab365ab Reverse a day when reading fine data
The fine enumerator factor accepts a 'date'. This date is that day
that the data is produced, so the emit time on that data is midnight
the following day. When we go to read the fine data we can't use the
current time because that's the 'emit time' -- instead we need to back
the time up a full day to find the correct start time. In addition,
the fine data was being read using UTC time stamps which led to even
more confusion here -- this change resolves both issues.

In addition to the above, the security.Fundamentals property wasn't being
properly set for the first time step when a security is selected due to
a bug in the subscription synchronizer not clearing out the universeData
in preparation for another loop (in the event changes != None).
2018-04-27 14:54:07 -04:00
Michael Handschuh b7e56360df Hack fine universe data into the algorithm
Fine universes are considered special due to their chaining behavior with
the coarse universe. UniverseSelection.ApplyUniverseSelection manually
reads the fine data for symbols that have passed the initial coarse filter.
There doesn't exist a mechanism for pipe this data back to the data feed
for inclusion in the TimeSlice object. As such, this hack relies on reference
semantics to updates the BaseDataCollection to include the merged coarse and
fine fundamental data.
2018-04-24 18:23:01 -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
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
Michael Handschuh ab92564e2d Fixes options chain underlying price data
The underlying price data was offset one time step in the future due to the
usage of `subscription.Current` after we've performed the synchronization loop.
At this time, `subscription.Current` is guaranteed to either be null
(`EndOfStream`) or be ahead of the frontier
2018-02-13 15:20:04 -05:00
Michael Handschuh d3ec0facc3 Add ISubscriptionSynchronizer interface
Provides an abstraction point allowing us to easily substitute in a different
synchronization algorithm. This isn't 100% complete as I'm hopefully able to
remove the universe selection dependency from the synchronization implementation.
2018-02-06 19:52:31 -05:00
Michael Handschuh db42b8a608 Move frontier to subscription synchronizer
The concept of subscription frontier is only relevant to the subscription synchronizer.
This change removes the back and forth communication of the frontier data between the
data feed component and the synchronizer component

This caused a change in the CoarseUniverseTop5DollarVolumeAlgorithm. The changed values are
due to the subscriptions now correctly stopping before the turn of the new year. The exact
same number of data points are emitted and the same trades are made, but due to the subscription
stopping slightly sooner (correctly), we lose a benchmark sample which caused a slightly different
beta to be computed (along with dependent statistics).
2018-02-06 19:52:31 -05:00
Stefano Raggi d76a1ae040 Minor performance fix in SubscriptionSynchronizer.Sync
This method was adding unnecessarily two types of DataFeedPacket objects.
The first type of packet contained the coarse data just used for universe selection, the other one contained only empty packets.
Since these packets would be filtered out later anyway, there is no point in passing them to TimeSlice.Create which needs to enumerate them.
2017-12-29 16:53:28 +01:00
Michael Handschuh 9de555716d Properly round times in SubscriptionSynchronizer 2017-10-02 12:16:06 -04:00
Michael Handschuh 6292f1e286 Clean white space 2017-10-02 12:16:05 -04:00
quant1729 c253c22ddd Merge branch 'master' into futures 2017-01-13 12:12:28 +08:00
Stefano Raggi ec5d4c0621 Filter consolidator inputs on data resolution
This update reverts PR #664 and includes an improved filtering solution.

It prevents consolidators and indicators from receiving inputs at a resolution higher than the data subscription resolution, typically fill-forward bars.
Volume-based indicators and consolidators will now be calculated correctly with fill-forward data.

It also fixes the RegressionAlgorithm failing test.
2017-01-12 00:56:58 +01:00
quant1729 5a57b4d25b Merge branch 'futures' 2016-12-29 22:12:58 +01:00
Stefano Raggi 29e2319400 Add date check for fill-forward data in SubscriptionSynchronizer
Before this change, fill-forward pre-market data was getting rounded down to the previous day, causing problems with consolidators and indicators.
2016-12-22 00:11:26 +01:00
quant1729 11d56db7d6 Fixed the bug that prevented option backtesting from running 2016-10-13 20:56:03 +02:00
quant1729 8494c9e1cf Added support for futures backtesting 2016-10-13 15:36:05 +02:00
Stefano Raggi e66f07b2f7 Handle OptionChainUniverseDataCollection in SubscriptionSynchronizer 2016-07-31 03:09:24 +02:00
Stefano Raggi 583e5cb7b6 Fix SubscriptionSynchronizer for universe selection with coarse data
Now UniverseSelectionRegressionAlgorithm regression test is passing
2016-07-17 15:07:31 +02:00
Michael Handschuh 348c601aae Aggregate universe data before invoking
Before now, universe data was provided as a single subscription.
Now, you may have many subscriptions feeding one universe, so we
aggregate the universe data and then invoke universe selection.

This change also removes the restriction of a single subscription
per symbol
2016-07-13 23:29:06 -04:00
Michael Handschuh 14776c6c21 Adds subscription configuration to DataFeedPacket ctor 2016-04-12 19:06:55 -04:00
Michael Handschuh a3d7d66554 Converts cache list kvp to list DataFeedPacket 2016-03-02 20:36:20 -05:00
snugs b6ae391678 Count BaseDataCollection.Data.Count towards data point counts 2015-12-09 16:36:12 -05:00
snugs 234e76c06f Remove EnqueueableEnumeator.EnqueueRange
Now using BaseDataCollection to ferry universe data around
2015-12-09 15:05:10 -05:00
snugs 471b8eb3de Remove UniverseSelectionEventArgs 2015-12-09 13:32:28 -05:00
snugs 74c5e06db8 Remove universe selection events 2015-12-07 12:21:49 -05:00
snugs 0d36b7cd2a Rename SubscriptionSyncer->SubscriptionSynchronizer 2015-12-07 12:06:38 -05:00