Commit Graph

861 Commits

Author SHA1 Message Date
Stefano Raggi 4d735756b2 Add error messages in CalculateOrderQuantity 2018-02-27 13:05:26 +01:00
Stefano Raggi 92b7b3ecc0 Normalize decimal value in SetHoldings message 2018-02-27 11:24:16 +01:00
Stefano Raggi 4318c17974 Update buying power model interface for better messaging
The HasSufficientBuyingPowerForOrder method has been updated to return a result object including the reason the order cannot be executed.

The SetHoldings method has also been updated to display a message if CalculateOrderQuantity returns zero.
2018-02-27 11:24:15 +01:00
Michael Handschuh 18a559943e Upgrade LEAN Python to 3.6 from 2.7
- Adds log to display the python version the algorithm is using.
- Fixes python algorithms that were failing because of small subtleties
like leading zeroes.
- Updates pythonnet with a version compiled with python 3.6 flags

- Changes in DockerfileFoundation: we now use miniconda to manage the python
environment.
- Took the opportunity to add NTLK (#1349), Tensorforce (#1369) and
PyTorch/Pyro (#1385).
- Changes readme in Algorithm.Python to show steps to install miniconda
2018-02-23 15:09:06 -05:00
Michael Handschuh facbf6c9e8 Remove daily universe tick
This setting forced the data feed and algorithm threads to synchronize every day
at midnight. The changes to the regression values are due to losing the benchmark
sample at midnight
2018-02-20 12:23:12 -05:00
Stefano Raggi 1943dcd99d Revert "Add duplicate security check in AddSecurity" 2018-02-20 15:07:03 +01:00
Stefano Raggi 79d33a5ea2 Add unit test for duplicate security check
Also updated error message to show user input parameters.
2018-02-17 01:29:31 +01:00
Stefano Raggi 74b4684dd3 Add duplicate security check in AddSecurity
AddSecurity was not checking if the security had already been added.
2018-02-15 20:06:54 +01:00
Jared 5eabec08b5 Merge pull request #1578 from AlexCatarino/fix-download
Adds user agent header to WebClient in Download method
2018-02-14 17:25:22 -05:00
AlexCatarino 83fda60cb8 Adds user agent header to WebClient in Download method
Add a user agent header in case the requested URI contains a query.
2018-02-14 21:58:19 +00:00
Stefano Raggi a39e6a8e28 Revert "Merge pull request #1526 from AlexCatarino/python3"
This reverts commit 2e523992d0, reversing
changes made to fa48fc23ea.
2018-02-14 16:03:12 +01:00
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
AlexCatarino 654d6ad9ce Adds overloads with PyObject to Logging and Debug methods
We enable Logging and Debug methods to accept python objects to avoid the need of calling the str method.
Those objects are safely converted into string objects.
2018-02-09 00:48:44 +00:00
AlexCatarino 6827624f83 Adds RegisterIndicator overloads that takes python-defined indicators
Adds example for this feature
2018-02-07 12:31:18 +00:00
Jared 67d8ce2be4 Merge pull request #1535 from Jay-Jay-D/MacdMAType
MACD default MovingAverageType
2018-02-06 23:31:07 +00:00
Michael Handschuh 667fde4786 Fixes bug w/ data feed initial frontier when changing default tz
Changing the default time zone after SetStartDate is set ends up with the algorithm's
UtcTime being incorrect. This can lead to incorrect start times in the data feed as
well
2018-02-06 09:29:13 -05:00
Juan José D'Ambrosio e38b520383 MACD default MovingAverageType
this RP only adds the Obsolete property to the constructor and `MACD` method in the `QCAlgorithm.Indicators.cs` file
2018-02-05 18:11:10 -03:00
Jared d5e6245c5f Merge pull request #1513 from Jay-Jay-D/CoppockCurve
Coppock Curve indicator implementation
2018-02-05 17:40:56 +00:00
Michael 99327d106c Merge pull request #1506 from QuantConnect/refactor-margin-models
Refactor margin model interface
2018-02-02 11:31:00 -05:00
Stefano Raggi acb5db6cf5 Rename Security.MarginModel to BuyingPowerModel 2018-01-31 11:47:34 +01:00
Stefano Raggi 05e3420d05 Move logic in CalculateOrderQuantity to SecurityMarginModel 2018-01-31 11:47:33 +01:00
Juan José D'Ambrosio e7223da4a7 Coppock Curve indicator implementation 2018-01-30 12:05:13 -03:00
Michael Handschuh 2e421c78cc Add MarketOnCloseOrder.DefaultSubmissionTimeBuffer
This is the default time span before market close that we'll allow an MOC
order to be placed. Nominally set to 15 minutes + 30 second buffer for
processing/transport.
2018-01-23 13:34:53 -05:00
AlexCatarino 599c00be5b Historical Data Requests fetchs data from non-subscribed securities
It was not possible to add a security based on its historical data, since we needed to add the security before requesting its security data. Universe Selection algorithms are an example of such usage.
2018-01-16 18:08:28 +00:00
Jared 755a0f8ba7 Merge pull request #1475 from StefanoRaggi/symbol-null-comparison-fix
Fix bug in Symbol inequality operator
2018-01-15 17:15:26 -05:00
Stefano Raggi 013edbcbcb Reuse existing OrderResponseErrorCode.AlgorithmWarmingUp 2018-01-15 23:01:17 +01:00
Stefano Raggi 89a59351cd Add OnWarmupFinished method to QCAlgorithm
This method is being added to allow algorithms to complete initialization tasks that cannot be executed during Initialize, such as cancelling existing open orders in live trading.
This method will be called only once, when the warmup task is complete.

Closes #1043
2018-01-15 13:46:30 +01:00
Stefano Raggi 1075571752 Replace Symbol.Empty checks with null checks 2018-01-12 21:56:10 +01:00
Jared 164bb80ba1 Merge pull request #1468 from AlexCatarino/lt-lotsize-msg
Adds OrderResponse error message for quantity less than lot size
2018-01-05 11:09:54 -05:00
Stefano Raggi 1db28b8358 Fix reserved chart names error in AddPlot
Fixes #1435
2018-01-04 23:59:43 +01:00
AlexCatarino 53ba7ee140 Adds OrderResponse error message for quantity less than lot size 2018-01-04 22:38:26 +00:00
Michael Handschuh 0cc6a53e9c Set correct time zone for custom data in MarketHoursDatabase
Add MarketHoursDatabase.SetEntry and SetEntryAlwaysOpen. This allows runtime modification of the
market hours database which is necessary for correct custom data time zone handling.

Extracts complicate ternary logic into its own method and make it human readable.
Set the market hours entry for custom data universe subscriptions defaulting to the security's time zone.
2018-01-04 12:36:57 -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 c6693cb237 Disable automatic security seeding
In this PR we are disabling the default security seeding (automatically getting the last price for a security when added to the algorithm) for a couple reasons, both when using large universes:
- In live trading, these history requests are sent to a history server, potentially causing timeouts
- In backtesting, depending on the algorithm this could also cause slowdowns up to 30%
2017-12-22 21:49:14 +01:00
Jared 5f64665598 Merge pull request #1425 from QuantConnect/concurrency-fix
Reduce full locking on ConcurrentDictionary objects
2017-12-20 18:56:30 -05:00
AlexCatarino 89575cb020 Sets Equity data to raw in option algorithms II
In #1390, we have implemented a feature that assured that prices from an option underlying are set to raw. If the algorithm adds options contracts with AddOptionContract method, that rule was not applied.
2017-12-20 22:32:13 +00:00
andrewhart098 c606a67b33 Merge pull request #1355 from AlexCatarino/pythonnet-update
Updates pythonnet
2017-12-20 16:30:54 -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
AlexCatarino bffa952c0a Fix missing tag from Liquidate call
Orders that are placed with Liquidate method did not come with the tag.
2017-12-19 14:40:05 +00:00
AlexCatarino c912c0d190 Updates pythonnet
In this update, we fixed type correspondence from C# Decimal to python decimal that caused wrong method overload binding.
2017-12-18 10:57:26 +00:00
Michael 9997abec89 Merge pull request #1372 from QuantConnect/feature-algorithm-framework
Initial release of the QuantConnect ALPHA streams feature.
2017-12-15 20:18:40 -05:00
Michael Handschuh b4b3aae112 Rename Signal -> Alpha
Whoa... I think I got everything :)
2017-12-15 18:24:58 -05:00
Michael Handschuh 2bc7905ea2 Add signal count and signal asset breakdown charts
Modifies the way we sample charts to be more like the equity sampling that we do.
In this case, we compute a sampling period based off of 1000 samples for the entire
backtest. In live mode, we'll just sample each minute.
2017-12-15 16:01:09 -05:00
Michael Handschuh bd9c14ce3b Remove virtual from OnSignalsGenerated
The implementation of this method is critical to the workings of framework
algorithms and as such, we're not allowing it to be overriden.

Algorithms can receive signal events via the SignalsGenerated event.
2017-12-14 19:43:27 -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
AlexCatarino 7d3327aea2 Adds warning to notify DataNormalizationMode change 2017-12-12 20:31:29 +00:00
Michael Handschuh 063a11adac Merge remote-tracking branch 'origin/master' into feature-algorithm-framework 2017-12-12 14:06:46 -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