Commit Graph

318 Commits

Author SHA1 Message Date
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 2967776130 Refactor AddToUserDefinedUniverse
AddToUserDefinedUniverse will receive configuration settings as parameters.
2018-10-02 09:59:33 -03:00
Martin Molinero d6f958b94a Rename to I...Service - Merge Create and Add 2018-09-28 14:48:21 -03:00
Martin Molinero d9f984a151 Remove unused AlgorithmSettings constructor parameter for SubscriptionManager 2018-09-26 14:08:48 -03:00
Stefano Raggi 04225dd691 Fix error getting account option holdings from brokerage 2018-09-13 13:01:41 +02:00
Stefano Raggi b4a2536b86 AddOptionContract - throw if existing underlying equity not in Raw mode
Also added OptionChainProviderAlgorithm to regression test suite
2018-08-21 14:51:43 +02:00
Martin Molinero 6da57a1e12 Improving GetMaximumOrderQuantityForTargetValue 2018-08-03 16:26:14 -03:00
Michael 8ec32c58af Merge pull request #2176 from AlexCatarino/bug-2030-download-method-ambiguous-call
Fixes ambigous call bug for Download method
2018-07-02 11:18:10 -04:00
Stefano Raggi 5eae88f06b Show warning when defaulting to Equity in SetBenchmark 2018-07-02 11:31:24 +02:00
AlexCatarino 4853e50dd2 Fixes ambigous call bug for Download method
Adds more overloads and remove the optional arguments.
2018-06-28 19:00:31 +01:00
Michael 2f33dbdcf9 Merge pull request #2096 from StefanoRaggi/bug-2062-setsecurityinitializer-after-adduniverse
Make SetSecurityInitializer update security initializers in existing universes.
2018-06-08 14:02:18 -04:00
Stefano Raggi 86f0209a2d Add check if SetSecurityInitializer called more than once 2018-06-08 18:17:22 +02:00
AlexCatarino bcbe25fa79 Adds exception for StartDate greater than Today 2018-06-08 17:09:55 +01:00
Stefano Raggi 47e3668803 Require SetSecurityInitializer to be called during Initialize 2018-06-08 16:58:51 +02:00
Stefano Raggi a93817f790 Fix SetSecurityInitializer when called after AddUniverse 2018-06-08 16:10:46 +02:00
Stefano Raggi 0a27af259d Add QCAlgorithm.GetParameters helper method 2018-06-07 15:06:50 +02:00
Stefano Raggi 8fe7651881 Add QCAlgorithm.ActiveSecurities 2018-06-06 21:45:48 +02:00
Stefano Raggi bbfe7a9beb Rename LatestSlice to CurrentSlice 2018-06-05 19:05:40 +02:00
Stefano Raggi 08f28a55cf Make the latest Slice received in OnData available to the algorithm 2018-06-01 18:24:09 +02:00
Michael Handschuh 42032ec328 Refactor setting of insight close/generated times
These times were being set AFTER they were copied, so the insights sent into
the portfolio construction model were the originals (uncopied) and then copies
that are sent into the event are then piped to the insight manager/alpha handler
for scoring, so interestingly, the scoring remained the same so regression tests
continued to pass because no types were written with a dependency on that data
other than the scoring, which as mentioned, got the copies with the correct times.
A recent change made use of this time and showcases this heinous bug in all its
glory.

This refactoring overrides the event invocator and seals the method to force
derived types to use the event handler, thereby guaranteeing that the event is
always invoked AFTER the generated/close times are properly set, also ensuring
that the copy is performed after the times are set as well.
2018-05-31 14:25:16 -04:00
Michael Handschuh 577c082b69 Confirm securities aren't in other universes before removal
Since we're moving towards better support of multiple universes,
it's important that we check that child subscriptions aren't in
those other universes before removing the security.
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
AlexCatarino 833c9f27f2 Adds overloads to QCAlgorithm logging methods 2018-05-24 12:13:42 +01:00
Stefano Raggi 637c153701 Add base OrderProperties class 2018-04-30 15:39:30 +02:00
Michael Handschuh dd764ad8e9 Rename InsightCollection->GeneratedInsightsCollection
This type is just used as a container for generatd insights. Renaming in
preparation for a new InsightCollection to mirror the PortfolioTargetCollection
2018-04-10 19:24:36 -04:00
Michael Handschuh 27b34a4274 Add IAlgorithm.OnEndOfTimeStep to batch universe changes
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.
2018-03-20 10:10:29 -04:00
Michael Handschuh 6b239674e2 Renames Alpha -> Insight
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.
2018-03-09 16:12:56 -05:00
Stefano Raggi 1943dcd99d Revert "Add duplicate security check in AddSecurity" 2018-02-20 15:07:03 +01:00
Stefano Raggi 79d33a5ea2 Add unit test for duplicate security check
Also updated error message to show user input parameters.
2018-02-17 01:29:31 +01:00
Stefano Raggi 74b4684dd3 Add duplicate security check in AddSecurity
AddSecurity was not checking if the security had already been added.
2018-02-15 20:06:54 +01:00
AlexCatarino 83fda60cb8 Adds user agent header to WebClient in Download method
Add a user agent header in case the requested URI contains a query.
2018-02-14 21:58:19 +00:00
AlexCatarino 654d6ad9ce Adds overloads with PyObject to Logging and Debug methods
We enable Logging and Debug methods to accept python objects to avoid the need of calling the str method.
Those objects are safely converted into string objects.
2018-02-09 00:48:44 +00:00
Michael Handschuh 667fde4786 Fixes bug w/ data feed initial frontier when changing default tz
Changing the default time zone after SetStartDate is set ends up with the algorithm's
UtcTime being incorrect. This can lead to incorrect start times in the data feed as
well
2018-02-06 09:29:13 -05:00
Jared 755a0f8ba7 Merge pull request #1475 from StefanoRaggi/symbol-null-comparison-fix
Fix bug in Symbol inequality operator
2018-01-15 17:15:26 -05:00
Stefano Raggi 89a59351cd Add OnWarmupFinished method to QCAlgorithm
This method is being added to allow algorithms to complete initialization tasks that cannot be executed during Initialize, such as cancelling existing open orders in live trading.
This method will be called only once, when the warmup task is complete.

Closes #1043
2018-01-15 13:46:30 +01:00
Stefano Raggi 1075571752 Replace Symbol.Empty checks with null checks 2018-01-12 21:56:10 +01:00
Michael Handschuh 0cc6a53e9c Set correct time zone for custom data in MarketHoursDatabase
Add MarketHoursDatabase.SetEntry and SetEntryAlwaysOpen. This allows runtime modification of the
market hours database which is necessary for correct custom data time zone handling.

Extracts complicate ternary logic into its own method and make it human readable.
Set the market hours entry for custom data universe subscriptions defaulting to the security's time zone.
2018-01-04 12:36:57 -05:00
Michael Handschuh b07928bd58 Properly account for market hours in alpha prediction periods
If we make a prediction for 1 day in the future, we actually mean 1 trading day.
This change updates the alpha analysis logic to take into account the security's
market hours.
2017-12-28 11:27:41 -05:00
Stefano Raggi c6693cb237 Disable automatic security seeding
In this PR we are disabling the default security seeding (automatically getting the last price for a security when added to the algorithm) for a couple reasons, both when using large universes:
- In live trading, these history requests are sent to a history server, potentially causing timeouts
- In backtesting, depending on the algorithm this could also cause slowdowns up to 30%
2017-12-22 21:49:14 +01:00
Jared 5f64665598 Merge pull request #1425 from QuantConnect/concurrency-fix
Reduce full locking on ConcurrentDictionary objects
2017-12-20 18:56:30 -05:00
AlexCatarino 89575cb020 Sets Equity data to raw in option algorithms II
In #1390, we have implemented a feature that assured that prices from an option underlying are set to raw. If the algorithm adds options contracts with AddOptionContract method, that rule was not applied.
2017-12-20 22:32:13 +00:00
Stefano Raggi f37d0cc962 Optimize loops for performance on cashbook and securities 2017-12-20 21:58:59 +01:00
Stefano Raggi c6aba7bfec Reduce full locking on ConcurrentDictionary objects
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/
2017-12-20 17:18:54 +01:00
Michael 9997abec89 Merge pull request #1372 from QuantConnect/feature-algorithm-framework
Initial release of the QuantConnect ALPHA streams feature.
2017-12-15 20:18:40 -05:00
Michael Handschuh b4b3aae112 Rename Signal -> Alpha
Whoa... I think I got everything :)
2017-12-15 18:24:58 -05:00
Michael Handschuh bd9c14ce3b Remove virtual from OnSignalsGenerated
The implementation of this method is critical to the workings of framework
algorithms and as such, we're not allowing it to be overriden.

Algorithms can receive signal events via the SignalsGenerated event.
2017-12-14 19:43:27 -05:00
Michael Handschuh d8ef289c9b Add IAlgorithm.IsFrameworkAlgorithm and BacktestingResut.IsFrameworkAlgorithm
Flag indicates whether or not the algorithm is a framework algorithm.
2017-12-14 19:43:26 -05:00
AlexCatarino 7d3327aea2 Adds warning to notify DataNormalizationMode change 2017-12-12 20:31:29 +00:00