Commit Graph

285 Commits

Author SHA1 Message Date
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
Stefano Raggi ec5d4c0621 Filter consolidator inputs on data resolution
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.
2017-01-12 00:56:58 +01:00
quant1729 145ba7bd83 Updated code as per PR 2017-01-02 19:47:23 +01:00
quant1729 3819561a82 Merge branch 'futures' into master-futures-merged
Conflicts:
	Common/QuantConnect.csproj
	Tests/RegressionTests.cs
2016-12-01 17:32:40 +01:00
quant1729 92a3be5ea5 Merge branch 'futures-quotebar-easy' into futures
Conflicts:
	Common/Securities/SecurityManager.cs
2016-11-28 14:46:46 +01:00
quant1729 55299e60fb Added new constructors to IBMapper class
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.
2016-11-25 15:11:01 +01:00
Andrew Hart 835fca41ca Live FX trading can use quotebar data 2016-11-22 11:11:26 -05:00
Andrew Hart 6cd52a0b60 FX quotebars are now passed to algo as tradebars 2016-11-22 08:31:09 -05:00
Andrew Hart 20c11e8e9d If QuoteBar data is present, OnData(TradeBar) will still work 2016-11-21 15:21:31 -05:00
Michael Handschuh 5809527a95 Scan consolidators to emit based on time
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.
2016-11-15 23:36:26 -05:00
quant1729 1141cd21e6 Merge branch 'futures' into master
Conflicts:
	Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj
	Algorithm/QCAlgorithm.cs
	Brokerages/InteractiveBrokers/InteractiveBrokersBrokerage.cs
	Common/QuantConnect.csproj
	Common/Securities/Option/Option.cs
	Data/equity/usa/factor_files/aapl.csv
	Data/symbol-properties/symbol-properties-database.csv
	Engine/DataFeeds/Enumerators/Factories/BaseDataSubscriptionEnumeratorFactory.cs
	Engine/DataFeeds/Enumerators/Factories/OptionChainUniverseSubscriptionEnumeratorFactory.cs
	Engine/DataFeeds/SubscriptionDataReader.cs
	ToolBox/QuantConnect.ToolBox.csproj
2016-11-07 16:18:11 +01:00
AlexCatarino e3c6e46da2 Adds divide by zero check before computing sample performance 2016-10-03 17:30:15 -03:00
quant1729 2dce74e26d - Extended Option security and Option holding classes
- 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.
2016-08-31 18:00:00 +02:00
AlexCatarino 9d32d4fd06 Reverts commit f4abe9c
Modifies logic in AlgorithmManager to account transations in the delisting day
2016-08-30 13:05:41 -03:00
Stefano Raggi 350fd6afe2 Fixed missing delisting events 2016-08-30 12:58:21 -03:00
AlexCatarino ede02d1b9b Fixes Delisting bug
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.
2016-08-30 12:57:56 -03:00
AlexCatarino f4abe9ce51 Prevents security removal from portfolio when delisted
Removing delisted securities from portfolio causes loss of information that is necessary to compute the algorithm statistics.
2016-08-19 12:58:35 -03:00
Michael Handschuh 04db12106a Merge remote-tracking branch 'origin/multi-subscriptions' into options-new
Conflicts:
	Engine/DataFeeds/UniverseSelection.cs
	Tests/QuantConnect.Tests.csproj
2016-04-13 12:45:05 -04:00
Michael Handschuh 2057858cfb Adds UpdataData<T> to clean up key value pairs in TimeSlice 2016-04-12 19:06:56 -04:00
Michael Handschuh 14776c6c21 Adds subscription configuration to DataFeedPacket ctor 2016-04-12 19:06:55 -04:00
Michael Handschuh 42465ffd52 Clean up IsInternalFeed usages 2016-04-12 19:06:49 -04:00
Michael Handschuh 73a4595d48 Adds Security.DataNormalizationMode
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
2016-04-12 19:06:35 -04:00