Commit Graph

256 Commits

Author SHA1 Message Date
Stefano Raggi dd1ba650a2 Fix consolidators not updating during warmup with tick resolution
Fixes #1724
2018-03-20 11:46:33 +01:00
Stefano Raggi d87fc1f264 Fix error when using SetWarmup with Tick resolution
Fixes #1716
2018-03-19 16:15:30 +01:00
Michael Handschuh 6b239674e2 Renames Alpha -> Insight
The term 'alpha' is used to describe the entire algorithm. Therefore, 'alpha'
produces insights. From this we have things like IAlphaModel, which is the model
defining how insights are produced. We have IAlphaHandler, which defines how the
insights from a single 'alpha' (the algorithm) are managed, analyzed, and stored.
Types closer to the individual prediction level, such as InsightDirection, or
InsightScore relate directly to exactly 1 insight. The distinction between the
two became more clear as we developed the insights API, and from that effort it
was decided to harmonize alpha/insight terminology across the various QC systems.
2018-03-09 16:12:56 -05:00
AlexCatarino 9f691113e6 Fixes subscription not found due to PythonData warm up history request 2018-02-14 17:02:12 +00:00
Stefano Raggi 1bf6ffd85b Fix consolidator updating during warmup
When creating time slices for warmup history requests, data for security types with multiple tick types (Crypto, Futures, Options) were being matched to the configuration for the first subscription, instead of using the correct data type.

For example, with the Crypto security type, historical data of type TradeBar was passed to TimeSlice.Create with a SubscriptionDataConfig object for the QuoteBar data type.
2018-02-12 21:09:41 +01:00
Michael Handschuh f490fd4400 Remove cash updates from time slice
Instead of tracking just the security's symbol in the cash object we're now
maintaining a reference to the actual security object. This removes the need
to worry about cash update data in the time slice create method.
2018-02-09 14:51:47 -05:00
Michael Handschuh 10dfabfe91 Remove unused parameter from AlgorithmManager.Stream 2018-02-06 18:44:01 -05:00
Michael Handschuh 0c06f39cd3 Don't apply split warning events 2018-02-05 11:58:44 -05:00
Michael 99327d106c Merge pull request #1506 from QuantConnect/refactor-margin-models
Refactor margin model interface
2018-02-02 11:31:00 -05:00
Jared 2c7c5204c6 Merge pull request #1503 from QuantConnect/liquidate-options-on-split-warning
Liquidate options on split warning
2018-02-01 14:52:44 +00:00
Stefano Raggi 3d1ab08b44 Move Portfolio.ScanForMarginCall to IMarginCallModel.GetMarginCallOrders
The logic for margin calls was previously split between SecurityPortfolioManager.ScanForMarginCall and IMarginCallModel methods, now it is entirely contained within margin call model implementations.

One of the margin call model tests was also testing against the Null model, it has been updated to use the DefaultMarginCallModel.
2018-01-31 11:47:35 +01:00
Michael Handschuh ac23c6b889 Liquidate option contract holdings before split events
Using the newly added split warnings, submit market on close order at the last
possible moment to liquidate option contract holdings. After the liquidate order
has been submitted, we now mark the option contract as non-tradable, thereby
preventing any further trading in post-split option contracts.

This is added because we currently do not properly support option contract splits.
To properly support, we'll need some extra data sources defining how the contracts
are rewritten due to the split event. This data is freely available via the OCC in
pdf format.
2018-01-23 15:03:48 -05:00
Ben Sauerwine bb9c11c4ba Re-use _timeLoopMaximum in error message. 2018-01-22 11:32:32 -06:00
Ben Sauerwine 2a4c567aaf Fix misleading error message in AlgorithmManager. 2018-01-22 11:20:42 -06:00
Michael Handschuh dfce99f575 Sample alpha scores on next time step, ignore mag scores if mag=null 2017-12-28 11:27:40 -05:00
Stefano Raggi fc77b886a6 Fix subscription removal in SubscriptionCollection.TryRemove
This method was not removing the symbol dictionary entry when removing the last subscription, allowing the collection to grow excessively over time (especially with universe selection algorithms).

This PR also includes a few minor performance fixes.
2017-12-22 00:03:35 +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
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 Handschuh 2295e524f4 Add IAlphaRuntimeStatisticsGenerator and send to result handler
Provides estimates of alpha value as well as performs online computations of
alpha scores and other KPIs.

Sends alpha stats to result handler
Update live result with framework flag
2017-12-20 08:33:30 -05: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
Stefano Raggi 4d805384d3 Fix inverted order message for option assignment/expiration 2017-12-13 10:37:32 +01:00
Michael Handschuh 5910bc620f Add ISignalHandler
Handles signals generated by the algorithm. The default implementation
sends a SignalPacket to the messaging handler.
2017-12-12 08:56:19 -05: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 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
Stefano Raggi 1295c91551 Update order event messages for option expiration
The message for short option order events at expiration was "Automatic option assignment on expiration" for both ITM and OTM. It has now been corrected to "Option expiration" for OTM short options.

The same message is now also being reported in QCAlgorithm.OnAssignmentOrderEvent instead of the generic "Option Assignment" message.
2017-12-05 00:49:41 +01:00
Jared Broad c475bde19e Increase timeout and add initialized check 2017-10-23 22:03:33 -04:00
Michael Handschuh fdf6a68196 Properly round consolidator updates
This check ensures that the data is on the subscribed interval.
A bug was found where daily data with a different data tz and
exchange tz was not being pumped into the consolidator. This is
because we were rounding a time such as 20:00 by 1-day. If we
convert the time to the data time zone, it becomes 00:00 and
then the rounding operation returns the same input value which
signals that we should use this data point to update consolidtors.
2017-10-02 12:16:06 -04:00
Michael Handschuh 6292f1e286 Clean white space 2017-10-02 12:16:05 -04:00
Andrew d893bd7398 Renamed ILeanManagement to ILeanManager
Renamed this interface and all associated classes and content to be more
in line with Lean naming conventions.
2017-08-09 16:15:52 -04:00
Andrew 3a7be01d78 Remove ICommand, ICommandQueueHandler and CommandResultPacket 2017-07-14 15:39:49 -04:00
Andrew 6d67dbd2a2 Added ILeanManagement.Update() method 2017-07-14 12:40:53 -04:00
Andrew 20109ff169 Remove Status update associated with algo finishing wamring up 2017-07-03 11:57:47 -04:00
oswaldozapata be5e718412 It has been added one call to log the message as debug message, also the check was moved out one level up. 2017-04-28 22:20:59 -04:00
oswaldozapata 44b50990e3 It has been moved the check for TotalPortfolioValue to the main loop and also now this control will be check in backtest only. 2017-04-28 08:47:49 -04:00
oswaldozapata 27f0bb7605 The wording was updated to "Portfolio value is less than or equal to zero" 2017-04-26 21:58:04 -04:00
oswaldozapata 9aad8655f7 It was added a new control to avoid going negative in portfolio value. Each second Lean engine will verify the TotalPortfolioValue, if this is less or equal to zero then Lean will stop the execution . 2017-04-26 21:27:36 -04:00
Stefano Raggi b41af9fec5 Fix bug in live mode consolidator updates with Tick resolution
This PR fixes issue #796
2017-03-22 22:20:49 +01:00
Stefano Raggi 3e70103e1f Remove time from the last point of benchmark and daily performance
In backtesting the timestamp of the last point includes time, the other points only have the date part.
2017-02-27 23:34:07 +01:00
Stefano Raggi 4149aba9d7 Fixed scheduled event firing time in backtesting
If backtesting, we need to check if there are realtime events in the past
which didn't fire because at the scheduled times there was no data (i.e. markets closed) and fire them with the correct date/time.
In live mode, no changes are needed.
2017-02-23 20:25:49 +01:00
quant1729 c416df6241 Refactored option assignment/exercise:
1. Made sure we treat properly option expiration dates before Feb 2015 and after. Added tests.
2. Refactored expiration delisting, assignments/option exercise to happen in the end of the date, not MOC orders in the beginning of the day. Regression test.
3. Refactored option exercise model to generate proper fills on assignments/option. Those fills are reflected correctly in margins, in stats and correspond to IB model. Still need to run IB real-life live tests.
4. Refactored option symbol related functions into separate module (OptionSymbol.cs)
5. Made sure OnAssignmentEvent arrived to the user algo in regression test. Do we need OnExercise event? Not sure.
6. Tested end-to-end Ray's current code (covered call strat) to see short option legs expire worthless, and stats updated.
2017-02-02 19:35:37 +08:00
jaredbroad 629d71a3eb Revert fix consolidators never updated by bad filter 2017-02-01 16:16:40 -05:00
Stefano Raggi 10f03155b1 ConvertToUtc before rounding up in consolidator filter 2017-01-31 20:58:34 +01:00
Stefano Raggi 15a751be3c Changed UtcTime rounding for consolidators to 1 second 2017-01-31 01:13:12 +01:00
Stefano Raggi c51d4fdba2 Fix consolidator not firing in live mode
Due to the recent filter to data for consolidators, algorithm.UtcTime needs to be rounded down to work in live mode
2017-01-30 23:13:19 +01:00
Jared 89254db694 Fixing issues from futures-options merge (#692)
* Swallow bug in QuoteBar.Reader() if an error is thrown during parsing

Following the pattern in TradeBar.Reader(), the QuoteBar.Reader() method will now swallow a parsing error, log the error message and line number and then proced to return a default instance of Quotebar.  The current implementation of QuoteBar.Reader() will stop the executation of the program if a parsing error is found.  Given the amount of data Lean may parse during the execuation of an algorithm, it is better to be resiliant to small errors in the data than to stop the execuation of the program because of a malformated line of csv.

* Added QuoteBar.Reader tests

* Minor changes to config.json; back to proper defaults

Remove QLLib.NET reference

Added date to QuoteBar.Reader() error message

* Incorrect timezone specified on consolidator filter
2017-01-15 16:41:09 -05:00
quant1729 7b31a792b1 Merge branch 'master' into futures 2017-01-14 01:17:11 +08:00
Stefano Raggi 6e9060e10f Fix time zone bug in consolidator input filter 2017-01-13 17:56:02 +01:00
quant1729 c253c22ddd Merge branch 'master' into futures 2017-01-13 12:12:28 +08:00