Commit Graph

96 Commits

Author SHA1 Message Date
Colton Sellers b8674731a5 Feature 2456 custom Python consolidator support (#4637)
* DataConsolidator Wrapper for Python Consolidators

* Regression Unit Test

* Refactor Regression test

* Bad test fix

* pre review

* self review

* Add RegisterIndicator for Python Consolidator

* Python base class for consolidators

* Modify regression algo to register indicator

* unit test - attach event

* Test fix

* Fix test python imports

* Add license header file and null check

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2020-08-25 17:26:55 -03:00
Martin Molinero 39e56ea7c0 Address reviews
- Removing the need to call MHDB.SetEntry, this will be handled by the
  data manager
2020-06-15 20:05:12 -03:00
Martin Molinero b575880739 Coarse tiingo new universe selection algorithm
- Adding an example algorithm of a custom universe selection using
  coarse data and adding tiingo news. If conditions are met will add the
  underlying and trade it
- Adding required UniversePythonWrapper
2020-06-15 20:05:08 -03:00
Martin Molinero 170d12859f Address reviews
- Reduce code duplication. Handle some missing History<TradeBar> for Tick
  resolution.
2020-06-09 19:49:36 -03:00
Martin Molinero b3970bdc3b Fixes and rebase
- FineFundamentalSubscriptionEnumeratorFactory will not emit empty fine
  points
2020-04-24 17:21:28 -03:00
Martin Molinero 89a73a5671 Fix and regression tests
- Fix FineFundamentalFilteredUniverse for a custom universe
- Adding regression test
2020-04-24 17:21:28 -03:00
Huai Chun Shih fa79fc8a41 Let Python can AddUniverse(universe, fineFunc) 2020-04-24 17:21:28 -03:00
Martin Molinero 085da7c352 Fixes for RegisterIndicator
- Fixes for C# RegisterIndicator API methods which were ignoring provided
type of T
- Fixes for Py RegisterIndicator API methods which was not using the
provided 'selector' method
- Adding C# and Py regression algorithm
2020-03-24 16:38:46 -03:00
Martin Molinero 8f50691927 Update documentation 2020-02-14 19:59:22 -03:00
Martin Molinero 68ad2f51b6 Address reviews
- Replacing `BaseData.AdjustResolution` for `DefaultResolution` and
`SupportedResolutions`
- Making `Resolution` nullable for `Algorithm.AddData` methods
- The `ISubscriptionDataConfigService` will set the default resolution
if none was provided and assert it is supported
- Fix bug with `PythonData` `IsSparseData` and `RequiresMapping`
resolution
2019-11-04 20:42:30 -03:00
AlexCatarino c37b450a2e Adds Python Support
- Adds PyObject overload to `ScheduleManager.TrainingNow` and `ScheduleManager.Training`
- Adds `QCAlgorithm.Train` helper method
- Adds Python algorithm showing how to use the helper method.
2019-10-19 14:52:34 -04:00
Martin Molinero 3e3bfd83d5 Try to convert to managed type
- Will try to convert IBrokerage from PyObject to managed type
- Adding unit tests
2019-10-15 17:34:36 -03:00
Martin Molinero a349f619a0 Add Slice.Get(Type) for python
- Adding `Slice.Get(Type)` and `Slice.Get(Type, Symbol)` for python use case
- Adding unit tests
2019-10-02 18:19:44 -03:00
Martin Molinero af6cc80b48 Adding BaseData.DataTimeZone()
- Adding `BaseData.DataTimeZone()` with the objective of allowing custom
data types to determine their data time zone.
2019-09-30 23:59:36 -03:00
Michael Handschuh f7034aa9d7 Add SubscriptionDataConfig GetBaseDataInstance extension method
Updates usages of GetBaseDataInstance that have a config in scope to use this
new method. This method properly assigns the symbol to the newly created base
data instance. This enables some of the new flag methods to work as expected.
Updated other poor usages where we weren't setting the symbol property.

See #3618
2019-09-27 14:27:08 -04:00
Martin Molinero 851d02c527 Update PythonNet version - Revert work around 2019-09-24 11:18:46 -03:00
Gerardo Salazar 56462f0283 Address reviews from Mike and Martin
* Added better documentation for AddData methods
* Added new regression algorithms for adding in OnSecuritiesChanged
* Changed regression algorithms to add data that exists
* Styling and logging fixes
2019-09-24 10:34:35 -03:00
Gerardo Salazar 9265bfe065 Implement C# AddData Symbol method equivalents
* Implement method precedence hack on two additional python methods
* Changed behavior of SymbolCache loading with a ticker
	- Previously, we would search the cache with ticker for types that did not
	require mapping.
* Added new documentation
* Code cleanup
* Change first date to be SID.DefaultDate if SecurityType isn't expected
* Modified AddData tests to meet expectations. AddData unit tests are passing
2019-09-24 10:34:35 -03:00
Gerardo Salazar 9d052afcf3 Work in progress commit
* Added new method for Symbol to allow creation with underlying
* Added new unit tests
* Alter SecurityIdentifier method signature for BaseData
* AddData changes to accept underlying Symbol
* Added AddDataImpl
2019-09-24 10:34:35 -03:00
Martin Molinero 50d9188c16 Fix rebase 2019-09-24 10:34:35 -03:00
Michael Handschuh 6362d101c1 Append type to custom data symbol
This is being done in an effort to prevent symbol collisions within the
custom data (SecurityType.Base) namespace. The custom data type's name,
is used for disambiguation. As written, this change will break several
user algorithms that still rely on using the implicit string -> Symbol
lift. Providing this type information is optional an currently only being
used by AddData<T> methods. Other consumers of SecurityType.Base symbols
arn't at risk for collision, such as the UserDefinedUniverse, ScheduledUniverse
and others that are LEAN controlled. In order to maintain backwards compatibility,
the SymbolCache was updated to do a hard search when the requested ticker was
not found, looking for the prefix ('ticker.').

Fixes #3332
2019-09-24 10:34:35 -03:00
Michael Handschuh e65f718577 Enforce consistency in AddData<T> C#/Python
See #3332 - initial pre-factoring/clean-up
2019-09-24 10:34:34 -03:00
Michael Handschuh d8db9f9fce Update Algorithm 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 15:30:44 -04:00
AlexCatarino 45c81371a3 Implements ConvertToSymbolEnumerable Extension Method
Following the convert python objects patter, it replaces `QCAlgorithm.GetSymbolsFromPyObject`.
Add unit tests.
2019-09-05 23:55:30 -03:00
Martin Molinero 24527e0cc2 Address reviews - Renaming 2019-08-21 16:30:03 -03:00
Martin Molinero 73d780daae Moving UsesMapFiles to DataType
- Custom data types will know whether or not Lean should use map files
- Updating regression test with sample custom data using map files,
which can run locally
- Adding unit tests for the `SubscriptionDataReaderHistoryProvider`,
checking it mappes equities and options correctly
2019-08-20 17:33:41 -03:00
Gerardo Salazar e6a510d803 Add Mapfile support for custom data sources 2019-08-20 16:56:02 -03:00
Martin Molinero 1983f36792 Allow Python selection to return unchanged
- We will now check if python selection method returned `Universe.Unchanged`
- Removing `ToList()` call on fine and coarse data before sending it to
the python algorithm
- Adding regression algorithms
2019-07-31 15:36:07 -03:00
AlexCatarino 0b0a1b31ff Refactors PythonIndicator
In order to provide full Lean Indicator functionality to python custom indicators, they need to inherit from a C# class. `PythonIndicator` will serve for this purpose.
Algorithms can use the former version (no inheritance).
2019-07-26 00:35:57 +01:00
AlexCatarino 84d548b5f2 Adds Custom Python Indicator Support for QCAlgorithm.PlotIndicator
In order to add support custom python indicators for `QCAlgorithm.PlotIndicator`, we created a `PythonIndicator` class that wraps the custom python indicator. In `QCAlgorithm`, the reference of the wrapper is saved into a dictionary keyed by the python indicator handle.
2019-07-23 22:02:33 +01:00
Jared 4f47df2ce8 Merge pull request #3022 from AlexCatarino/feature-3007-calendar-consolidators
Implements Calendar (Weekly/Monthly) Consolidator
2019-04-10 14:35:13 -07:00
Martin Molinero fa122fa809 Add missing PyObject.Dispose calls
- Adding _some_ of the missing PyObject.Dispose calls. In the cases
where C# is calling the Python side.
   - Note that Python calls to C# code is correctly handling the
   disposure of resources.
2019-04-10 15:03:10 -03:00
AlexCatarino 0202df35f4 Replaces Enum CalendarType for Static Class with the Same Name
Replaces Enum `CalendarType` for static class with the same name. This class defines two properties (`Weekly` and `Monthly`) that can be used to define the previous calendar date (Monday or 1st of current month) which will correspont to the `Time` of a `IBaseData` object.

Refactor `PeriodCountConsolidatorBase` to define use `GetRoundedBarTime` based on a period specification that depends on the constructor overload: `integer`, `TimeSpan` or `Func<DateTime, CalendarInfo>`. The last one can be set with the `CalendarType` properties.
2019-04-08 22:10:04 +01:00
AlexCatarino 5314e7426d Implements Calendar (Weekly/Monthly) Consolidator
Implements consolidators that group bars by a calendar unit (week or month).
2019-04-08 22:10:04 +01:00
Jared ee2d7ef36c Merge pull request #2768 from Martin-Molinero/refactor-2767-add-new-history-request-factory-class
Adding new HistoryRequestFactory
2018-12-21 08:56:23 -08:00
AlexCatarino b5918f3bf2 Fixes Plot(string, PyObject) handling of indicators. 2018-12-21 14:46:59 +00:00
Martin Molinero 541b4e3a00 Adding new HistoryRequestFactory
- Adding new `HistoryRequestFactory` class. Will provide some methods to
facilitate the creation of new `HistoryRequests`. Moving
`CreateHistoryRequest` and `GetStartTimeAlgoTz` into the new
`HistoryRequestFactory`. And consolidating `GetStartTimeAlgoTz` and
`GetStartTimeAlgoTzForSecurity`.
2018-12-19 16:14:42 -03:00
AlexCatarino 70e2ef9480 Changes the custom data type base class
By using the python object parant class, which is either `PythonQuandl` or `PythonData`, instead of `DynamicData`, the `AlgorithmManager.Stream` method can find a matching subcription data configuration used to create a data feed packet.

Closes #2694
2018-11-13 19:29:34 +00:00
Martin Molinero a288648929 Creating new ISecurityService
- Adding new ISecurityService and its implementation SecurityService.
Expose by SecurityManager.
This class will expose a method for creating new securities. The
SecurityManager is exposing this new interface, calling _securityService
internally, so Future/OptionUniverseSelectionModel.cs can use it
- Replacing all usages of SecurityManager.CreateSecurity for new
ISecurityService
- Modifying `Cash.cs` and `CashBook.cs` `EnsureCurrencyDataFeeds()` to
return newly added `SubscriptionDataConfig` instead of `Security`. This
will avoid using `Security.Subscriptions` at call site.
- Moving old SecurityManager.CreateSecurity into new
SecurityServiceTests.cs
2018-10-18 16:25:32 -03:00
Martin Molinero 2967776130 Refactor AddToUserDefinedUniverse
AddToUserDefinedUniverse will receive configuration settings as parameters.
2018-10-02 09:59:33 -03:00
Michael Handschuh fdc866fda0 Reverting 'Merge pull request #2483 python-history-provider'
We didn't experience the expected performance improvements. Locally under
unit test there was aboout an order of magnitude throughput increase, but
when run against the history benchmark, this new approach was 60% slower.
We're reverting this for now to perform further analysis and better
understand the performance profiling of the python history stack.
2018-09-18 18:37:23 -04:00
AlexCatarino 5456f53545 Fix exception message: remove unrequired \ 2018-09-17 19:05:49 +01:00
AlexCatarino 8ac671d7ab Minor improvements
- Do not throw, but log, when a entry in the zip file does not exist. It can happen in trade bar data for options/futures since a given contract may only exist as quote bar.
- Verify whether the minimum requires arguments ("periods", "span" and "start") are present in the dictionary used to pass the variables.
- Adds doctring to History.
- Fixes type check for custom data.
2018-09-17 19:05:49 +01:00
AlexCatarino 3bc4d661c8 Implements Futures and Options support
Since futures and options have multiple entries in the zip file, we need to include the entry name in the request.
Futures have multiple open market periods during on trading day, therefore we need to apply a more complex mask to pandas dataframe index.
2018-09-17 19:05:49 +01:00
AlexCatarino aa078ec7d1 Implements Tick resolution support
- Removes HistoryRequest inheritance in PandasHistoryRequest
2018-09-17 19:05:49 +01:00
AlexCatarino 602644c65d Fix the implementation to support adjusted prices and non-regular market hours handling
- Adds unit tests.
2018-09-17 19:05:48 +01:00
AlexCatarino 3e4a71cd50 Creates QCAlgorithm.py: a bridge between C# QCAlgorithm and python algorithms 2018-09-17 19:05:48 +01:00
AlexCatarino c3023825e0 Fixes custom data type mismatch in python algorithms
If the custom data type is a C# type, it should be used instead of wrapping it around a `PythonActivator` object.
2018-07-23 13:30:02 +01:00
AlexCatarino e40a318f88 Fixes "object isn't callable" bug in Universe Selection
Reverse the order that a `PyObject` is attempt to be converted into a `Universe` object and a `Func`.
2018-07-03 17:19:03 +01:00
AlexCatarino 4853e50dd2 Fixes ambigous call bug for Download method
Adds more overloads and remove the optional arguments.
2018-06-28 19:00:31 +01:00