Commit Graph

125 Commits

Author SHA1 Message Date
Martin Molinero e8660d9f52 Address reviews 2019-06-17 23:40:56 -03:00
Martin Molinero 65201cb808 Adding StepTimeProvider for live
- Adding new `StepTimeProvider` that will advance time based on a
desired custom evaluator.
- Live trading `Options`, `Futures` and `Coarse` data will use a
`FrontierAwareEnumerator` + `StepTimeProvider`. This will allow to hold
the selection data until its the desired time
- `Universe.CanRemoveMember` will round the members time in the universe
based on the `UniverseSettings.MinimumTimeInUniverse`
2019-06-17 23:40:55 -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 0c20ca870b Merge pull request #3088 from AlexCatarino/feauture-3082-universe-settings-data-normalization-mode
Implements UniverseSettings.DataNormalizationMode
2019-04-17 15:44:14 -07:00
Martin Molinero 771256fd2c Fix live coarse data subscription
- When subscribing to `Coarse` data the `LiveTradingDataFeed` will use
the normalized `CoarseFundamental Universe Symbol` for that market ->
not using the random GUID
- Adding unit tests which reproduce issue.
2019-04-17 17:18:33 -03:00
AlexCatarino c151fd51de Adds Missing Argument in OptionChainUniverse and Universe 2019-04-17 15:18:04 +01:00
AlexCatarino e92a40192d Implements UniverseSettings.DataNormalizationMode
Implements `DataNormalizationMode` field in `UniverseSettings` to enable the settings of a desired `DataNormalizationMode` to the securities that are chosen in Universe Selection.
2019-04-17 15:18:03 +01:00
AlexCatarino e4e3ee6524 Adds Constructor Overload with PyObject to ScheduledUniverse
Adds constructor overload that accepts a PyObject representing a `Func<DateTime, Symbol[]>` object to `ScheduledUniverse`. With this overload, we are able to create a `ScheduledUniverse` with a selector defined in a python script.
2019-04-08 22:10:36 +01:00
Martin Molinero 91f19f781d Implement AddUniverseSelectionModel
- Implementing `QCAlgorithm.AddUniverseSelectionModel`
- Adding C#/Py regression algorithms using the new API
- Modifying `ManualUniverSelectionModels` symbol, adding hash of
the selected `Symbol.Values`
- Modifying `Coarse` and `Fine` symbol, adding random GUID
- Adding `NullUniverseSelectionModel`
2019-04-08 16:58:42 -03:00
Stefano Raggi 10329ed293 Fix time zone bugs in SubscriptionDataReader
In a few places SubscriptionDataReader was incorrectly assuming the TradeableDates were in ExchangeTimeZone instead of DataTimeZone.
This issue was found specifically with CFD assets which have the exchange time zone ahead of the data time zone.
2019-03-14 12:10:01 +01:00
Martin Molinero 75f4ecaf54 Remove unused SubscriptionDataConfigs
- After removing a `Subscription` entirely, we will now also remove the
matching `SubscriptionDataConfig` from the `SubscriptionManager`
- Adding a new regression test, which fails in `master`
- Fixing previous PR change that removed `Trace` logging when adding
and removing a `Subscription`
- Fixing a bug in the `UserDefinedUniverse` where calling `RemoveMember`
would cause the `SubscriptionDataConfig` to be re added to the
`SubscriptionManager` (not the `DF`). Found this through added
regression test.
2018-11-15 11:35:31 -03:00
Jared 988abaa0a4 Merge pull request #2662 from Martin-Molinero/refactor-2616-track-universes-requesting-subscription
Subscriptions will track Universe requests
2018-11-09 09:05:19 -08: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 de32c3aefd Update future universe enumerator stack to refresh every day
- The DataQueueFuturesChainUniverseDataCollectionEnumerator now reloads the future chain from the IDataQueueUniverseProvider when the date changes.
2018-11-08 15:00:43 +01:00
Martin Molinero a288648929 Creating new ISecurityService
- Adding new ISecurityService and its implementation SecurityService.
Expose by SecurityManager.
This class will expose a method for creating new securities. The
SecurityManager is exposing this new interface, calling _securityService
internally, so Future/OptionUniverseSelectionModel.cs can use it
- Replacing all usages of SecurityManager.CreateSecurity for new
ISecurityService
- Modifying `Cash.cs` and `CashBook.cs` `EnsureCurrencyDataFeeds()` to
return newly added `SubscriptionDataConfig` instead of `Security`. This
will avoid using `Security.Subscriptions` at call site.
- Moving old SecurityManager.CreateSecurity into new
SecurityServiceTests.cs
2018-10-18 16:25:32 -03:00
Martin Molinero 5221999b88 Addressing reviews
- Some formatting, comments changes
- Removing SubscriptionManager from new FuturesChainUniverse constructor
- Making Option and Future properties in FutureChainUniverse and
OptionChainUniverse
2018-10-04 16:08:12 -03:00
Martin Molinero 7f1471000a Address reviews - Obsolete Constructors
- Adding new and obsoleting old constructors which received
SecurityInitializer as a parameter.
- Extracting the setting of Underlying security at UniverseSelection for
Option and Future chain universes.
2018-10-02 16:22:00 -03:00
Martin Molinero 4e424c4f19 Refactor UserDefinedUniverse, UniverseSelection
- Obsolete Universe.CreateSecurity, Universe.SetSecurityInitializer,
Universe.GetSubscriptionRequests(Security security, DateTime currentTimeUtc, DateTime maximumEndTimeUtc)
- Adding new GetSubscriptionRequests() overload that will receive
instance which implementes new ISubscriptionService
- UserDefinedUniverse will stop using Security.Subscriptions
2018-10-02 09:59:23 -03:00
Stefano Raggi a93817f790 Fix SetSecurityInitializer when called after AddUniverse 2018-06-08 16:10:46 +02:00
Stefano Raggi 2ff5650b4a Add price and split factors to CoarseFundamental class 2018-06-01 12:19:06 +02:00
Michael Handschuh ad331118ab Add refresh to IUniverseSelectionModel to support dynamic universes
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.
2018-05-31 11:48:23 -04:00
Michael Handschuh 43a7d0c3e8 Rename HasDiffs to AreDifferent
No need to be so terse :)
2018-05-30 15:55:34 -04: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
Michael Handschuh f7db6d2442 Add LinqExtensions.HasDiffs method
Implementation is simplified form of that used to detect diffs
in universe selection (selection updated to use simplified form
as well)
2018-05-30 15:54:06 -04:00
AlexCatarino 381e30da4d Implements ConvertToDelegate helper method 2018-05-10 19:08:34 +01:00
AlexCatarino 787e820247 Adds PyObject overload to FineFundamentalUniverse
Adds PyObject overload to `FineFundamentalUniverse` to be able to pass a selector defined in python.
2018-05-09 11:36:18 +01:00
AlexCatarino 433feff1df Implements python version of FundamentalUniverseSelectionModel
- This version serves two purposes: example of universe selection model and base class for other universe selection models, since the pythonnet doesn't deal well with inheritance of abstract classes.

- Adds PyObject overload to `CoarseFundamentalUniverse`.
2018-05-08 18:54:17 +01:00
Michael Handschuh 5879e477b7 Mark delisted securities as not tradable
Add regression test for delisted/tradable flags.
Add Security.IsDelisted to flag.
2018-05-07 11:41:24 -04:00
Michael Handschuh 351ac55f7f Rework implementation of maintaining tradable flag
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.
2018-05-02 20:00:37 -04:00
Michael Handschuh f4690ef6f2 Add UniverseManager.ActiveSecurities
Fetches the unique set of securities that are currently members of at least one
universe. This is the set of active/tradable securities that are currently receiving
data. It does not guarantee that we've received pricing data, but does guarantee that
the security is a member of the universe and we've minimally added a subscription for
data and have not yet removed that subscription (although it is possible for the sub
to end before the security is removed -- very rare/unlikely scenario though).
2018-05-02 13:27:15 -04:00
Michael Handschuh 3db242203e Add ScheduledUniverseSelectionModel
The ScheduledUniverseSelectionModel wraps the new ScheduledUniverse.
ScheduledUniverse is similar to the UserDefinedUniverse we use to create
universes for dopbox/remote files w/ symbol listing. The new abstraction
that 'turns on' this no-data/scheduled based universe behavior is the
ITimeTriggeredUniverse, which exposes GetTriggerTimes which yields the
date/times your univese selection function will be called.

A regression algorithm was also added to cover the new feature.
2018-04-10 19:24:36 -04:00
Michael Handschuh cf7cd7e1fb Define ITimeTriggeredUniverse
Provides a common abstraction for UserDefinedUniverse and the
yet-to-be-impemented ScheduledUniverse. Categorized by the fact
that they don't operate on data, but instead a fixed schedule and
any data required is fetched through external means, such as a
web request.
2018-04-10 19:24:36 -04:00
Michael Handschuh 5ef9401fda Remove unnecessary cast, use abstraction
The interface properly declares the required properties, so no
need to down cast to the concretion.
2018-03-19 12:40:54 -04:00
Michael Handschuh 05dd29b645 Add SecurityChanges.Count 2018-02-12 11:13:09 -05:00
Stefano Raggi 9e54be123f Add time range check in ApplyUniverseSelection 2017-11-14 20:39:49 +01:00
Michael Handschuh 7124ddff3f Revert "Merge pull request #1225 from QuantConnect/bugfix/universe-select-benchmark"
This reverts commit 0df445c9a8, reversing
changes made to b2095907fd.

Memory instability was reported during live trading. Internal feed defaulting to false
is suspected cause.
2017-10-20 11:52:11 -04:00
Michael Handschuh 3e19d9b458 Make subscriptions from universes force non-internal feed 2017-10-19 13:28:11 -04:00
Stefano Raggi d972c4d0a5 Fix subscription sharing issue with universe selection in backtesting
In backtesting with universe selection, when symbols are be added and removed the next day, we have experienced slightly different backtesting results for the same algorithm. This was caused by invalid factors applied to equities due to the sharing of a SubscriptionDataConfig instance between two threads.

The issue was solved by calling the SubscriptionDataConfig copy constructor in Universe.GetSubscriptionRequests.
2017-09-21 00:21:34 +02:00
12112 921ec8f983 merge from upstream 2017-08-22 16:56:35 +01:00
12112 83fdf9c386 crypto wip 2017-07-14 16:53:42 +01:00
Stefano Raggi ba1e462fc4 Fix open interest bug setting value to zero for contracts added intraday
When using a filter function creating a dynamic chain universe, contracts added during the day would be set to zero.
2017-06-30 18:31:32 +02:00
Stefano Raggi f9fdd82b06 Time-based removal of option contracts from universe in live mode
Previously, removal of option contracts from the option chain universe was allowed only on date change (in both live and backtesting).

Now, in order to reduce market data subscriptions in live mode, removal is allowed intraday if the contract has been in the universe for at least 15 minutes. When backtesting, behavior is unchanged.
2017-05-24 22:23:25 +02:00
Stefano Raggi e1710e9031 Remove BaseData underlying symbol from Future symbol 2017-04-17 13:52:23 +02:00
quant1729 fba955a229 Removing code that created duplicate subscription configs. Currently the responsibility to create appropriate data types for the new security is localized in security manager, and there is no need to duplicate it. Duplicate configs prevented consolidation from working for futures/options contracts. 2017-02-07 19:14:08 +08:00
Andrew Hart 46b74f6bae Refactored GetDataType into LeanData
This method is used by both Future and OptionsChainUniverse.  This method is useful, espeically in the SecurityManager.  It will eventually be used there.
2017-01-06 11:48:25 -05:00
quant1729 36a83dc44c Added sample option filter universe algorithm code. Tests. 2016-12-29 13:59:45 +01:00
quant1729 cf8163fc3a Refactored option/future universe filters for performance improvements and versatility 2016-12-29 11:44:15 +01:00
quant1729 705024cd89 Merge branch 'futures'
Conflicts:
	Common/QuantConnect.csproj
2016-12-20 15:53:24 +01:00
Stefano Raggi de037ad4ef Universe selection with FineFundamental filtering - backtesting and live 2016-12-06 15:44:41 +01:00
Andrew Hart e5377bdd82 Options/Futures ChainUniverse uses AvailableDataTypes to create subscriptions 2016-11-23 15:25:58 -05:00