Commit Graph

239 Commits

Author SHA1 Message Date
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
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
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
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
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 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
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
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
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
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 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
AlexCatarino 6d27c10e63 Sets Equity data to raw in option algorithms
In the options trading, the strike price, the options settlement and exercise are all based on the raw price of the underlying asset instead of the adjusted price.  In order to select the accurate contracts, we need to set the data normalization mode of the underlying asset to be raw.
2017-12-12 16:28:40 +00:00
Michael Handschuh cc3902de09 Set default benchmark to 2% per annum 2017-12-11 20:34:59 +01:00
Michael Handschuh 39f5080a40 Rename framework events to OnFramework<Event>
This more closely follows existing conventions.
2017-12-08 12:04:53 -05:00
Michael Handschuh c093b45319 Add IAlgorithm.SignalsGenerated event
This event will fire each time step that generates signals and will
include all signals generated by the algorithm at that time step.
2017-12-08 10:07:54 -05:00
Michael Handschuh 14a2a09581 Add explicit methods for updating framework models
IAlgorithm.FrameworkOnData is used to pulse models with new data each time step
IAlgorithm.FrameworkOnSecuritiesChanged is used to pulse models with security changes

These two functions need to be separate to ensure that if we add an indicator during
the securities changed event that it will get the data from the current time step.
This forces us to call the securities changed event before we invoke the consolidators
for the current time step.
2017-12-08 10:07:54 -05:00
Michael Handschuh 0591d45db2 Add QCAlgorithmFramwork w/ IPortfolioSelectionModel
Adds a default implementation of IPortfolioSelectionModel that creates a
universe using the securities explicitly defined by the user.
2017-12-08 10:07:53 -05:00
AlexCatarino 0efd3a0c48 Renames Fetch to Download 2017-12-04 22:20:19 +00:00
AlexCatarino 96562b335f Implements authentication headers 2017-12-04 21:25:41 +00:00
AlexCatarino a40ded1c14 Implements QCAlgorithm.Fetch method
Fetch wraps the WebClient.DownloadString method. It allows python users to fetch data from a uri without a third party python library.
2017-12-04 21:25:41 +00:00
Jared b34cedd646 Merge pull request #1311 from AlexCatarino/futures-quantbook
Implements historical futures data requests
2017-12-04 12:05:39 -05:00
AlexCatarino dfffbd6953 Adds IFutureChainProvider interface with base implementations
- Move BacktestingFutureChainProvider provider to Lean.Engine.DataFeeds along with its options equivalent.

- EmptyFutureChainProvider: provider that returns an empty list of symbols
- CachingFutureChainProvider: implements caching by date
- BacktestingFutureChainProvider: provider that gets chain from local files
- LiveFutureChainProvider: provider that gets chain from external source (empty list of symbols for now)
2017-12-04 14:16:59 +00:00
Maly-Lemire ba30b2c547 Merge branch 'master' into master 2017-11-29 21:12:16 -05:00
Maly Lemire 657d98fa59 Added SetWarmUp resolution parameter. 2017-11-29 20:57:41 -05:00
AlexCatarino 783d841a59 Changes AddData method return type
Unlike other methods used to add securities to the algorithm that return a Security or a derived object, AddData was returning void. This commit change it to return Security for consistency.
2017-11-16 14:41:08 +00:00
Stefano Raggi a24164ecec Refactor OrderProperties class to IOrderProperties interface
This change will make it easier to add other planned brokerage features:
for Interactive Brokers, besides Financial Advisor support, we will be adding IB algorithmic orders soon (PR #1203).
2017-10-26 18:22:11 +02:00
Stefano Raggi ddb3c7d33b Add DefaultOrderProperties to QCAlgorithm
The properties in the default instance can be modified by users duing Initialize.
These properties are always copied into all new orders submitted with any method available (Order, SetHoldings, etc.)
2017-10-26 18:15:08 +02:00
Jared ef9a841ae1 Merge branch 'master' into gdax 2017-10-13 21:43:19 -04:00
Michael Handschuh 7c0a0c4698 Set algorithm name in setup handler
When using the console setup handler, the algorithm's type name
will be used as an identifier.
2017-10-06 16:23:38 -04:00
Michael Handschuh ecd92462da Clean white space 2017-10-06 16:23:37 -04:00
jameschch@outlook.com 7fab872927 Integrates with crypto security 2017-09-15 13:42:51 +01:00
Jared 72b66501eb Merge pull request #1131 from QuantConnect/crypto-security
Crypto security
2017-09-14 10:48:31 -04:00
Stefano Raggi f94cb659cb Fix missing underlying security in AddOptionContract 2017-09-06 17:48:57 +02:00
jameschch@outlook.com 0f4e166499 Changes market deriving logic and adds extra test cases 2017-09-01 12:29:25 +01:00
jameschch@outlook.com 6c06413fe4 Moves existing bitfinex to crypto and updates crypto tests 2017-08-30 13:46:30 +01:00
jameschch@outlook.com ca4cd13476 Merge branch 'master' of https://github.com/QuantConnect/Lean 2017-08-29 11:11:04 +01:00
12112 921ec8f983 merge from upstream 2017-08-22 16:56:35 +01:00
Stefano Raggi 492bc70229 Fix Options and Futures subscriptions at Tick resolution
Previously Tick resolution subscriptions only received ticks with TickType.Trade, now TickType.Quote and TickType.OpenInterest are received as well.

This PR replaces PR #1065
2017-08-22 02:20:36 +02:00