Commit Graph

303 Commits

Author SHA1 Message Date
Stefano Raggi 3dd862262b Add unit tests for StandardDeviationExecutionModel 2018-08-03 21:33:02 +02:00
Martin Molinero 6da57a1e12 Improving GetMaximumOrderQuantityForTargetValue 2018-08-03 16:26:14 -03:00
Stefano Raggi 6e86634b21 Add unit tests for MaximumDrawdownPercentPerSecurity risk management model 2018-08-02 12:51:57 +02:00
AlexCatarino 47b3abfca2 Improves the logic to select active insights
- Also: adds unit tests for `EqualWeightingPortfolioConstructionModel`
2018-07-31 19:01:02 +01:00
Martin Molinero c73b7bb62f Adding smarter methods for PortfolioTargetCollection 2018-07-27 10:48:55 -03:00
Martin Molinero 2479768b7e Fix for null reference in TimeSlice.Create when calling HandleOptionData 2018-07-23 14:43:44 -03:00
AlexCatarino c59ff47ed7 Refactors PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm
- Moves `PearsonCorrelationPairsTradingAlphaModel` class to its own file in order to make it available as a framework model.
- Follows existing pattern design that alpha models receive a lookback and a `Resolution` object.
- Algorithm implements `IRegressionAlgorithmDefinition`.
2018-07-11 23:40:30 +01:00
AlexCatarino 6dbe83d0be Renames PairsTradingAlphaModel
- Since it will be used as a base class for other pairs trading models, it was ranamed as BasePairsTradingAlphaModel

- Use a tuple of symbols are key of BasePairsTradingAlphaModel._pairs dictionary.
2018-07-11 23:40:29 +01:00
AlexCatarino e815fe8cba Refactors PairsTradingAlphaModel
Instead of using a single, pre-defined, pair set in the class constructor, the pair is defined when securities are changed, therefore depending on the universe selection model.
2018-07-11 23:40:29 +01:00
Michael Handschuh 2fa9b0b6f7 Make regression algorithms self-contained
Some algorithms had dependencies outside of the file that needed
to be copied into each project. The alternative here is to move
the Bitcoin and QuandlFuture type into Common\Data or similar
2018-07-06 02:05:03 -04:00
Michael e81e0bd507 Merge pull request #2180 from QuantConnect/bug-2161-setholdings-pending-market-orders
Fix SetHoldings not taking into account pending market orders
2018-07-02 11:26:19 -04:00
Stefano Raggi 7806466a24 Fix SetHoldings not taking into account pending market orders 2018-06-29 15:02:27 +02:00
AlexCatarino 5c5bcabeb4 Adds unit tests for QCAlgorithm.Download method 2018-06-28 19:26:25 +01:00
AlexCatarino a4233c7179 Improves Extensions.TryConvert to avoid test by exception
Instead of letting `PyObject.AsManagedObject` throw an exception because the types do not match, we check whether the target type is assignable from the python object type.

This PR fixes PR #2102 that caused a bug in Symbol[] convertion.

Unit tests were added to test all changes.
2018-06-12 22:39:16 +01:00
Michael 0ec7f297f5 Merge pull request #2059 from QuantConnect/bug-insight-close-times-not-being-set
Refactor setting of insight close/generated times
2018-06-01 01:07:29 -04:00
Michael Handschuh b7c046565b Add unit test for checking insight generated/close times
Confirms the times are set and available inside the portfolio construction
model as well as being set and available via the InsightsGenerated event.
2018-06-01 00:51:41 -04: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
AlexCatarino e914bcf782 Make CommonAlphaModelTests.GetExpectedModelName abstract 2018-05-15 22:38:01 +01:00
AlexCatarino b15cfacff2 Insight.Group retuns the original Insight array with modified Insights
Use the new return type in PairsTradingAlphaModel.
2018-05-10 16:18:07 +01:00
AlexCatarino 62adc3a24b Changes Insight.Group return type to IEnumerable<Insight> from Guid 2018-05-09 14:49:00 +01:00
Michael 22711ad346 Merge pull request #1910 from QuantConnect/feature-1901-universe-data-on-security
Make universe data accessible via security object
Use security.Fundamentals to access coarse/fine data directly from the security object
2018-04-25 16:06:54 -04:00
AlexCatarino 9c4b85b693 Adds python version of PairsTradingAlphaModel 2018-04-25 13:45:13 +01: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 2e0111b858 Handle null group-id in FromSerializedInsight
Also updates the insight serialization tests to exercse the null
group-id case to prevent future regressions.
2018-04-23 13:26:41 -04:00
Michael Handschuh c1c741f55f Remove canonical symbols from manual universe model
This happens when users pass Securities.Keys into the manual model,
causing the SecurityChanges object to have references to the canonical
securities, thereby leading to indicators and other things being
done to them unknowningly.
2018-04-20 09:32:22 -04:00
Michael Handschuh 38d749caa4 Add PairsTradingAlphaModel w/ regression test
The PairsTradingAlphaModel is a simple example of defining an insight
grouping. Insights that are grouped together are assigned a unique
group-id that can be used by the portfolio construction model.

Updates were made to the CommonAlphaModelTests to give more control to
derived types. Some changes are still needed here to give securities
unique prices. I would recommend using a psuedo-random walk approach
by using Random with a constant seed value.
2018-04-19 16:30:20 -04:00
Michael Handschuh 5f33d61220 Add Insight.GroupId and Insight.Group( insights )
Provides a means of grouping insights together.
This new value is serialized as 'group-id'.
2018-04-19 12:47:08 -04:00
Michael Handschuh 90d54da87c Add INamedModel and implement in existing alpha models
Alpha models can choose to implement the Name property, if not, the system
will use the model's type name as the Insight.SourceModel.
Existing tests were updated to also assert expected model names
2018-04-17 16:50:16 -04:00
Michael Handschuh c3c6a9aff8 Add Insight.SourceModel
This identifier is used to determine the alpha model that generated.
This is NOT ideal, since it requires users to specify the value, more
thought will be givent to how we can resolve this value automatically

Adds test for surviving roundtrip copy operation.
2018-04-17 16:36:47 -04:00
AlexCatarino 58493a2f21 Updates python version Lean AlphaModels to reflect API changes
Refactors unit tests.
2018-04-11 11:16:04 +01:00
AlexCatarino 191d92b7ea Adds python version of RsiAlphaModel 2018-04-11 11:07:51 +01:00
AlexCatarino 2bfa5dfc28 Implements a framework to perform unit tests of alpha models 2018-04-11 11:07:51 +01:00
AlexCatarino bf1aa7fa4c Implements Insight.Price helper method.
Implements `Insight.Price` method to make it easier to create new instances of `Insight` of `InsightType.Price`.
Standardize the parameter order to `Symbol`, `TimeSpan`, `InsightType`, `InsightDirection`, `Double`, `Double`.
2018-04-10 19:49:29 +01:00
Michael Handschuh f11acf1246 Remove Insight.Equals
This method is misleading at best and incorrect at worst.
Insight objects should use reference equality or compare ids to
perform equality checking. The only usage, in MacdAlphaModel,
was easily converted to not relying on this method.
2018-04-03 23:32:34 -04:00
Michael Handschuh 99491a9ec7 Add IDataConsolidator.Dispose to remove event handlers
All consolidators now clear the event handlers list when being disposed.
In addition, SubscriptionManager.RemoveConsolidator will now dispose of
the consolidator before returning. This ensures the consolidator and any
downstream indicators that were attached to it can be properly cleaned
by garbage collection.
2018-04-03 14:59:10 -04:00
Michael Handschuh 756ca9c741 Fix PortfolioTarget percent test name 2018-04-02 12:46:35 -04:00
Michael Handschuh b1e624dfdc Fixes bug in PortfolioTarget.Percent
Buying power model's GetMaximumOrderQuantityForTargetValue returns the
delta quantity needed to reach a particular position, so we need add
back in the existing quantity to get the total quantity required.
2018-04-02 11:30:13 -04:00
Stefano Raggi bd89c2cb1b Fix currency conversion in CashBook.Convert
Fixes #1813
2018-03-30 20:44:49 +02:00
AlexCatarino f588e190f2 Fix data consolidation with python custom data
When creating a CRL type in runtime to represent a python custom data class, we need define `DynamicData` as its parent class so that it passes the `IsAssignableFrom` condition in `SubscriptionManager.AddConsolidator`
2018-03-14 17:55:22 +00:00
AlexCatarino 4e3577939d Refactors AlgorithmPythonWrapper
Move the logic of importing the module into AlgorithmPythonWrapper where it is wrapped.
Throws an exception if the script does not have a class that inherits from either QCAlgorithm not QCAlgorithmFramework.
Adds a check for OnData being defined in the module. If not, OnData from the base class will not be called (it causes stack overflow otherwise)
2018-03-12 23:36:39 +00:00
Michael 3fb429e5f4 Merge pull request #1685 from QuantConnect/feature-update-alpha-framework-for-consistency-with-api
Finalizes implementation of alpha framework, including alpha.spanner updates, many name changes, and harmonizes insight serialization with alpha streams API
2018-03-12 16:39:33 -04:00
Michael Handschuh 0d5fca0733 Add insight serialization tests
Moved costruction of insight from serialized insight to the insight
object so it could access private properties, such as the id
2018-03-12 16:28:41 -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
AlexCatarino 2f500fc1b6 Minor corrections 2018-03-08 12:06:54 +00:00
AlexCatarino 5e2f24b90f Uses PyObject.TryConvert to determine which indicator type will be registered
Minor fixes in RegisterIndicator tests.
2018-03-08 10:54:19 +00:00
AlexCatarino 6ca66722e8 Adds tests for RegisterIndicator method 2018-03-08 10:51:29 +00:00
Stefano Raggi 7460d4f9c7 Fix concurrency issue in QCAlgorithm charts
Fixes #1640
2018-03-07 15:09:48 +01:00
AlexCatarino 078cfd685b Adds tests for python custom data 2018-03-01 20:08:03 +00:00
Michael Handschuh 0c6965c808 Add failing alpha serialization unit test 2018-02-27 15:07:00 -05:00
Stefano Raggi 1943dcd99d Revert "Add duplicate security check in AddSecurity" 2018-02-20 15:07:03 +01:00