Commit Graph

309 Commits

Author SHA1 Message Date
Michael Handschuh f5656f6113 Add EmaCrossAlphaModel
Simple alpha model that uses a fast/slow ema cross to generate
a prediction.
2018-03-26 17:33:14 -04:00
Michael Handschuh c5704a1cd4 Rename SimplePortfolioConstructionModel -> EqualWeightingPortoflioConstructionModel
The simple name was too simple and too vague. Equal weighting nicely
describes the purpose and intent of this model
2018-03-26 17:33:13 -04:00
Michael Handschuh 64b9766685 Add RsiAlphaModel 2018-03-26 16:42:24 -04:00
Jared 20c6db9b01 Merge pull request #1763 from QuantConnect/bug-1762-manual-selection-add-symbols-to-symbolcache
Add entries to SymbolCache for ManualPortoflioSelectionModel symbols
2018-03-23 17:53:58 -04:00
Michael Handschuh 794c71bb55 Add entries to SymbolCache for ManualPortoflioSelectionModel symbols
This ensures similar behavior to using AddSecurity directly.
2018-03-23 17:07:37 -04:00
Michael Handschuh a7128ad0db Add QC500PortfolioSelectionModel 2018-03-23 15:10:39 -04:00
AlexCatarino b8cfbd7c24 Improves error message in python wrappers 2018-03-14 12:30:50 +00:00
AlexCatarino 35d29060d0 Implements python support for custom models in framework
Adds method overload that accept a `PyObject` to `SetAlpha`, `SetExecution`, `SetPortfolioConstruction`, `SetPortfolioSelection` and `SetRiskManagement`. In these methods, a custom model written in python will be wrapped around the respective `PythonWrapper`.
2018-03-13 11:35:31 +00:00
AlexCatarino 5d82c32040 Removes the abstract classifier of QCAlgorithmFramework
This change is required because pythonnet cannot initialize abstract types. Loader.cs was modified to avoid loading QCAlgorithmFramework type.
2018-03-12 22:42:42 +00: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
Michael Handschuh 3f7b7702a4 Add Alpha.ReferenceValue
Gets the current value for the specified 'type'.
For example, this could be the price of the asset at the moment
the prediction was made.
2018-03-08 16:33:29 -05:00
Michael Handschuh 18a559943e Upgrade LEAN Python to 3.6 from 2.7
- Adds log to display the python version the algorithm is using.
- Fixes python algorithms that were failing because of small subtleties
like leading zeroes.
- Updates pythonnet with a version compiled with python 3.6 flags

- Changes in DockerfileFoundation: we now use miniconda to manage the python
environment.
- Took the opportunity to add NTLK (#1349), Tensorforce (#1369) and
PyTorch/Pyro (#1385).
- Changes readme in Algorithm.Python to show steps to install miniconda
2018-02-23 15:09:06 -05:00
Stefano Raggi a39e6a8e28 Revert "Merge pull request #1526 from AlexCatarino/python3"
This reverts commit 2e523992d0, reversing
changes made to fa48fc23ea.
2018-02-14 16:03:12 +01:00
AlexCatarino 34a271adac Updates pythonnet
In this update, we had compiled pythonnet with python 3.6 instead of 2.7 flags
2018-02-13 13:00:50 +00:00
Michael Handschuh 1dd84c65df Add NullExecutionModel and NullPortfolioConstructionModel
When focusing on generating alpha signals we don't need t both with execution or
portfolio construction models. Instead we can judge how well we do based on our
generated alphas. By not submitting orders, backtests and live performance is
greatly improved.
2018-01-02 14:53:40 -05:00
AlexCatarino 9459f47cba Updates pythonnet
In this update, methods overloads with decimal parameters accept python float.

- Fixes FractionalQuantityRegressionAlgorithm:
With the pythonnet update we can pass a python float where a decimal is required.
2017-12-29 17:25:48 +00: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 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 Handschuh 8e776a9fb5 Make QCAlgorithmFramework abstract
This simplifies things when loading algorithms.
2017-12-17 17:00:24 -05:00
Michael Handschuh 3161fd600b Rename PercentChange -> Magnitude 2017-12-15 20:10:34 -05:00
Michael Handschuh b4b3aae112 Rename Signal -> Alpha
Whoa... I think I got everything :)
2017-12-15 18:24:58 -05:00
Michael Handschuh ac23fade5c Mark QCAlgorithmFramework overrides as sealed
This is to prevent derived types from overriding these implementation as
they're critical to the proper function of the class. This removes the
existing reflection checks that would accomplish the same thing, but at
runtime instead of compile time.
2017-12-14 19:43:26 -05:00
Michael Handschuh 7a8620c66e Fix Algorithm.Framework packages.config target framework versions 2017-12-14 19:43:26 -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
Michael Handschuh e09a4404b9 Add more convenience methods to NotifiedSecurityChanges 2017-12-14 15:44:52 -05:00
Michael Handschuh f3596c310a Adds coarse/fine convenience portfolio selection methods/classes 2017-12-14 15:44:51 -05:00
Michael Handschuh 7a067a8b7d Change IPortfolioConstructionModel.CreateTargets to accept List<Signal>
Internally we're materializing the symbols enumerable from the signal model and then
passing that into the portoflio construction model. So we already have the list. In
addition, a common task is to check the count of the signals for use in further math,
such as determining weighting percentages, ect...
2017-12-14 13:06:07 -05:00
Michael Handschuh 36311be93f Remove ISignal, add Signal.GeneratedTimeUtc
This abstraction point is completely unwarranted. The signal object is really
just a DTO and it's extensible as it is currently defined. This also allows us
to enforce certain behaviors, such as internal set of GeneratedTimeUtc.

Removes GeneratedTimeUtc from the result object as it's now directly on the signal.
2017-12-12 11:57:03 -05:00
Michael Handschuh d4674e6f73 Signal.PercentChange doc update, ToString to include Id 2017-12-12 08:56:20 -05:00
Michael Handschuh 5910bc620f Add ISignalHandler
Handles signals generated by the algorithm. The default implementation
sends a SignalPacket to the messaging handler.
2017-12-12 08:56:19 -05:00
Michael Handschuh d0b7c9b31e Make ISignal.Period a required field
Requiring a period here forces signal models to place a time frame on
when their signal is valid. This also allows consumers of signals to
have some expectation of when a prediction should come to fruition.
2017-12-10 08:41:29 -05:00
Michael Handschuh ca9d5182a0 Add ISymbol.Id unique identifier
This guid uniquely identifies a signal instance
2017-12-10 08:41:29 -05:00
Michael Handschuh 39f5080a40 Rename framework events to OnFramework<Event>
This more closely follows existing conventions.
2017-12-08 12:04:53 -05:00
Michael Handschuh c264132447 Move json serialization attributes to inteface
It's not unreasonable to think users will provide their own ISignal implementation
and we'll want them all behaving by the same serialization rules to make consumption
much easier.
2017-12-08 10:07:54 -05:00
Michael Handschuh 3ee467b595 Stringify enum values when serializing to json 2017-12-08 10:07:54 -05:00
Michael Handschuh 791799bf52 Fire SignalsGenerated only if there are any signals
Was previously firing on every time step, check to ensure we've actually generated
signals before firing the event.
2017-12-08 10:07:54 -05:00
Michael Handschuh 2feae2cf0d Ignore default values when serializing signals
The presence of extra nulls does little other than bloat the size of the data.
This will trim a little fat and keep the files smaller
2017-12-08 10:07:54 -05:00
Michael Handschuh 131d9eeb30 De-duplicate signals in example models 2017-12-08 10:07:54 -05:00
Michael Handschuh abf5d2e8ff Add equality members for Signal
This will enable expected behavior when performing comparisons
or checking for uniqueness.
2017-12-08 10:07:54 -05:00
Michael Handschuh c093b45319 Add IAlgorithm.SignalsGenerated event
This event will fire each time step that generates signals and will
include all signals generated by the algorithm at that time step.
2017-12-08 10:07:54 -05:00
Michael Handschuh 7e63f2ae42 Add SignalCollection and ISignal.Clone
SignalCollection groups signals by the time they were generated.
This will be used as a transport medium out of the algorithm.
2017-12-08 10:07:54 -05:00
Michael Handschuh 24cebd2aa1 Move signal/target data structures to common
Since these are really just data structures they belon in the common library. Also,
it stands to reason that we'll want to reuse them in other components, such as the
result handler.
2017-12-08 10:07:54 -05:00
Michael Handschuh 2f319fdbdf Add MACDSignalModel and CustomFrameworkModelsAlgorithm 2017-12-08 10:07:54 -05:00
Michael Handschuh 087c7a748d Rename INotifiedSecuritiesChanged -> INotifiedSecurityChanges
Also synchronizes the helper class's name
2017-12-08 10:07:54 -05:00
Michael Handschuh 8093a818c7 Rename Direction -> SignalDirection
This follows the naming convention of the other direction enums
2017-12-08 10:07:54 -05:00
Michael Handschuh c5da7fe5fe Add FundamentalPortfolioSelectionModel base class
This class provides a base class so the user only needs to provide the required
coarse/fine selection functions.
2017-12-08 10:07:54 -05:00
Michael Handschuh dac63225cf Set default executon and risk management models 2017-12-08 10:07:54 -05:00
Michael Handschuh 14a2a09581 Add explicit methods for updating framework models
IAlgorithm.FrameworkOnData is used to pulse models with new data each time step
IAlgorithm.FrameworkOnSecuritiesChanged is used to pulse models with security changes

These two functions need to be separate to ensure that if we add an indicator during
the securities changed event that it will get the data from the current time step.
This forces us to call the securities changed event before we invoke the consolidators
for the current time step.
2017-12-08 10:07:54 -05:00
Michael Handschuh d6496ebb85 Change ManualPortfolioSelectionModel to accept params Symbol
This will make life easier for python while also keeping things easy for csharp.
2017-12-08 10:07:54 -05:00