Commit Graph

1000 Commits

Author SHA1 Message Date
Martin-Molinero 13431b11c1 Merge pull request #4236 from QuantConnect/bug-4205-registerindicator-of-t
Fixes for RegisterIndicator API
2020-03-25 10:55:43 -03:00
Martin Molinero 085da7c352 Fixes for RegisterIndicator
- Fixes for C# RegisterIndicator API methods which were ignoring provided
type of T
- Fixes for Py RegisterIndicator API methods which was not using the
provided 'selector' method
- Adding C# and Py regression algorithm
2020-03-24 16:38:46 -03:00
Martin Molinero eb533b9954 Fixes for QCAlgorithm.Indicators.Consolidate API
- Fixes for 3 QCAlgorithm.Indicators.Consolidate API methods
- Adding C# and Py regression test
2020-03-23 21:16:33 -03:00
Martin-Molinero 899ea03a1c Merge pull request #4227 from QuantConnect/bug-3861-indicator-warmup
Fix WarmupIndicator duplicate consolidator
2020-03-23 18:49:57 -03:00
Adam May 9049d753aa Adding overload to QCAlgo.EMA to support smoothing factor 2020-03-20 10:48:51 +11:00
Martin Molinero 5242cc57f4 Fix WarmupIndicator
- WarmupIndicator will remove and dispose added consolidators
- Consolidating duplicated implementation
- Adding regression test
2020-03-19 18:06:05 -03:00
Jared 8cd8d206ca Revert "Adding Support for Equity L1 Quote Data" 2020-03-11 19:16:05 -07:00
Martin Molinero 21f636fecc Fix undeterministic unit test
- Fix underterministic python indicator unit test
- Refactor `QCAlgorithm.Indicators.GetSubscriptions`
2020-03-11 14:34:13 -03:00
Martin Molinero 2190145830 Refactor quote type filtering logic 2020-03-11 14:34:13 -03:00
Juan José D'Ambrosio 1fa733a733 Fix issue with history request asking for Low resolution quotes 2020-03-11 14:34:13 -03:00
Juan José D'Ambrosio 1269966e51 Rebase and squash commits
Update test to the new crypto and equity subscriptions  rules:
- Only consolidates trades
- Low resolution data are only trades.
Update and fix tests

Add missing minute sample files

Update Regression algorithms statistics
2020-03-11 14:34:13 -03:00
Juan José D'Ambrosio fd9de5895a Consolidate only trades, low resolution reads trades only, update tests
Crypto and Equities will consolidate trades by default

Daily and hourly resolution will return only trades for crypto and equities. 
Update equity TAQ regression test 

Add minute sample files

Updating regression algorithms

Update SpotMarket test cases

Add regression test for equity trades and quotes
- History request.
- Trades and quotes pumped into OnData.
- Subscriptions are added correctly.

Add sample data

Checks low resolution only subscribes to trade bars
2020-03-11 14:34:05 -03:00
Juan José D'Ambrosio 228aad658b Process Equity quotes
This is just a draft for supporting Equity quotes in Lean
2020-03-11 14:34:05 -03:00
Rahul 5f5dee1e24 Renamed all instances of _isEmitWarmupInsightWarningSent
Changed from _isEmitWamrupInsightWarningSent to _isEmitWarmupInsightWarningSent
2020-03-04 09:26:12 -08:00
AlexCatarino c2ff03caad Implements PortfolioBias in EWPCM and IWPCM
Implements `PortfolioBias` in EWPCM, CWPCM and IWPCM. With this new feature, these PCM will ignore insights that do not respect the desired bias. E.g. for `PortfolioBias.Long`, on Insights with `InsightDirection.Up` will be converted into `PortfolioTarget.Quantity` greater than zero and other `InsightDirection` will result in `PortfolioTarget.Quantity` of zero.
2020-02-20 19:29:12 -03:00
Martin Molinero afed84e1a2 Add new unit test assert and bug fix 2020-02-20 13:01:35 -03:00
Martin Molinero a8120c197a Improvements
- Adding new unit test for python PCM implementations, asserting each
method is correctly called
- Reverting some unrequired changes in the
`MeanVarianceOptimizationFrameworkAlgorithm`
2020-02-20 12:13:47 -03:00
Martin Molinero 8ff23936d1 Refactor EWPCM into base PCM
- Refactor shared logic from `EqualWeightingPortfolioConstructionModel`
into base `PortfolioConstructionModel` implementation
- `MeanVarianceOptimizationPortfolioConstructionModel` will respect
rebalancing period and will use all active inisights, not just the last
2020-02-19 15:13:20 -03:00
Rohan Talip 66358ac798 Removed the RunMode enum that has been deprecated since the initial commit on 2015-01-12. 2020-02-17 12:50:16 -08:00
Martin Molinero 8f50691927 Update documentation 2020-02-14 19:59:22 -03:00
Martin Molinero 3679ad591f Address reviews
- Improve custom rebalance function logic
- Add new PyObject C# PCM constructor overloads for performance
2020-02-14 16:38:16 -03:00
Martin Molinero e12788375b Adding IDateRule rebalacing PCM
- Adding IDateRule to be used by the PortfolioConstructionModel as
rebalancing function.
- Adding unit tests and C#/Py regression algorithms
2020-02-13 18:23:15 -03:00
Martin Molinero 26c731f895 Add python regression algorithm implementation 2020-02-13 16:11:23 -03:00
Martin Molinero 4584088a9e Address reviews
- Refactor to avoid calling rebalancing function twice in the same loop
- Refactor making portfolio rebalance setting instance based instead of
static
2020-02-13 16:10:52 -03:00
Martin Molinero 0845f0802d Unknown next rebalance time
- Adding new `Func<DateTime, DateTime?>` that allows PCM to return null
if the next rebalance time is null, in which case the function will be
called again in the next loop.
- Adjusting PCM next rebalance time check to perform rebalance once the
time is reached
- Adding new regression test. Updating existing
2020-02-13 16:10:52 -03:00
Jared 873a392546 Merge pull request #4079 from QuantConnect/refactor-4075-portfolio-construction-rebalancing-period
Refactor PCM rebalacing
2020-02-11 16:54:52 -08:00
Martin Molinero d3a2c7ff5a Address reviews
- Moving InsightCollection into base `PortfolioConstructionModel`
- Will call `InsightCollection.GetNextExpiryTime()` on each check, and
for performance `InsightCollection` will keep track of next insight
expiry time
- Removing need for PCM base classes having to call `RefreshRebalance`
- Some refactor clean up at base
PortfolioConstructionModel.IsRebalanceDue()
2020-02-11 21:02:35 -03:00
Martin Molinero 4fc9a516fd Adding RebalanceOnInsightChanges flag
- Refactoring some PCM methods to be `protected` since they are not required
to be public
- Adding new `PortfolioConstructionModel.RebalanceOnInsightChanges`
flag, that will allow avoiding new insights or insight expirations to
trigger a rebalance
- Updating unit tests
- Fix for the MeanVarianceOptimizationPortfolioConstructionModel that
was skipping, in some cases, 0 magnitude insights
2020-02-11 16:06:27 -03:00
Martin Molinero 1dd742d1b8 Order sizing fix
- Improving OrderSizing.Value and Volume to include code in consumers
- OrderSizing.GetUnorderedQuantity() will adjust result by lot size
- ImmediateExecutionModels will use OrderSizing.GetUnorderedQuantity()
- OrderSizing.Value() will take into account ContractMultiplier
- Adding unit tests
2020-02-11 13:17:10 -03:00
Martin Molinero 6cfa19697a Refactor PCM rebalacing
- Add missing PCM constructor methods for the different supported
rebalancing periods overloads
- Normalize rebalance behavior in the base `PortfolioConstructionModel`
- Adding new `PortfolioConstructionModel.RebalanceOnSecurityChanges`
that will allow disabling rebalance on security changes
- Adding unit tests
2020-02-10 22:32:09 -03:00
AlexCatarino 8bd65ecc1d Fixes Typos 2020-02-03 21:11:40 +00:00
AlexCatarino 200d3b0271 Changes GetLastKnownPrice Logic to Increase History Look-back
Changes `GetLastKnownPrice` logic to retry to get non-null data after a first attempt. Previously, it would return null in the first attempt and illiquid securities would not have valid data to set its market price. In the second attempt, we increase the look-back period to the equivalent of three trading days worth of data.
2020-01-30 17:53:30 +00:00
Martin Molinero b4b2f90303 AddUniverse will be deferred to EndOfTimeStep
- `AddUniverse` call will add new Universe to the pending collection which
will be consumed at the `OnEndOfTimeStep` where it will be added to the
data feed, same as we do for the `UserDefinedUniverses`. This is
required since the start and end date, during initialize, is consumed by
these universe subscriptions.
-Adding unit test.
2020-01-09 20:39:00 -03:00
AlexCatarino 898a5c2324 Addresses Peer-Review 2020-01-08 22:21:15 +00:00
AlexCatarino f205a7e8cd Refactors QC500 Universe and Universe Selection Model
The class field that tracks the current month is updated only if there are securities that passed the selection criteria. It prevents division by zero and allows the universe selection a new attempt on the next trading day while keeps the universe unchanged
2020-01-07 09:24:58 +00:00
Michael Handschuh 39935552a3 Convert ObjectStore ext class to implement IObjectStore for API
Since extension methods don't play well with pythonnet, this change converts
the extensions class into a decorator class. Additionally, this ObjectStore
type is the type that gets exposed via QCAlgorithm so users can access these
methods directly without requiring the use of extension methods.

This approach has many good properties. For one, it doesn't force implementors
of IObjectStore to use a base class. Second, it maintains healthy separation of
API level concerns (such as convenient methods) from the  abstraction level conerns
of IObjectStore. Setting it up in this way ensures ANY implementation of IObjectStore
will still get access to these additional methods. Another thing to note is this
prevents using a base class on QCAlgorithm's public interface. Instead, we have a
specific type that is dedicated to fulfilling API level requirements, which also
provides us flexibility in the event the API needs to be updated. If it were a subclass,
you run the risk of breaking the implementors of the subclass.
2019-12-31 15:55:16 -05:00
Stefano Raggi a803827a7f Address review
- In GetBrokerageModel pass IOrderProvider instead of IAlgorithm
2019-12-31 12:42:21 +01:00
Stefano Raggi 5a71ba16d9 Add order validation in AlpacaBrokerageModel 2019-12-27 20:34:09 +01:00
Stefano Raggi d407307566 Add IObjectStore interface with LocalObjectStore implementation
This commit is squashed from iterative development:

- More consistent method naming
- Storage root path updated to be absolute and include algorithm name
- Storage root path created only if object store is actually used
- Implemented XML save/load
- Added missing unit tests
- Replaced Log.Trace with Log.Error calls
- Added the object store name logging in Engine.Main
- Read storage root from config
- Create algorithm storage root folder in Initialize
- Remove empty folder in Dispose
- Added null checks in all methods
- Added missing XML parameter docs
- make Initialize and Dispose virtual
- make AlgorithmStorageRoot protected

The IObjectStore abstraction provides algorithms with a persistent
storage mechanism. While the algorithm is running, data is maintained
in memory as a dictionary of raw bytes (string -> byte[]). This ensures
we avoid any reference type shenanigans. Periodically, the data in the
object store is persisted and additionally, when the algorithm shuts
down, the object store's data will again be persisted. This ensures that
when the algorithm starts up again, it will have access to any state
that has been saved into the object store.

A great use case for IObjectStore is saving a compute heavy model.
For example, computing the weights of a deep neural network is very
CPU intensive, but after the weights are computed, evaluation is fairly
quick. An initial backtest can be used to solved for the network's weights
and then subsequent backtests or even in live mode, the weights will be
available to the algorithm provided they were saved into the object store.

Also, some libraries require a file path to load model data. The object
store provides a `GetFilePath(key)` method which will copy the data for
the provided key to the disk and return that path so the library can load
the model data.
2019-12-17 22:21:11 -05:00
Stefano Raggi e0a08cbb8d Add XML documentation generation for release builds 2019-12-14 13:50:10 +01:00
Martin Molinero a3526fee84 Add ConstituentUniverseDefinitions 2019-11-21 12:28:51 -03:00
Martin Molinero 394130e58a Revert qc500 constituent - Fix data order
- Reverting qc500 constituent universe
- Fix data parsing order, based on the constituent universe data already
generated
2019-11-20 19:47:19 -03:00
Martin Molinero 81974b3fb3 Address reviews 2019-11-20 17:20:33 -03:00
Martin Molinero e2c129a311 Improved version
- Renaming `PreSelected` to `Constituents`
- Adding base `ConstituentsUniverse`
- Adding Py and C# regression algorithm
- Fixing bug in `UniverseSelection`, it wasn't removing pending to be
removed securities unless the universe selection changed
- Adding test data
2019-11-20 17:16:44 -03:00
Martin Molinero eee4c7cb79 Adding PreSelected data types
- Adding new custom data `PreSelected` type and `PreSelectedQC500` using
it.
- Adding 1 day worth of pre selected data for the QC500
2019-11-20 16:58:43 -03:00
Martin Molinero ec7a8fa906 Bump PythonNet to 1.0.5.29 2019-11-13 17:33:32 -03:00
Martin Molinero c6ab54f6d2 Bump PythonNet to 1.0.5.28 2019-11-12 16:06:55 -03:00
Martin Molinero 2aeed3595d Algorithm will respect job dates if present
- Console and Backtesting setup handler will use job dates if present
(not the brokerage setup handler)
- Adding unit test
2019-11-08 17:51:33 -03:00
Martin Molinero 2812ad6f8e Address reviews. Improvement
- Improve mechanism to fetch open orders quantity, based on method used
by the `ImmediateExecutionModel`
- Adding unit test
2019-11-06 12:14:10 -03:00
Martin Molinero 9b507bbf34 Fix SetHoldings OnMarketOpen orders
- `SetHoldings` will take `OnMarketOpen` ordes into account when
determining order quantity
- Adding new regression test. Updating existing algorithms which
suffered of the issue
- Adding a performance improvement, will avoid margin and portfolio
calculations for MarketOnOpen orders that wont be able to fill
2019-11-05 21:05:49 -03:00