Commit Graph

41 Commits

Author SHA1 Message Date
Adalyat Nazirov 1e3a1e3c43 Historical data requests start & time fix (#4733)
* regression tests

* fix: apply the same time convertion to history request time as for data time

* ver2

* fixup

* unit tests

* do not need this conversion because RoundDownInTimeZone returns in proper TZ

* comment

* requested changes

* refactoring

* more refactoring

* fix existing test: should return Sunday if open

* more symbols

* fix existing tests: submit new btcusd data

* fix

* add Cfd symbol
2020-09-24 14:51:35 -03:00
Stefano Raggi 375f192f07 Add PolygonDataQueueHandler (#4604)
* Add PolygonDataQueueHandler

* Add history provider and downloader for Polygon

* Add aggregator to PolygonDataQueueHandler

* Address review

- Removed duplication in message classes
- Added public Subscribe/Unsubscribe methods in PolygonWebSocketClientWrapper
- Added history requests for Forex and Crypto

* Address review

- Add security type and market arguments to downloader
- Fix time zone bug in downloader

* Remove unnecessary locks

* Add Polygon history for all resolutions

- Equity: trades and quotes
- Forex: quotes only
- Crypto: trades only
2020-08-27 12:09:20 -03:00
Adalyat Nazirov ea9007601d fix date parsing: TwelveCharacter dateformat can't be parsed properly;
more String Extensions: extract substring safely
add more US formats
2020-07-31 17:53:55 +03: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 a79cc16b03 Add Kelly Criterion values
- New `KellyCriterionManager` will be used by the
`StatisticsInsightManagerExtension` to calculate and update the
`AlphaRuntimeStatistics` with the new Kelly Criterion values, on a daily
basis.
2019-07-26 19:16:36 -03: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
Martin Molinero 5b04cfe202 Emiting Insights based on Fills
- Classic Algorithms will emight insights based on order fills.
   - To be able to update generated insights closed time, we will not
   clone emitted insights.
   - `InsightAnalysisContext` will update `AnalysisEndTimeUtc` when the
   Insight period is closed and the period is `EndOfTimeTimeSpan`
- Adding new regression algorithm asserting on the new emitted insights
- Adding unit tests
- `LiveTradingResultHandler` will store `AlphaRunTimeStatistics`
- Making `DefaultAlphaHandler.ProcessAsynchronousEvents` virtual to
facilitate cloud changes
2019-03-26 16:09:22 -03:00
Martin Molinero 7d7ad17883 Obsoleting Securities configurations properties
> This PR is a mechanical refactor, no behaviour changed

- Obsoleting `IsFillDataForward`, `Resolution`, `IsExtendedMarketHours`
`Security` configuration properties. Replacing there usages by
requesting the `SubscriptionDataConfigs` to the new
`SubscriptionDataConfigService`
2018-12-05 10:05:53 -03:00
Michael Handschuh c7e1ee4999 Revert "Logging for travis"
This reverts commit de9c417227.

This code was added to aide in debugging a travis failure and was never
intended to be merged into master.
2018-08-07 17:24:26 -04:00
Michael Handschuh de9c417227 Logging for travis
These tests pass locally but are failing on travis and I'm gonna find out why!
2018-08-07 15:59:27 -04:00
Michael Handschuh 4fd16f6daf Fix resolution of insight close times, allow user defined close times
Fixes a bug where we were using the security's data resolution to compute
the insight's close time. This led a case such as insight.Period == 20days
to step 20days worth of tradable minutes (assuming minute data resolution),
yielding a close time that was very far in the future.

We also add different means of specifying an insight's period/close time:
1. Specify insight period as a TimeSpan and we compute close time
2. Specify insight period and a resolution and bar count and we compute close time
3. Specify insight close time local directly and we compute the insight period

The key here is maintaining consistency between the three different approaches
which is heavily validated with the corresponding unit tests.

Edits also made to trust the insight's close time as the analysis end time in
the case where the analysis period == insight period (extra analysis period = 0).
Given the current setup (extra analysis period == 0), this guarantees that close
and analysis end times are equivalent.

Regression statistics were updated and expectedly we get many more insights that
have completed analysis, and as such, average scores have also changed.
2018-08-07 11:21:11 -04:00
Michael Handschuh d52ea82573 Adds TimeSpan.Multiply extension method
The alternative is fairly verbose and often obfuscates the intent.
2018-04-03 12:31:01 -04:00
Michael Handschuh 2450f40d37 Improve date time from unix stamp precision
AddSeconds and AddMilliseconds methods are only accurate to the millisecond.
This fix uses the AddTicks methods to get the highest possible precision
2018-03-10 16:38:12 -05:00
Michael Handschuh b07928bd58 Properly account for market hours in alpha prediction periods
If we make a prediction for 1 day in the future, we actually mean 1 trading day.
This change updates the alpha analysis logic to take into account the security's
market hours.
2017-12-28 11:27:41 -05:00
Michael Handschuh 13b6d6eae3 Initial implementation of signal analysis
This commit provides the required infrastructure for analyzing algorithm generated
signals. The analysis of signals is mainly performed via ISignalScoreFunction which
computes scores for a signal. The SignalAnalysisContext provides contextual information
regarding the analysis of a particular signal object and also allows for the storing
of arbitrary state by consumers -- scoring functions can benefit greatly from having
this state tracked (consider any iterative function, or maybe just some heavy calcs to
be persisted between function invocations).
2017-12-12 14:01:44 -05:00
Andrew 076bb1627c Added KaikoDataConverter Toolbox project
This project can take trade as well as orderbook information from Kaiko
and convert the data into Lean compatible data at all resolutions in
modeled as both trades and quotes.
2017-10-27 15:50:47 -04:00
Michael Handschuh ea01252cf2 Add LiveCustomDataSubscriptionEnumeratorFactory
Defines an enumerator factory for live custom data. This is a refactoring
and bugfix over the previous implementation. This implementation now checks
the transport medium of each refresh of the stack to see if it's a file or
a rest server and provides the appropriate fast forward/rate limiting behavior.
2017-10-17 12:15:58 -04:00
Michael Handschuh 20ea2d20b4 Add comments to Time.EachTradeableDayInTimeZone 2016-02-12 16:44:08 -05:00
Michael Handschuh 5e491744b2 Adds Time.EachTradeableDayInTimeZone 2016-02-12 13:42:55 -05:00
Stefano Raggi 1e7d8f47ee Fixed XML comments compiler warnings 2015-12-06 16:26:48 +01:00
snugs be950e756a Log full errors/stack traces
Many places in the code used Log.Error(err.Message) or equivalent which
strips out all the really useful information, such as the stack trace
and inner exceptions. Using Log.Error(exception) is the correct way to
log an error as it will correctly write all the message details, also,
by passing the full Exception object we can improve the logging in this
one place and all call sites will automatically benefit from the improvements
2015-12-02 12:35:33 -05:00
snugs eca15f8274 Merge branch 'master' into sid 2015-11-23 13:05:51 -05:00
Stefano Raggi 48147a46ff Made EpochTime readonly 2015-11-20 11:14:14 -05:00
Stefano Raggi b76fb035ef UnixTimeStampToDateTime performance bugfix 2015-11-20 11:14:13 -05:00
snugs 4228167af8 Set Time.BeginningOfTime to OADate(0) 2015-11-12 13:55:41 -05:00
snugs 678cd38fc5 Add Time.MaxTimeSpan to mirror Time.EndOfTime for time spans 2015-10-21 13:05:13 -04:00
snugs 6f15f4139b Move all subscriptions into a universe 2015-10-21 13:05:11 -04:00
snugs 65f75708bb Initial implementation of IHistoryProvider 2015-09-15 15:40:09 -04:00
snugs f1ed668582 Reduce dependency in tradeable data function parameters 2015-09-15 15:40:05 -04:00
snugs e1938baafe Clean up using directives 2015-09-01 22:17:35 -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 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 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 d76af14645 Improve TradeableDates performance 2015-06-23 15:36:13 -04:00
QuantConnect fde0cbed3a Strip out block quote section header comments 2015-06-13 16:04:27 -04:00
snugs 759273565b misc fixes 2015-06-08 10:51:06 -04:00
snugs 887faa24e7 Adds support for hourly/daily data to LEAN engine 2015-06-02 21:44:44 -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 6aff4fa1b4 Use TryParseExact instead of try/catches in Time.cs 2015-03-04 19:40:08 -05:00
Michael Ourednik 0f483b0056 Added en-US date format to Time helper class 2015-02-01 10:49:42 +13:00
Jared Broad b3de520915 Initial commit 2015-01-12 12:03:33 -03:00