55 Commits

Author SHA1 Message Date
Adalyat Nazirov 7bb143b215 Bug 4031 Change data depending on configuration (#4650)
* Calculate both raw and adjuasted prices for backtesting

* disable second price factoring

* move and reuse method

* test coverage for new methods

* reuse scaling method

* reuse subscriptionData.Create method

* removed unused code

* regression test

* switch to aapl

* fix regression test output

* more asserts

* fix comments - reduce shortcuts and abbrevation

* more comments

* merge parameters

* reduce number of getting price factors

* fix tests

* fix tests

* fix regression tests

* calculate TotalReturn on demand

* include TotalReturn calculations

* perf tuning

* more unit tests for SubscriptionData.Create

* simplify things - store and return only raw and precalculated data

* fix regression tests; change it back

* factor equals 1 for Raw data

* small changes

* follow code style

* implement backward compatibility
2020-09-09 18:40:19 -03:00
Martin-Molinero 400a0d42d9 Add internal subscription manager (#4678)
* Add internal subscription manager

- Add InternalSubscriptionManager that will handle internal
  Subscription. Replaces the realtime updates
- Fix thread race condition in the TimeTriggeredUniverseSubscription, we
  have one thread injecting data points, the main algorithm thread, and
  the base exchange is pulling from it
- Fixes for FakeDataQueue
- Adding unit tests

* Address reviews and fixes

- Internal subscription will use extended market hours
- Only sample charts accordingly
- Get api-url once
2020-09-01 21:22:22 -03:00
Michael Handschuh 32077c0ddf Use ConcurrentSet<T> for SubscriptionDataConfig.Consolidators
Fixes #3603
2019-09-25 02:28:20 -04:00
Michael Handschuh d709d1c4e0 Update Common to respect CA1304 and CA1305
Updates all occurrences of parsing/ToString-ing to go through the new
StringExtensions methods that use CultureInfo.InvariantCulture

See #3045
2019-09-12 14:13:24 -04:00
Martin Molinero 08b72c5907 Overall performance improvements v2
- Adding `LazyToUpper()` implementation, that will avoid the call to
`ToUpper` if the string is already upper.
- Reduce the timezone conversions at `Time.EachTradeableDayInTimeZone`
- `TotalPortfolioValue` will iterate over all securities once
- Adding new `SecurityIdentifier` cache, significant impact for
algorithms using coarse/fine data
2019-06-05 17:06:59 -03:00
Michael Handschuh f9f648d41c Add DataNormalizationMode to SubscriptionDataConfig.ToString
This will aide in finding differences between regression tests
2018-03-19 12:40:54 -04:00
Michael Handschuh a98d8aa62f Copy consolidator reference so added ones receive data
Since we're creating a new instance of the SubscriptionDataConfig, any new
consolidators added afterwards (includes incdicators) won't receive pricing
updates because they'll be on the wrong config. They would be attached to the
config that live in SubscriptionManager.Subscriptions
2017-12-14 23:33:38 -05:00
Stefano Raggi d972c4d0a5 Fix subscription sharing issue with universe selection in backtesting
In backtesting with universe selection, when symbols are be added and removed the next day, we have experienced slightly different backtesting results for the same algorithm. This was caused by invalid factors applied to equities due to the sharing of a SubscriptionDataConfig instance between two threads.

The issue was solved by calling the SubscriptionDataConfig copy constructor in Universe.GetSubscriptionRequests.
2017-09-21 00:21:34 +02: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
Stefano Raggi 2fb4847b41 Handle subscriptions for existing brokerage Option holdings 2017-05-19 15:50:45 +02:00
Andrew 9e2c435593 Forex and CFD Tick resolution SubscriptionDataConfigs are added as Quotes not Trades 2017-02-15 11:54:26 -05:00
Stefano Raggi ed4a7efefc Add missing DataNormalizationMode in history requests
Previously, DataNormalizationMode in history requests was always being set to the Adjusted default value, so SetDataNormalizationMode calls were not being respected in SubscriptionDataReaderHistoryProvider.GetHistory and warmup.
2017-01-31 23:50:52 +01:00
Andrew Hart 99b9c7626e Expanded SecuirtyManagerTests to include Cfds, Concrete Options and Concrete Futures 2017-01-16 11:42:42 -05: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 5803115548 Option splits and renames in backtesting. Added regression tests. 2016-10-26 21:20:03 +02:00
quant1729 58c3ca21ca Added support for underlying in Symbol class 2016-08-24 16:30:55 +02:00
Stefano Raggi 5524034377 Add Type.Name to SubscriptionDataConfig.ToString 2016-08-02 23:51:46 +02:00
Stefano Raggi 84ad9694eb Added SubscriptionDataConfig.ToString 2016-05-11 17:46:26 +02:00
Michael Handschuh e34ebe4d11 Add equality members to SubscriptionDataConfig 2016-04-12 19:06:33 -04:00
Michael Handschuh 9cf86614cd Properly set option subscription data type/tick type 2016-04-07 06:46:23 -04:00
Michael Handschuh cc25950e10 Adds SubscriptionDataConfig.IsFilteredSubscription
Subscriptions can now be explicit as to whether or not a SubscriptionFilterEnumerator is to be applied.
Regular security price data subscriptions get filtered (user/market-hours)
Universe subscriptions don't get filtered (even if a subscription of equity price data, such as options underlying feeds)
2016-04-05 15:51:45 -04:00
Michael Handschuh 86004cb55a Adds TickType to config - use in GetSource 2016-02-24 09:31:34 -05:00
snugs f9734c9447 Remove unused parameters from SubscriptionDataConfig.ctor 2015-12-07 12:32:47 -05:00
snugs 95bfe729a8 Adds ExchangeTimeZone to SubscriptionDataConfig 2015-12-01 12:03:00 -05:00
snugs 6f15d4e569 Rename SubDataConfig.TimeZone to DataTimeZone
Also reviewed usages to check for data time zone vs exchange time zone
2015-11-30 18:43:41 -05:00
snugs 43fc0a2d6d Cleans up some methods accepts Symbol, sec type/market 2015-11-19 20:16:03 -05:00
snugs 7b6c82841f Initial implementation of SecurityIdentifier 2015-11-12 13:55:42 -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 c67ff638f4 Renames Symbol.SID to Symbol.Permtick
Coming soon we'll have a full SID system, so renames to make backwards compatibility easier
2015-09-20 23:14:53 -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 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 836cbbaa38 Remove IsTradeBar/HasVolume from sub data config 2015-08-12 14:43:23 -04:00
snugs c8c32b4838 Remove dependence on SubscriptionIndex 2015-08-06 17:52:22 -04:00
snugs 019496b252 Use hashset to prevent duplicate consolidators 2015-08-01 12:58:31 -04:00
snugs 6bd38ece77 Adds international/timezone support
Time sync:
	* Data feeds are required to time sync in UTC time
	* TimeSlice.Time is now in UTC

IAlgorithm
	* Time is now exclusively the algorithm's local time zone
	* Added UtcTime
	* SetDateTime( DateTime ) accepts a UTC time and is internally converted

SubscriptionDataConfig
	* Adds market and time zone as required ctor parameters

SecurityExchange
	* Now passes most calls directly through to SecurityExchangeHours class

SecurityExchangeHours
	* Holds market hours for each day of week (LocalMarketHours)
	* Talks in terms of local times in the SecurityExchangeHours.TimeZone time zone

Data/market-hours/
	* New data folder to hold market hour information
	* Includes market-hours-database.csv to hold market hours per market/symbol/security (see doc in file)
	* Includes holidays-usa.csv to hold holidays for 'usa' market
		+ The holiday files follow the pattern 'holidays-*.csv' where * is the market

TimeKeeper
	* Receives updates in UTC time
	* Passes that to LocalTimeKeeper's who lazily evaluate the time in their respective time zones
	* Eventually this can grow to be the sole source of time in the algorithm's scope

MISC:
	* Fixes exception thrown when exiting LiveTradingDataFeed
	* Fixes exception thrown when exiting FileSystemDataFeed
	* Fixes exception thrown when exiting StatusPing
	* Simplify FillForwardEnumerator logic with GetNextMarketOpen
	* Adds many time zones, see TimeZones.cs
2015-07-08 18:45:34 -04:00
QuantConnect 26e8cf4a21 Rework liquidity provider & country code to generic Market class, commented out python buggy code 2015-06-18 20:18:51 -04:00
QuantConnect 0f9f30be91 Typo fix in liquidity data provider 2015-06-17 17:43:59 -04:00
snugs 3c45ee2ff9 Update TotalReturn mode to use split adjusted prices 2015-06-16 16:15:40 -04:00
QuantConnect 5a810690b4 Moved Equities to be grouped by country code, forex grouped by liquidity provider 2015-06-14 12:31:44 -04:00
QuantConnect fde0cbed3a Strip out block quote section header comments 2015-06-13 16:04:27 -04:00
snugs e1d9b8a913 Set default normalization as Adjusted 2015-04-24 16:41:12 -04:00
snugs 6447909413 Adds split adjusted normalization 2015-04-24 12:05:00 -04:00
snugs 6fd357b710 Adds support for dividends and splits
Updates SubscriptionDataReader to use IStreamReader
Adds FactorFile and MapFile helpers
Adds support for Raw, Adjusted, and TotalReturn data normalization and portfolio application
2015-04-23 20:39:59 -04:00
snugs 3af7d5ed43 Adds firing of dividend events 2015-04-23 14:31:15 -04:00
snugs 4714ee1276 Cleans up SubscriptionDataConfig comments/ctor 2015-04-23 10:38:56 -04:00
snugs 72aba5e5fa Adds dividend data type
Also renamed config.Security to something more sane
2015-04-23 10:31:18 -04:00
snugs eba1696f33 Updated SubscriptionDataConfig to class 2015-04-14 13:37:42 -04:00
snugs 72e70d82b6 Make SubscriptionDataConfig have readonly fields 2015-04-14 13:35:08 -04:00
snugs 1f15eb2c04 Initial implementation of Margin and Portfolio models
Changed system to use Margin Models, removing leverage wherever possible allowing for dynamic margin models.
Created first portfolio fill model for FOREX which treats it as a currency swap through the cashbook instead of a tradable asset.
Updated the Securities/SecurityPortfolioManager to use cashbook value + holdings removing FOREX virtual positions.
Created a new benchmark system for comparing quantconnect builds.
2015-04-13 20:51:43 -04:00