Commit Graph

55 Commits

Author SHA1 Message Date
Martin Molinero 251071ee73 Remove Security from Subscription
- Removing unneeded `CashBook` instance to create a new `TimeSlice`
- Adding new `TimeSliceFactory`, an instance base class that will
provide methods to create a new `TimeSlice`. Will own the `DateTimeZone`
property.
- Adding new `ISecurityPrice` and `IOptionPrice` that will provide a
reduced interface for accessing price properties and methods used when
creating a new `TimeSlice`
2018-11-14 18:28:18 -03:00
Martin Molinero 2479768b7e Fix for null reference in TimeSlice.Create when calling HandleOptionData 2018-07-23 14:43:44 -03:00
Michael Handschuh 5d69b2a5e2 Remove disposed security data from TimeSlice
If we pull data and on the same time step that security gets removed,
we can still get that data in OnData(Slice) even though it was removed.
This change filters out removed securities by tracking a reference to
the subscription's disposed flag. Another change was made to wait until
the end of the time step to dispose of subscriptions.

Add IDataFeed.GetSubscription(SubscriptionDataConfig)
2018-05-24 17:40:29 -04:00
Michael Handschuh a5179bc6ab Add universe data to TimeSlice
Pipes universe data from the data feed, through TimeSlice.Create and adds
TimeSlice.UniverseData dictionary property for read access from the algo
manager, where the data will be placed onto the correct security object.
2018-04-24 18:23:00 -04:00
AlexCatarino d9a7e1dcd7 Adds Volume property to FutureContract and OptionContract
Minor change in `TimeSlice` to update `FutureContract.Volume` and `OptionContract.Volume` with `TradeBar.Volume` value.
2018-03-23 09:58:22 +00:00
Michael Handschuh 163dc6c5c1 Move security type ordering to SubscriptionCollection
This will change the order in which we enumerate subscriptions so we don't need
to re-sort inside of TimeSlice.Create.

The way we currently build time slices requires that we receive the underlying data
before any derivative data. This change ensures that we enumerate the underlying equity
data before we process any derivative data, such as options.
2018-02-12 14:31:06 -05: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
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
Stefano Raggi e19d9ce242 Fix option chain underlying price in TimeSlice
When creating time slices, in the option chain object the price of the underlying was set to the value of the previous time step when using AddOption and was equal to zero when using AddOptionContract.

For each time step in algorithm.OnData, these expressions are now guaranteed to have the same value:
- algorithm.Securities[underlyingSymbol]
- optionChain.Underlying.Price
- optionContract.UnderlyingLastPrice
2017-12-13 14:41:51 +01:00
AlexCatarino c5da472abe Changes SecurityCache.AddData to not save suspicious tick
When Tick data is suspicious, do not save it. It will prevent orders to be filled with suspicious data.
Ref. #1023
2017-12-12 18:48:50 +00:00
Stefano Raggi c0b1077dbc Update Tick quantity fields from integer to decimal
Tick.Quantity: int -> decimal
Tick.BidSize: long -> decimal
Tick.AskSize: long -> decimal
2017-08-16 20:30:14 +02:00
Stefano Raggi 7a68448cd8 Fix build errors 2017-06-26 23:34:20 +02:00
Stefano Raggi e1710e9031 Remove BaseData underlying symbol from Future symbol 2017-04-17 13:52:23 +02:00
quant1729 1305d96edd Open interest support: backtesting, converters, live data handlers (IQFeed/IB), live trading (IB). First cut. Regression Test. 2016-11-15 21:33:33 +01:00
quant1729 7b71c1a0e8 Fixing contract.UnderlyingLastPrice bug (trello #1103) 2016-11-01 16:38:25 +01:00
quant1729 5803115548 Option splits and renames in backtesting. Added regression tests. 2016-10-26 21:20:03 +02:00
quant1729 f89ea2183f Added real-time support for futures. Tested with IQFeed, IB. 2016-09-28 19:10:03 +02:00
quant1729 b3590647b5 Support for option strategies in API, QL option pricing models:
- Added OptionStrategies class with 10 popular option strats
- Defined OptionStrategy class
- Added support for trading of option strategies in QCAlgorithm.Trading.cs
- Added several estimator interfaces to introduce QL pricing models extention points: IDividendYieldEstimator, IRiskFreeRateEstimator, IUnderlyingVolatilityEstimator provided default implementation (flat term structure)
- Added QLOptionPriceModel class that contains meat of the calculations
- Added OptionPriceModels class that exposes 12 popular option pricing models to the user: those include Black Scholes, Barone-Adesi Whaley, Bjerksund Stensland, Crank Nicolson FD, Binomial Trees and more.
- Modified Greeks class to support lazy evaluation and introduce IV
- Partially tested on live data and trading (IQFeed/IB) and backtests. Need more data for tests.
2016-09-20 17:14:25 +02:00
quant1729 0396841d82 - Added support for sourcing and caching the full symbol list from IQFeed website.
- Added IQFeed options support to toolbox: option chain universe, option symbol list, subscriptions, live prices
- Added LiveTradingDataFeed to support options live screaming
- Added IB live options trading support: trading orders, holdings, live option exercising
- Modified ISymbolMapper interface to support derivatives (options, futures)
- Fixed minor bugs with (introduced ealier) symbol changes for options
Tested with IQFeed version 5.2.4.2. IB TWS offline version 957.
2016-09-14 21:56:12 +01:00
quant1729 58c3ca21ca Added support for underlying in Symbol class 2016-08-24 16:30:55 +02:00
Stefano Raggi ed89e09304 TimeSlice now handles multiple custom data of same type and same symbol 2016-06-12 14:34:18 +02:00
Stefano Raggi 73845ee080 Fixes TimeSlice bug preventing multiple custom symbols of same type 2016-06-11 22:29:35 +02:00
jaredbroad ebbe704ac4 First commit; DailyFX with JSON Subscription factory 2016-05-27 23:22:18 -04:00
Stefano Raggi 114f82f391 Merge from master 2016-05-12 21:29:58 +02:00
Matt 2e9be20ab7 Fixed an issue where TimeSlice was duplicating ticks 2016-04-23 21:42:15 +08: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 14bd34e64c Evaluate IOptionPriceModel
This is done lazily since some of these models can be computationally expensive.
2016-04-07 14:18:23 -04:00
Michael Handschuh d6dc2441f1 Handle options data in TimeSlice.Create 2016-04-07 14:18:13 -04:00
Michael Handschuh bf7f8bc72d Adds QuoteBars/OptionChains to Slice 2016-04-07 13:39:28 -04:00
Michael Handschuh 83d6fc6560 Allow multiple security data updates per time slice 2016-03-31 20:00:39 -04:00
Michael Handschuh a333e6a463 Extract method in TimeSlice.Create
We'll want to reuse this in the options branch, so easier merging to do this refactor on master
2016-03-22 09:57:36 -04:00
Michael Handschuh d413366614 Convert if/else to switch
This will make for easier merged since options branch has this as a switch statement
2016-03-17 12:18:59 -04:00
Michael Handschuh a3d7d66554 Converts cache list kvp to list DataFeedPacket 2016-03-02 20:36:20 -05:00
Michael Handschuh 13227dc212 Make TimeSlice custom data kvp to enumerable 2016-03-02 20:05:28 -05:00
Stefano Raggi 19496fdaff TimeSlice.Create - Removed extra ConvertFromUtc call 2016-01-04 21:55:54 -05:00
snugs b6ae391678 Count BaseDataCollection.Data.Count towards data point counts 2015-12-09 16:36:12 -05:00
snugs 4f73c7ecea Make Slice DataDictionary lazy eval 2015-12-07 12:02:16 -05:00
snugs f3fe4d1f35 Check for internal feeds on custom data
Internal feed data is not intended to be pumped into algo
2015-11-03 19:14:12 -05:00
snugs f296d666ee Implements user defined universes
This places all security subscriptions within a universes
Subscriptions generated via calls to AddSecurity are place in a UserDefinedUniverse
UserDefinedUniverse will serve up a predetermined list of symbols on a requested interval
LiveTradingDataFeed - reworked custom enumerators to use RefreshEnumerator as wrapper for rate limitting
2015-10-21 13:05:17 -04:00
snugs 6f15f4139b Move all subscriptions into a universe 2015-10-21 13:05:11 -04:00
snugs a642e734fd Rename Fundamental namespace to UniverseSelection 2015-10-07 12:54:26 -04:00
Stefano Raggi 86f8de74c7 Fixes bug in TimeSlice with internal data feeds
Error "EURGBP: requires EUR and GBP to have non-zero conversion rates. This can be caused by lack of data."
2015-09-21 12:44:40 -04:00
snugs f7d6ae6d5e Prevent internal feed data from entering ticks/bars collection 2015-09-20 23:03:31 -04:00
snugs 3ad5540a8a Remove dependency on Security from SubscriptionDataReader
Add dynamic data flag to config
Remove dynamic data flag from Security
Rename dynamically loaded flag to IsCustomData
Remove Security from SubscriptionDataReader ctor
2015-09-15 15:40:12 -04:00
snugs 388a6949fc Refactor TimeSlice.Create to not require IAlgorithm 2015-09-15 15:40:08 -04:00
snugs e1938baafe Clean up using directives 2015-09-01 22:17:35 -04:00
snugs df79ce30c2 Adds the Symbol type
This includes updating all usages of symbol as a security identifier to use the new type.
The type includes a unique field, SID, as well as the current ticker's value. This allows
for consistent addressability while also allowing the ticker to evolve over time with the
mapping changes.

Effort was made to maintain compile and runtime backwards compatibility.
2015-09-01 22:17:10 -04:00
snugs 4bc2092d8c Adds OnData(SymbolChangedEvents) handler 2015-08-25 21:22:43 -04:00