Commit Graph

285 Commits

Author SHA1 Message Date
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
snugs 7e2f362986 Stop timing algo manager loops at end of algorithm 2015-06-22 12:14:30 -04:00
snugs 0ef2be5bf8 Respect time from algo manager in live real time handler 2015-06-20 13:58:50 -04:00
snugs 4de2ec4070 Make Engine an instance
Updated all interfaces to accept dependencies via Initialize methods
2015-06-18 13:50:11 -04:00
snugs e07c4d02e2 Make DataStream an instance 2015-06-18 10:56:55 -04:00
snugs 0b169b6baf Make AlgorithmManager an instance 2015-06-18 10:44:51 -04:00
snugs e05e4fd08e Load data feed handlers via MEF configuration 2015-06-17 22:34:05 -04:00
QuantConnect 6b035d323c Converted Isolator to be an instance based class 2015-06-14 12:31:26 -04:00
QuantConnect fde0cbed3a Strip out block quote section header comments 2015-06-13 16:04:27 -04:00
snugs cf160b49de Some fixes from SubscriptionDataSource review 2015-06-11 22:27:42 -04:00
snugs 44a38f3e1d Updates LiveTradeDataFeed to allow custom data with remote files 2015-06-11 17:34:54 -04:00
Stefano Raggi 3fdf5f509b Processing speed improvement 2015-06-10 12:01:29 +02:00
snugs 887faa24e7 Adds support for hourly/daily data to LEAN engine 2015-06-02 21:44:44 -04:00
snugs 51f9b1dd6d Fixes bug in DataStream with ticks 2015-06-01 13:56:56 -04:00
snugs 6165c354e7 Initial implementation of TradierBrokerage
Adds new base test class for brokerages: BrokerageTests
2015-05-20 16:37:33 -04:00
snugs 89b6e98af8 Fixes warnings mostly relating to xml comments
Also cleans up some block comments

Via PR#72 - thanks @ammachado!
2015-05-13 10:56:47 -04:00
snugs e1827fae31 Implements OnMarginCall and OnMarginCallWarning events
Also fixes bug in ConsoleResultHandler to process log/debug/error messages synchronously
2015-05-12 18:16:25 -04:00
snugs 790ce35c55 Adds 10 minute default time limit to each algo mgr loop
Overrideable with 'algorithm-manager-time-loop-maximum' configuration value in minutes
2015-05-12 18:16:23 -04:00
QuantConnect 2fc6725780 Fix algorithm status to only decrease algo state, not set it to running when algos are in an error state 2015-05-04 21:44:08 -04:00
snugs 95aaa58c9d Adds check in AlgoMgr for runtime errors 2015-05-04 15:06:48 -04:00
snugs 49b398f8ff DataStream sync by end of bar
Adds EndTime to BaseData
Adds Period to TradeBar
Now filling data forward on days missing files/data
Some performance enhancements
Removed sorted dictonary in DataStream/AlgorithmManager

We round down fill forward data in the data stream since if we were to perform this in the data feed we would continually produce data at the same time and it would all go into the algorithm at once.
2015-05-01 19:23:57 -04:00
snugs a136d1331e Fixes bug in backwards compatibility mode 2015-04-30 23:38:44 -04:00