Commit Graph

396 Commits

Author SHA1 Message Date
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
Michael Handschuh ff8842be5c Convert IPortfolioTarget.GetTargetQuantity to Quantity property
This forces the quantity computation to be performed from the portfolio construction model.
As a result of this change, we've removed the Percent and Quantity implementations and
replaced them with just a PortfolioTarget implementation that is equivalent to the previous
Quantity implementation. Users can still use the static Percent method to generate the
correct quantities for a target for the common case of a percent weighted portfolio.
2017-12-08 10:07:54 -05:00
Michael Handschuh b8f6afe4e8 Add model setter methods 2017-12-08 10:07:54 -05:00
Michael Handschuh 755dcb30ab Add IRiskManagementModel
The risk management model is intended to check the algorithm's positions
at the end of each time step to potentially exit positions that are losing
too much.
2017-12-08 10:07:54 -05:00
Michael Handschuh ae422bb6c2 Check algorithm framework models for null
Framework algorithms are expected to set these models. All of these models
should be user specified. The execution model could be defaulted to the immediate
model, but perhaps it's best that users are explicit
2017-12-08 10:07:54 -05:00
Michael Handschuh 7076928904 Add IExecutionModel
The execution model is responsible for executing trades to achieve the desired
portfolio targets
2017-12-08 10:07:54 -05:00
Michael Handschuh 343bbf2c59 Add IPortfolioConstructionModel
The portoflio construction model generates portoflio targets from signals
2017-12-08 10:07:53 -05:00
Michael Handschuh 514434692b Add ISignalModel
This change includes a check to prevent users from overriding methods  required
by the framework. This is non-ideal and we should perhaps look into alternatives
to this approach, which could involve additional methods on IAlgorithm. In order
to not lose access to these events at the algorithm level, we could expose them
as C# events (not sure python compatibility?)
2017-12-08 10:07:53 -05:00
Michael Handschuh 0591d45db2 Add QCAlgorithmFramwork w/ IPortfolioSelectionModel
Adds a default implementation of IPortfolioSelectionModel that creates a
universe using the securities explicitly defined by the user.
2017-12-08 10:07:53 -05:00
Michael Handschuh 077452da2b Add QuantConnect.Algorithm.Framework csproj
This project will house the new modular qc algorithm framework.
2017-12-08 10:07:53 -05:00