Commit Graph

978 Commits

Author SHA1 Message Date
Stefano Raggi e976bd1122 Update expected statistics to latest master branch
The expected statistics were out of date.
2019-01-28 16:58:54 +01:00
Martin Molinero 1b0bdd9b0b Adding SetAccountCurrency for backtesting
- Adding new `SetAccountCurrency()` for backtesting. Has to be called
before adding any `Security` or calling `SetCash()`, else will throw.
- Adding new Non account currency unit tests for `CashBuyingPower`,
`SecurityPortfolioModel`, `SecurityMarginModel`,
`SecurityPortfolioManager`, `Future/OptionMarginBuyingPowerModels`
- Adding new C# regression test using `SetAccountCurrency()`, one for
`CashBuyingPowerModel` and one for `SecurityMarginModel`
- Adding new Py and C# basic regression algorithms using
`SetAccountCurrency()`
- `Options` and `Futures` will use not use `AccountCurrency` as quote
Cash.
- `SecurityBenchmark` value will be in account currency
2019-01-25 14:54:43 -03:00
Martin Molinero 5d3d16a773 Fix exception caused by split for removed security
- Adding check at `AlgorithmManager.ProcessSplitSymbols()`, will skip
splits from removed securities.
- Adding regression test which reproduces original issue in master.
2019-01-25 10:55:00 -03:00
Stefano Raggi d5cabce0db Update regression statistics for OptionExpiryDateOnHolidayCase 2019-01-23 21:29:07 +01:00
Martin Molinero d53a922cf0 PythonNet installation does not require copy pasting
- Requires a new PythonNet 1.0.5.15 package where the different `.dll` are in a
specific folder: `\win` `\linux` and `\osx`
- Removed not present `decimal.py` from `Algorithm.Python` project. It
was moved into `Common`.
- Replace `xbuild` for `msbuild` required for using the `System.Runtime.InteropServices`.
Also note the `xbuild` on travis prints:
> >>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
2019-01-22 19:48:11 -03:00
AlexCatarino ef59fa7ba2 Updates pythonnet package.
In the new package:
- C# decimal conversion will use C# double and python float due to the big performance impact of converting C# decimal to python decimal;
2019-01-18 23:18:35 +00:00
Jared 7a6c427735 Merge pull request #2834 from StefanoRaggi/bug-2833-history-symbol-changes-fix
Update SubscriptionDataReaderHistoryProvider to handle symbol changes
2019-01-17 11:50:01 -08:00
Stefano Raggi 4e241dec52 Add missing list materialization in AuxiliaryDataEnumerator
- restored includeAuxiliaryData to false in SubscriptionDataReaderHistoryProvider
2019-01-17 20:22:49 +01:00
Stefano Raggi 24ccda8b9a Update SubscriptionDataReaderHistoryProvider to handle symbol changes 2019-01-17 12:49:16 +01:00
Gerardo Salazar 40def51d93 Add python to regression test languages. Remove code with no effects from CustomModelsAlgorithm.py 2019-01-16 17:56:09 -08:00
Martin Molinero 124af7282e Improve HistoryRequestBenchmark algorithm
- The HistoryRequestBenchmark will now perform a daily and minute history
request at end of day.
- C# performance is at ~15k data points per second
- Python performance is at ~11k data points per second
2019-01-11 18:09:59 -03:00
Martin Molinero 40ac9c5033 Fix IB FeeModel Option fees
- Fixing IB FeeModel options fees. Adding unit tests
- Updating regression algorithms
2019-01-02 15:50:00 -03:00
Martin Molinero 3ce9d8be7e Fix FractionalQuantityRegressionAlgorithm
- Add missing crypto data and update
FractionalQuantityRegressionAlgorithm statistics
2018-12-27 15:37:43 -03:00
Martin Molinero ab3db6310b Add missing crypto data
- Add missing crypto
- Updating crypto regression tests
- Updating `DailyResolutionSplitRegressionAlgorithm` previous statistics
were calculated using the wrong factor file.
2018-12-24 17:32:39 -03:00
Martin Molinero 177d786ac5 Removing internal currency subscriptions
- `UniverseSelection` class will now keep track and remove internal
currency subscriptions through the usage of new class
`CurrencySubscriptionDataConfigManager`
- Modifying existing regression tests to assert bug 2773.
- Adding new regression test that fixes the case where a new cash is set
after initialization. This could happen during cash sync performed by
the `BrokerageTransactionHandler`.
    - Adding new `CashAdded` event for the `CashBook` to solve the
    issue.
2018-12-21 17:31:47 -03:00
Martin Molinero af8e6bf85c Fix starting capital for non usd cash
- Moving `UniverseSelection.EnsureCurrencyDataFeeds` call into the
`IResultHandler` implementation through usage of the new `SetupHandlerHelper`
class, that will also set an initial conversion rate if none present.
- Adding regression test, that reproduces original issue
2018-12-19 16:15:28 -03:00
Jared 86807d3f04 Merge pull request #2298 from AlexCatarino/bug-2288-pythonnet-memory-leak
Updates pythonnet
2018-12-18 16:44:53 -08:00
Martin-Molinero 9f502ec15e Merge pull request #2757 from Martin-Molinero/bug-2756-disable-intrinio-regression-tests
Disabling Intrinio regression tests
2018-12-14 17:39:19 -03:00
Martin Molinero c9aba0c2db Fix warmup currency data feeds
- `AlgorithmManager` will call `EnsureCurrencyDataFeeds()` before the
history requests are created so the conversion rate securities are also
updated during warmup.
- `EnsureCurrencyDataFeeds()` will add new `SubscriptionDataConfigs` to
the `_addedCurrencySubscriptionDataConfigs` hash set. This hash set will
be used during `UniverseSelection()` to add the subscriptions.
- Wont trigger a `UniverseSelection()` before warmup. This was causing
the data to be fetched twice and for consolidators to be updated with
old data.
- Adding a new regression test and adding new checks to existing
regression tests.
2018-12-14 16:05:14 -03:00
Martin Molinero 759c15833a Disabling Intrinio regression tests
- Disabling C# and Py `BasicTemplateIntrinioEconomicData` regression
test. Free user credentials are invalid because Intrinio has now a 30 day trial for free users
2018-12-14 15:29:46 -03:00
Martin Molinero 0af7ba14f5 Address reviews
- `CashBook[NullCurrency] { get; }` will throw an exception
- Revert `Currencies.USD` changes in user facing algorithms
- Improve some documentation
- Revert some format changes
- Adding more asserts for regression test
- Adding new regression tests using a custom fee model which returns
`OrderFee.Zero`
- Adding a non-usd account currency test to the cash book tests
- Adding some unit tests for `NullCurrency` and `OrderFee.Zero`
2018-12-14 12:38:55 -03:00
Martin Molinero 0933da9303 Refactor previous commits
- Removing `AccountCurrency` from `Cash` and `Brokerage` classes.
`ICurrencyConverter` will now provide the `AccountCurrency`
- Adding new static `OrderFee.Zero` which will return a 0 order fee in
`NullCurrency`
- Adding static `Currencies.USD` value, replacing all "USD".
- Addin new static `Currencies.NullCurrency`
- Updating Bitfinex `FeeModel` so it return fees in quote currency.
Adding unit tests
2018-12-13 11:30:40 -03:00
Martin Molinero e85942f4f0 GDAX FeeModel will use QuoteCurrency
- GDAX FeeModel will now use QuoteCurrency as fee currency. Adding unit
test.
2018-12-10 14:59:55 -03:00
Martin Molinero b7bcdbef04 Adding OrderFee to OrderEvent
- Replacing `decimal` for `OrderFee` at the `OrderEvent`.
- Adding `FeeModelNotUsingAccountCurrency` regression test
- Adding unit tests for `CashBuyingPowerModel` and `SecurityMarginModel`
with non account currency fees
2018-12-10 13:18:41 -03:00
AlexCatarino 823bb01438 Updates pythonnet
Includes memory leak fix (https://github.com/QuantConnect/pythonnet/commit/c6db86653e7fa4fa89e1f8404d72e346b67ed857 and https://github.com/QuantConnect/pythonnet/commit/bec9563d2958acc5adf3e8972b23609fe3914402)

- Fix python version to 3.6.6 (avoid updating to 3.7)
- Fix numpy version to 1.14.5 (tensorflow requirement)

- Adds py-earth python package (closes #2399).
2018-12-07 09:36:48 +00:00
Martin Molinero c5daf9ac9a Refactor IFeeModel
- Refactoring `IFeeModel`. *This is a breaking change* for implementations
inheriting directly from the interface. Deleting old and adding a new method
`OrderFee GetOrderFee(OrderFeeParameters parameters)` that will use a parameter
and a result object.
- Refactoring `CashAmount` so it does not embed a `ICurrencyConverter`
instance.
- Updating unit tests
- The `Security.QuoteCurrency`, a `Cash` instance, will provide access
to the `AccountCurrency` as a property.
- Will maintain backwards compatibility with old python custom
FeeModels, Adding unit test.

> Note that for now, consumers will ignore the currency, as before, and
directly consume the amount
2018-12-06 16:20:36 -03:00
Jared 425558942f Merge pull request #2713 from Martin-Molinero/bug-2478-delete-removed-universe-subscription
Will now delete removed universe subscriptions
2018-12-03 14:36:49 -08:00
Jared 108480d888 Merge pull request #2710 from Martin-Molinero/refactor-2634-refactor-fill-models-3
Refactor FillModels - v3
2018-12-03 14:24:59 -08:00
Jared 54fbf36be8 Merge pull request #2671 from Martin-Molinero/refactor-2429-corporate-events-own-enumerator
Move corporate events to new enumerators
2018-12-03 10:45:44 -08:00
Martin Molinero 46baedf858 Refactor FillModels
- Modifying `IFillModel` interface removing old methods and adding new
method `Fill Fill(FillModelParameters)`. This is a breaking change.
- Adding new `PythonWrapper` property for the `FillModel` base class.
This is required due to a limitation in PythonNet:
   - Given C# class T has `virtual` methods A and B. Where method A
   calls method B. And given custom python class L inherits class T.
   And overrides method B. When class L calls
   base method A (of class T). And when method A internally calls method B.
   It will call C# implementation, not the python override. This issue
   is solved going back to the `PythonWrapper`. Adding unit tests.
- Adding new `Parameters` property for the `FillModel` base class that will
be set by the call to `Fill()`. The `Parameters` property will be used by
the modified `XxxxFill()` implementations
- Adding new `Fill` result object for the `Fill(FillModelParameters)`
method
- Adding new check before removing a `SubscriptionDataConfig` due to the FillModels consuming the configuration collection when determining which Price to use. WIll now only remove the `SDC` if the symbol was removed from the selecting `universe`, this will avoid the case where the symbol is never deselected and the subscription ends, which happens at the end of all executions.
- Adding unit tests showcasing retro compatibility.
- Enabling C# `CustomModelsAlgorithm` as a regression test. Python
version returns a different result due to random number generation.
2018-11-29 15:38:46 -03:00
Martin Molinero c934fe0044 Will now delete removed universe subscriptions
- Previously when a user requested to remove a universe, they would call
`RemoveSecurity()`->`UniverseManager.Remove()`-> `Universe.Dispose()` ->
collection change notification would call `DataManager()` that would
call `RemoveSubscription()` that *would not perform any operation* since
it would return `false` through
`if(subscription.IsUniverseSelectionSubscription &&
subscription.Universe.DisposeRequested)`. Previous comment stated that
the `Subscription` would be removed by the `SubscriptionSynchronizer`
via `SubscriptionFinished()` but this called would go through the same
if statemente as above, returning false and no performing any operation.
So the `Universe` `Subscription` was never removed.
PR https://github.com/QuantConnect/Lean/pull/2039
- In this PR I'm removing the mentioned `if` statement and the call
relation between `UniverseManager.Remove()` and
`DataManager.RemoveSubscription()` since this will be covered by the
`SubscriptionSynchronizer` in the next loop.
- Modified regression test (originally added with these changes at
https://github.com/QuantConnect/Lean/pull/2039) to verify this issue.
2018-11-27 12:24:04 -03:00
Martin Molinero 6db7f13dca Addressing reviews
- Will now use the `SynchronizingEnumerator` and avoid the duplicated
synchronization logic.
- Slightly modified the `SynchronizingEnumerator` implementation to
avoid removing enumerators with current `null` returning `true`. Adding unit tests
- Adding unit tests for `DelistingEnumerator`
- Fixing issue where price was not correctly set. Adding new check for
`HourSplitRegressionAlgorithm`
2018-11-20 15:50:19 -03:00
Martin Molinero a746dd0137 Move corporate events to enumerators
- Moving `Splits`, `Dividends`, `Mappings`, `Delistings`, from the
`SubscriptionDataReader` into there own enumerator, inheriting from
new `CorporateEventBaseEnumerator`
- Adding new helper `static class CorporateEventEnumeratorFactory` to
create the new enumerators
- Adding unit tests for new `CorporateEventBaseEnumerator`
- Adding some extra checks to `HourSplitRegressionAlgorithm` and
`DelistingEventsAlgorithm`
2018-11-20 15:50:19 -03:00
Martin Molinero 75f4ecaf54 Remove unused SubscriptionDataConfigs
- After removing a `Subscription` entirely, we will now also remove the
matching `SubscriptionDataConfig` from the `SubscriptionManager`
- Adding a new regression test, which fails in `master`
- Fixing previous PR change that removed `Trace` logging when adding
and removing a `Subscription`
- Fixing a bug in the `UserDefinedUniverse` where calling `RemoveMember`
would cause the `SubscriptionDataConfig` to be re added to the
`SubscriptionManager` (not the `DF`). Found this through added
regression test.
2018-11-15 11:35:31 -03:00
Juan José D'Ambrosio f6b5da261a Implement method for setting the time interval between calls
Update Python version of BasicTemplateIntrinioEconomicData
2018-11-14 14:10:59 -03:00
Juan José D'Ambrosio 12513a3217 Set the free limit in the regression algorithm
Left the default rate gate time span in 5 seconds. 

Increment the rate gate time span to 1 minute only for testing..
2018-11-13 12:34:30 -03:00
Martin Molinero ee2dc32710 Subscriptions will track Universe requests
- The class `Subscription` will internally track each `Universe`
`SubscriptionRequest` added or removed
- Adding regression test in which two different `Universe` request the
same `SubscriptionDataConfig` and one of them removes/adds it in a
toggle fashion (fails on current master)
- `UniverseSelection` pending removals will also be tracked by
`Universe`
- `UniverseDecorator` will overwrite the `Universe` member of
`SubscriptionsRequests` at `GetSubscriptionRequests()`. This is due to
`this != this,Universe`
- Adding `Subscription` unit tests covering expected behavior
- Extracting pending removals logic from `UniverseSelection` class into
a new helper class `PendingRemovalsManager`. This new class will keep
track of the `universes` requesting to remove a security. Adding unit tests
2018-11-08 13:02:11 -03:00
AlexCatarino 25baaf179a Implements python version of TrailingStopRiskManagementModel
- Implements python version of `TrailingStopRiskManagementModel`
- Implements python version of `TrailingStopRiskFrameworkAlgorithm`
2018-11-07 15:50:40 +00:00
AlexCatarino 5389f9bf8b Implements python version of MaximumDrawdownPercentPortfolio
- Implements python version of `MaximumDrawdownPercentPortfolio`
- Implements python version of  `MaximumPortfolioDrawdownFrameworkAlgorithm`
2018-11-06 23:52:52 +00:00
Jared 3b17be57b0 Merge pull request #2659 from Martin-Molinero/bug-2655-split-not-correctly-handled
Fix for split not correctly handled on Resolution.Daily
2018-11-05 16:40:56 -08:00
Jared e3cd28cae3 Merge pull request #2643 from dd-w/feature/portfolio_max_drawdown
Feature: Maximum Portfolio Drawdown
2018-11-05 09:25:26 -08:00
David 537d168d4c Fix algo description 2018-11-04 12:28:19 +08:00
David c35649b1b5 Add support for trailing portfolio stop loss 2018-11-04 08:41:38 +08:00
Martin Molinero ed0544b075 Fix for split not correctly handled
- In some cases, for Resolution.Daily, application of splits were
up to one day behind the data. Causing the 'early' data to use a
wrong factor value
- Updating regression test affected by issue
- Adding new regression test
2018-11-01 17:45:24 -03:00
David b59550dd59 Initial TrailingStop implementation
Restructured


Update message


Added removal of trailing highs for unnecessary securities


Add logging message


Improvements


Rename


Add regression Algorithm


Changed to use TradeBar values instead of only current price


Cleaned msg layout


Update Regression test
2018-10-29 08:57:44 +00:00
David f41315cb69 Remove non-conforming features 2018-10-25 23:40:50 +01:00
David dfd8027715 Add regression algorithm - MaximumPortfolioDrawdownFrameworkAlgorithm 2018-10-25 00:03:57 +01:00
Stefano Raggi ea55b8ba09 Fix failing CustomDataRegressionAlgorithm 2018-10-22 14:48:16 +02:00
Michael Handschuh a875023837 Merge pull request #2605 from QuantConnect/feature-2581-multiple-risk-models
Add CompositeRiskManagementModel
2018-10-18 12:25:04 -04:00
Michael Handschuh 72327507ad Rename MaximumUnrealizedProfitPerSecurty->MaximumUnrealizedProfitPercentPerSecurity
While it is a long name, this aims to provide consistency with it's inverted
brethern, the MaximumDrawdownPercentPerSecurity risk model
2018-10-15 13:52:41 -04:00