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.
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.
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.
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.
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.
* 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
This update reverts PR #664 and includes an improved filtering solution.
It prevents consolidators and indicators from receiving inputs at a resolution higher than the data subscription resolution, typically fill-forward bars.
Volume-based indicators and consolidators will now be calculated correctly with fill-forward data.
It also fixes the RegressionAlgorithm failing test.
Added support for history requirements, exposed by vol models. AM processes requirements.
Added new volatility model - standard deviation of returns - default vol model. Compared its results with publicly available.
Refactored option pricing engine to support optimal approximation calculations.
Added basic greeks approximation in case they are not available in QL. Tests.
Updated BasicTemplateOptionHistoryAlgorithm to print greeks.
Currently, most consolidators rely on receiving a piece of data after
the consolidation period before firing the consolidated event. This
introduces a lag in the results. We've mostly gotten around this for
the most common case through usage of the IdentityConsolidator.
The issue arises when considering fill forward behavior and subscriptions
with different resolutions.
Consider a Minute subscription a Daily subscription. Default behavior will
fill forward that daily bar on every minute. If your indicator is based on
the IdentityConsolidator, then it will receive the same price update for
each minute the security trades that day.
By scanning the consolidators based on time, the consolidator is able to
determine that it is indeed time for it to emit a new consolidated bar.
This removes the need for the IdentityConsolidator while also fixing the
aforementioned bug.
- Updated IB fee model to support option exercise
- Added support for splits for options. Not tested on real data yet.
- Added option exercise functionality for long positions. Unit Tests. Not tested on real data yet.
- Added option assignment functionality for short positions. Assignment event. Unit Tests.
- Added basic option assignment simulator for backtesting brokerage. Simulates assignments for deep ITM short positions close to expiration. Unit Tests.
Reverts commit f4abe9ce
Now delisted securities are removed using IAlgorithm.RemoveSecurity that properly removes a security from a SecurityManager: keeps it at the Portfolio, but remove it from the user universe, unsubscribing to the datafeed in the process.
A security must have a single normalization mode, any added subscriptions will need to be forced to the current mode and when updating the mode it must be done to all... this should probably be a 'locked' property as well since changing it mid execution can lead to unexpected behavior