Commit Graph

239 Commits

Author SHA1 Message Date
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
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
Stefano Raggi 24ccda8b9a Update SubscriptionDataReaderHistoryProvider to handle symbol changes 2019-01-17 12:49:16 +01: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 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 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 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 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
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
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
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 dfd8027715 Add regression algorithm - MaximumPortfolioDrawdownFrameworkAlgorithm 2018-10-25 00:03:57 +01:00
David 28bc066692 Add CompositeRiskManagementModelFrameworkAlgorithm 2018-10-08 22:11:14 +01:00
Jared Broad c4d0baab49 Added 2 example benchmark alphas 2018-08-14 18:43:45 -04:00
Michael cfb05d190f Merge pull request #2328 from AlexCatarino/feature-2326-implements-futures-template-framework
Implements BasicTemplateFuturesFrameworkAlgorithm
2018-08-02 10:44:09 -04:00
Stefano Raggi dc4b961ec8 Update CoarseFundamentalTop5Algorithm to run as cloud regression test
- The algorithm has been renamed to CoarseFundamentalTop3Algorithm and updated to select the Top 3 instead of Top 5.
- The only new data required is daily, map and factor file for FB and has been added (map and factor files are dated 6/4/2018, as required by all regression tests).
- The coarse fundamental open source data has been updated.
- The expected regression statistics for the algorithm have been updated.
2018-07-31 21:20:06 +02:00
AlexCatarino e5ed09924b Implements BasicTemplateFuturesFrameworkAlgorithm
This algorithm shows how to implement a futures strategy in a framework algorithm.
`FutureUniverseSelectionModel` portfolio selection model was implemented to provide a base class to help create other futures universe selection models.
2018-07-30 22:21:47 +01:00
Juan José D'Ambrosio 84e0074350 Adding a control to avoid set the last trading date in a holiday
Move delisting date estimation to the constructor

Using `MarketHoursDatabase` for option delisting date estimation instead USHolidays
Adding file header.
Regression algorithm added.

Use of  `ExchangeHours.IsDateOpen` instead  `ExchangeHours.IsDateOpen.Holidays`.
Extract values from `symbol.ID` into a local variable.


Improved Regression test
2018-07-24 16:04:33 -03:00
Art Wild d5996fb7c8 MV & BL portfolio optimization implementation
Closes #1998. Closes #2219.
2018-07-24 16:53:11 +01:00
Stefano Raggi 3d48efcbea Add Tiingo Daily Prices example algorithm 2018-07-24 13:24:52 +02:00
Stefano Raggi fde0239930 Fix failing internal feed regression algorithms 2018-07-23 14:25:28 +02:00
Michael 975c2845c3 Merge pull request #2246 from QuantConnect/feature-2245-updates-pythonnet
Update pythonnet version to v1.0.5.8
* Includes fix for date time UTC bug
2018-07-18 11:26:19 -04:00
Martin Molinero ff5e888313 Fix for delisted subscription data being sent 2018-07-18 09:45:13 -03:00
AlexCatarino 8e3b7153b2 Rebase with pythonnet/master and fix datetime UTC bug
Updates pythonnet with pythonnet/master and fix datetime issue ([65ac279](https://github.com/QuantConnect/pythonnet/commit/65ac279a03dbded39fe3e28bb79c233f0c970f6f)).
2018-07-16 11:52:54 +01:00
AlexCatarino 0a6488ba5b Removes PairsTradingAlphaModelFrameworkAlgorithm
This algorithm uses the `BasePairsTradingAlphaModel` that should only be used as a base class, since it doesn't have a method to select the pairs.
2018-07-11 23:40:30 +01:00
AlexCatarino 6121236f20 Implements PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm
This algorithm is an example on how to extend the `BasePairsTradingAlphaModel` to select a pair to trade based on pearson correlation.
2018-07-11 23:40:29 +01:00
Martin Molinero 96dc5e8673 Moving IRegressionAlgorithmDefinition to QuantConnect.Common 2018-07-03 13:34:27 -03:00
Jing Wu 15e67b4ddd Renamed IndicatorWarmupRegressionAlgorithm 2018-06-28 11:56:23 -04:00
Jing Wu 891cd5952a Renamed HistoryAndWarmupRegressionAlgorithm 2018-06-27 17:42:35 -04:00
Michael Handschuh 9ee61f425c Refactor regression algorithm to IRegressionAlgorithmDefinition
A mechanical refactoring was performed to make algorithms currently used in
regression algorithms to implement IRegressionAlgorithmDefinition, which allows
algorithms to define their own expected statistics and what languages should be
run as part of regression. The type name of the  C# type is used to determine the
file/model name for python. This was for simplicity, but if needed, could later be
refactored to expose more information, but for now the convention of keeping names
the same makes sense and just works easily.
2018-06-05 12:10:50 -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
Michael Handschuh 80e01e0d1f Add support for removing universes
Adds the concept of universe disposal which is requested by an algorithm
through invocation of UniverseManager.Remove, which is invoked via
algorithm.RemoveSecurity. This instructs the data feed that the algorithm
has requested to completely remove the universe and any child subscriptions
from the feed. Security changes are fired for all removed securities.
2018-05-30 15:55:33 -04:00
Michael Handschuh e95157b097 Add QCAlgorithmFrameworkBridge for easier porting of QCAlgorithm
Provides demonstration algorithm showing the steps required to convert a
QCAlgorithm into the framework with minimal code changes.

1. Subclass QCAlgorithmFrameworkBridge
2. Add EmitInsights calls to where orders are placed
3. Profit :)
2018-05-29 22:42:16 +01:00
Michael Handschuh 6f4b15e182 Add demonstration of porting old algorithm to framework 2018-05-29 22:41:07 +01:00
Jared f0a3196b00 Merge pull request #2041 from jingwu74/master
Adding Benchmark algorithms
2018-05-29 17:38:55 -04:00
Jing Wu 6e8dd0d40f modify project file 2018-05-26 01:55:39 -04:00
Stefano Raggi ae427a14d0 Add regression algorithms for this bug fix 2018-05-25 22:06:28 +02:00
Jared d3c70c93b1 Update QuantConnect.Algorithm.CSharp.csproj 2018-05-21 19:59:31 -04:00
AlexCatarino ec63bffaa2 Modifies CoarseFundamentalTop5Algorithm
Renames CoarseUniverseTop5DollarVolumeAlgorithm.cs to CoarseFundamentalTop5Algorithm.cs: fine name was unconsistent with class name (not a QuantConnect pattern).

Adds Log method calls to python algorithm that are present in C# example.
2018-05-10 19:44:19 +01:00
AlexCatarino 24af1bd7cd Adds universe selection algorithm with custom security initilizer 2018-05-10 11:58:11 +01:00
AlexCatarino b476e22e41 Implements EmaCrossUniverseSelectionModel
Adds EmaCrossUniverseSelectionModel and EmaCrossUniverseSelectionFrameworkAlgorithm to show the new model in action
2018-05-08 18:54:17 +01:00
AlexCatarino 61b5859446 Implements SectorExposureRiskFrameworkAlgorithm
This algorithm and its regression test are meant to test the `MaximumSectorExposureRiskManagementModel`.
2018-05-03 21:53:14 +01:00
Stefano Raggi 38ac2c5d72 Add TimeInForceAlgorithm regression tests 2018-04-30 20:18:18 +02:00