Commit Graph

256 Commits

Author SHA1 Message Date
snugs 468b4cdb92 Remove (mostly) unused UniverseSelectionType 2015-10-07 12:54:29 -04:00
snugs c31eb7fa65 Adds support for multiple universes
This is a scaffolding step in that live will only use the first in the list
Also, there's no API helpers for doing this and it's assumed it's only coarse
fundamental data, the next change removes the coarse fundamental assumptions
2015-10-07 12:54:29 -04:00
snugs a642e734fd Rename Fundamental namespace to UniverseSelection 2015-10-07 12:54:26 -04:00
snugs e919d99053 Updated universe selection to be more generic
Includes changing FundamentalType to UniverseSelectionType
IDataFeed.Fundamental -> IDataFeed.UniverseSelection
FundamentalEventArgs -> UniverseSelectionEventArgs

All in preparation for another type of selection, hand-picked
2015-10-07 12:54:25 -04:00
snugs 78dc208fc7 Make IBenchmark instead of using Func directly
This is in an effort to keep IAlgorithm usable across various languages
2015-10-07 12:46:56 -04:00
snugs 93b17d3b4e Fixes potential exception when no requests have fill forward 2015-09-23 19:11:50 -04:00
snugs cc2db6c0db Force warmup to use equal fill forward resolutions
This matches what the data feed does, we maintain equal ff resolutions for ease of use in the algorithm
2015-09-23 14:39:31 -04:00
snugs e8c38993b0 Properly set internal feed history request ff resolution
Also log requests after we modify the internal feed subscription requests
2015-09-23 14:02:22 -04:00
snugs 7f04b28dbf Fixes bug resolving resolution for warmup internal feeds 2015-09-23 13:50:09 -04:00
snugs 3b0c2f6c7c Rewrite warmup history requests for internal feeds 2015-09-22 22:49:06 -04:00
snugs d4f8006443 Revert "Enforce a 100k bar limit on warmup requests"
This reverts commit 5d30dedb46.

*This check was removed from lean as it is a cloud only concern.
2015-09-22 21:15:08 -04:00
snugs 5d30dedb46 Enforce a 100k bar limit on warmup requests 2015-09-22 20:17:44 -04:00
snugs 19f2fbe0ec Fixes bug in timespan warmup
Better status messaging when finished warmup as well
2015-09-22 19:28:07 -04:00
snugs acdc3632e6 Correctly set previous time for first iteration 2015-09-22 18:46:37 -04:00
snugs 63ceefc4ed Initial implementation of algorithm warmup 2015-09-22 15:14:46 -04:00
snugs 8c8d0f5e0f Moves application of universe selection to algo manager 2015-09-22 15:14:42 -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
Stefano Raggi fac6f46a9a New Statistics implementation
Added Trade and TradeBuilder classes
Added UtcTime and OrderFee property to OrderEvent class
Added AlgorithmPerformance class with a few metrics + tests
Added portfolio statistics + rolling statistics

Closes #30 via PR #164

Thanks @SteffanoRaggi!
2015-09-16 20:48:02 -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 f405edc19d Cancel open orders on symbol changed events 2015-08-25 21:39:48 -04:00
snugs 4bc2092d8c Adds OnData(SymbolChangedEvents) handler 2015-08-25 21:22:43 -04:00
QuantConnect 872c379676 Bug fix LINQ margin call events without fills, version bump 2.1.3.5 2015-08-19 17:07:55 -04:00
QuantConnect 51d78332a4 Merge branch 'master' of https://github.com/QuantConnect/Lean 2015-08-18 21:31:51 -04:00
QuantConnect 780bbc8186 Benchmark moved to stacked on equity plot, bug fix time in live mode 2015-08-18 21:31:33 -04:00
snugs 0667f986b2 Fixes bug in data reader skipping days and aux data ordering
A midnight bar was triggering what was intended for only daily data,
restructured ResolveDataEnumerator to allow being called both when there
is more data in the enumerator and when it's not and do the right thing
2015-08-18 21:21:18 -04:00
snugs c4c48e535e Add try/catch around calls to potential user code 2015-08-14 10:44:58 -04:00
snugs 402dd6da8a Revert "Allow two forms of reflection methods"
This reverts commit 300e2eee9c.

We want to encourage usage of OnData(Slice), so let's not add more ways to do the same thing
2015-08-11 13:37:40 -04:00
snugs 300e2eee9c Allow two forms of reflection methods
OnData(TypeName data);
On{TypeName}(TypeName data);

For example,

OnData(Quandl data); // existing
OnQuandl(Quandl data); // new
2015-08-11 11:24:05 -04:00
snugs 844a040be5 Initial impl of coarse universe selection
Adds concept of Subscription to contain everything a data feed needs in order to process  single data feed item
Moves preparation of all data to data feed thread, algo thread receives data in format it needs
QCAlgorithm.SetUniverse( func ) allows selection based on market/symbol/dollar volume/price
Remove laziness from Slice as optimization, no order by in real time handler
2015-08-06 17:52:23 -04:00
snugs 8c9a69beaf Misc tidy up
Clean up offset provider
Fixes bug in GetBetterTypeName
Adds redelivered flag to log
Fixes bug in Slice.Time
Fire Slice only if data; Fire SecuritiesChanged after update
Add return to margin warning try/catch
2015-08-06 17:52:23 -04:00
snugs c8c32b4838 Remove dependence on SubscriptionIndex 2015-08-06 17:52:22 -04:00
Ray Bohac 1b9c1b7921 Initial implementation of custom benchmarks 2015-08-05 15:30:34 -04:00
snugs 7fa9a4b1be Implements self re-scheduling events
A ScheduledEvent can be defined using an enumerator of event times and a callback
2015-08-05 13:13:08 -04:00
snugs 019496b252 Use hashset to prevent duplicate consolidators 2015-08-01 12:58:31 -04:00
snugs e4404e61fb Adds IBrokerageModel.ApplySplit
Default implementation modifies order prices/quantities to maintain value
Tradier implementation cancels reverse splits and performs the default on forward splits
2015-07-31 17:13:35 -04:00
snugs f4d1955da2 Delisting changes from review 2015-07-29 14:41:39 -04:00
snugs 2c1a00fa23 Implements Delisting events in the algorithm
This change adds OnData(Delisting data) event handler to the algorithm and is fired when a security gets delisted.
Likewise, when a security is delisted, data will stop being sent into the algorithm and if the algorithm has any
holdings then a MarketOnClose order is submitted at midnight on the last day of trading. If you require that the
algorithm does not sell its shares, then you must cancel the MarketOnClose order before close of trading.
2015-07-29 13:21:25 -04:00
snugs c853a4ddbd Adds some logging/error handling 2015-07-28 14:21:00 -04:00
snugs 27cd9b1fed Fixes bug in fire EOD events in live mode 2015-07-24 19:28:56 -04:00
bizcad 8b1a1c0bd7 change to use algorithm.Time in Algorithm Manager 2015-07-23 14:36:09 -07:00
QuantConnect 3869a4b73b Removed the hacked time frontier for end time liquidation 2015-07-15 15:20:34 -04:00
snugs 71acd220e5 Set exchange time to before close for liquidation 2015-07-09 18:24:18 -04:00
snugs 28d8300e46 Fixes failing tests
Beefs up the UpdateOrderRegressionAlgorithm/updates statistics
Now using TimeKeeper/LocalTimeKeeper for dissemination of time to algo classes
2015-07-09 17:19:40 -04:00
snugs bb69221e6b Fixes bug in not setting algo time before update securities 2015-07-09 16:52:19 -04:00
snugs 6bc9c5a7fb Fixes bug related to new time zone feature
RealTimeSynchronizedTimer now triggers based on UTC time
LiveTradingDataFeed used UTC time to add to bridge
Renamed Security.Time to Security.LocalTime to be explicit
Renamed SecurityExchange.Time to SecurityExchange.LocalTime to be explicit
2015-07-09 16:14:19 -04:00
snugs 704bfc2298 Adds new order ticket system
QCAlgorithm order functions now return an OrderTicket

OrderTicket can be used to directly update or cancel an order

Placing an order now submits an OrderRequest which is processed by the ITransactionHandler
2015-07-08 23:40:28 -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
snugs 87554ecf0d Implements OnData(Slice) and remove v1.0 event handlers
Also cleans up IAlgorithm interface of unused/old methods
Slice is a new type that contains all the data from a time slice to be sent into an algorithm
2015-07-03 15:15:15 -04:00
snugs b9a72e62ca Update IDataFeed to use single time slice bridge
DataFeeds now expose a single bridge (BlockingCollection<TimeSlice>)
	- IDataFeed now responsible for all time syncing, DataStream was removed
	- BlockingCollection allows for easy throttling of data feed thread without sleeps (internally using semaphore slim)
	- Slimmed down IDataFeed interface to not include members unused externally

DataFeeds now use raw IEnumerator<BaseData> instead of subscription data readers directly
	- Simplifies fill forward logic (see FillForwardEnumerator.cs and FillForwardEnumeratorTest.cs)
	- Allows for composition (raw reader -> fill forward, user/market filters)
	- SubscriptionDataReader now handles refreshing source (continuous enumeration)

LiveTradingDataFeed cleaned up to work with time slice bridge
	- RealTimeSynchronizedTimer handles pushing time slices into bridge every second, with or without data
	- Subscriptions with tick resolution get their data pushed directly into the bridge immediately

Fill forward changes
	- Implemented as an IEnumerator<BaseData>
	- Fill forward lower res on higher res (daily gets filled forward on second/minute/hour bars)
	- Second/minute/hour will not be filled forward on daily bars (at midnight) in line with current behavior

MISC:
	- Performance boost in backtesting brokerage via not checking _pending.Count, instead use local bool to determine if there's pending orders
	- Added a FakeDataQueue to aid in testing LiveTradingDataFeed
	- FileSystemDataFeed now uses CancellationTokenSource to handle thread exits
	- Added logging
2015-06-30 15:18:34 -04:00