Commit Graph

72 Commits

Author SHA1 Message Date
Jared Broad e86155c117 Shuffle init to set environment path inline 2019-07-28 15:12:54 -07:00
Jared Broad 1e8fdba3d9 Revert to master 2019-07-28 14:32:04 -07:00
Jared Broad 5a2adf2065 Remove lock, additional benchmarking 2019-07-28 10:57:22 -07:00
Jared Broad 2dd94f3687 Optimize python load times 2019-07-28 10:33:37 -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
Martin Molinero 082906ed14 Test memory leak fix 2019-04-10 12:36:35 -03:00
AlexCatarino 38574ef9d5 Adds missing Py.GIL() in VolatilityModelPythonWrapper.Volatility 2019-02-14 23:13:56 +00:00
AlexCatarino 11742406b7 Adds "sort=True" argument to pandas.concat call in PandasConverter
From [pandas-docs](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.concat.html):
> The current default of sorting is deprecated and will change to not-sorting in a future version of pandas.
>
> Explicitly pass sort=True to silence the warning and sort. > Explicitly pass sort=False to silence the warning and not sort.
2019-02-07 12:59:37 +00:00
AlexCatarino ef59fa7ba2 Updates pythonnet package.
In the new package:
- C# decimal conversion will use C# double and python float due to the big performance impact of converting C# decimal to python decimal;
2019-01-18 23:18:35 +00:00
Martin Molinero 103bf638b5 Adding Pandas MultiIndex cache
- Adding a cache for the `Pandas.MultiIndex`, giving a significant
performance improvement.
- Adding new `ListComparer` class. Adding unit tests.
2019-01-11 14:00:32 -03:00
Martin Molinero 3d918bae1b PandasData will convert DateTime once
- `PandasData` will convert DateTime to python once and share it among
consumers giving a performance improvement.
2019-01-10 11:45:19 -03:00
Martin Molinero c9e6268cbd Remove OrderFeeParameters.AccountCurrency
- Removing OrderFeeParameters.AccountCurrency. Where required replacing
for constructor parameter defaulting to USD.
- Updating IB fee model to use to correct fee currency
2018-12-28 15:57:53 -03:00
Martin Molinero 0933da9303 Refactor previous commits
- Removing `AccountCurrency` from `Cash` and `Brokerage` classes.
`ICurrencyConverter` will now provide the `AccountCurrency`
- Adding new static `OrderFee.Zero` which will return a 0 order fee in
`NullCurrency`
- Adding static `Currencies.USD` value, replacing all "USD".
- Addin new static `Currencies.NullCurrency`
- Updating Bitfinex `FeeModel` so it return fees in quote currency.
Adding unit tests
2018-12-13 11:30:40 -03:00
Martin Molinero c5daf9ac9a Refactor IFeeModel
- Refactoring `IFeeModel`. *This is a breaking change* for implementations
inheriting directly from the interface. Deleting old and adding a new method
`OrderFee GetOrderFee(OrderFeeParameters parameters)` that will use a parameter
and a result object.
- Refactoring `CashAmount` so it does not embed a `ICurrencyConverter`
instance.
- Updating unit tests
- The `Security.QuoteCurrency`, a `Cash` instance, will provide access
to the `AccountCurrency` as a property.
- Will maintain backwards compatibility with old python custom
FeeModels, Adding unit test.

> Note that for now, consumers will ignore the currency, as before, and
directly consume the amount
2018-12-06 16:20:36 -03:00
Jared e17184d01e Merge pull request #2719 from Martin-Molinero/refactor-2718-rename-context-to-parameters
Renaming BuyingPower..Context to BuyingPower..Parameters
2018-12-04 11:20:31 -08:00
Jared 69e6c3726a Merge pull request #2714 from StefanoRaggi/refactor-2701-ibuyingpowermodel-context
Refactor additional IBuyingPowerModel methods to use context objects
2018-12-04 11:13:06 -08:00
Stefano Raggi bd4c799d2b Rename parameter classes from Context to Parameters 2018-11-29 22:05:49 +01:00
Martin Molinero 46baedf858 Refactor FillModels
- Modifying `IFillModel` interface removing old methods and adding new
method `Fill Fill(FillModelParameters)`. This is a breaking change.
- Adding new `PythonWrapper` property for the `FillModel` base class.
This is required due to a limitation in PythonNet:
   - Given C# class T has `virtual` methods A and B. Where method A
   calls method B. And given custom python class L inherits class T.
   And overrides method B. When class L calls
   base method A (of class T). And when method A internally calls method B.
   It will call C# implementation, not the python override. This issue
   is solved going back to the `PythonWrapper`. Adding unit tests.
- Adding new `Parameters` property for the `FillModel` base class that will
be set by the call to `Fill()`. The `Parameters` property will be used by
the modified `XxxxFill()` implementations
- Adding new `Fill` result object for the `Fill(FillModelParameters)`
method
- Adding new check before removing a `SubscriptionDataConfig` due to the FillModels consuming the configuration collection when determining which Price to use. WIll now only remove the `SDC` if the symbol was removed from the selecting `universe`, this will avoid the case where the symbol is never deselected and the subscription ends, which happens at the end of all executions.
- Adding unit tests showcasing retro compatibility.
- Enabling C# `CustomModelsAlgorithm` as a regression test. Python
version returns a different result due to random number generation.
2018-11-29 15:38:46 -03:00
Martin Molinero 7ce09f22cb Renaming Context to Parameters
- Renaming `BuyingPowerContext` to `BuyingPowerParameters` and
`ReservedBuyingPowerForPositionContext` to
`ReservedBuyingPowerForPositionParameters`
2018-11-29 15:02:09 -03:00
Stefano Raggi 78f3b4b099 Refactor additional IBuyingPowerModel methods to use context objects 2018-11-27 22:50:15 +01:00
AlexCatarino b89bc97d61 - Use ValidateImplementationOf method in RiskManagementModelPythonWrapper
- Use recently implemented `ValidateImplementationOf` extension method in `RiskManagementModelPythonWrapper`
2018-11-06 23:11:21 +00:00
Martin Molinero 239664277f Refactor Volatility Models
- Removing usages of Security.Configuration properties from existing
Volatility Models, without modifying existing interfaces. Adding unit
tests for existing behavior
- Adding new BaseVolatilityModel, which will have a setter for a
ISubscriptionDataConfigProvider which will be called by the system.
Adding unit tests for this behavior.
- Adding new `SubscriptionDataConfigExtensions` static class which will
provide methods used to determine different configuration properties for
a given set of `SubscriptionDataConfigs`. The behavior was extracted
from current `Security` class behavior regarding the `SubscriptionBag`.
Adding unit tests covering exepected behavior here.
2018-10-29 16:57:23 -03:00
Martin-Molinero 6629ba379d Merge branch 'master' into feature/2606-custom-brokerage-message-handler 2018-10-26 18:14:03 -03:00
Michael Handschuh 85942b3f14 Add BrokerageMessageHandlerPythonWrapper
This will enable python users to implement IBrokerageMessageHandler
2018-10-16 19:26:46 -04:00
Michael Handschuh 7189cb916f Add PythonWrapper.ValidateImplementationOf<T>
Provides an extension method that python wrappers can call to
validate that the provided python implementation implements all
of the required members.
2018-10-16 19:26:46 -04:00
Michael Handschuh cb726cb60a Refactor IBuyingPowerModel.GetBuyingPower
In preparation for sweeping changes that will require adding a currency converter
parameter to this method and augmenting the return value to be a CashAmount. This
ensure the future change won't produce a compile-time breaking change. An extension
method was also added as a shim to keep any existing code functional
2018-10-16 18:44:22 -04:00
Michael Handschuh df0e19ef27 Refactor IBuyingPowerModel.GetReservedBuyingPowerForPosition
In preparation for sweeping changes that will require adding a currency converter
parameter to this method and augmenting the return value to be a CashAmount. This
ensure the future change won't produce a compile-time breaking change. An extension
method was also added as a shim to keep any existing code functional
2018-10-16 18:14:17 -04:00
Stefano Raggi 5c9b81cef1 Fix Python initialization and imports for multiple tests 2018-10-02 20:28:13 +02:00
AlexCatarino 3688a0f9af Enables custom margin call model setting in python
- Adds `MarginCallModelPythonWrapper` to wrap a python class that represents a margin call model.
- Adds `SetMarginCallModel` to enable the setting of custom margin call model.
2018-09-21 14:45:30 +01:00
AlexCatarino f1a1dd0091 Enables custom buying power model setting in python
- Adds `BuyingPowerModelPythonWrapper` to wrap a python class that represents a custom buying power model.
- Adds `SetBuyingPowerModel` and `SetMarginModel` to enable the seeting of custom buying power model.
2018-08-21 12:04:49 +01:00
Martin Molinero 78742e5df6 Adding cash buffer for IB Cash Accounts 2018-08-10 17:21:50 -03:00
Martin Molinero 85e8a2bc91 Refactoring IBrokerageModel. Removing some unnecessary parameters 2018-08-06 10:21:12 -03:00
Juan José D'Ambrosio 4ace8cb255 Lean Visualizer C# toolbox project and Python Wrapper working 2018-04-27 11:49:52 -03:00
AlexCatarino 7707c166dd Refactors PandasConverter and PandasData
Since Lean/QuantConnect data from a symbol can be found in Slice.Ticks, Slice.Bars and Slice.QuoteBars, information for all of this members must be used in order present all information in the pandas.DataFrame.
2018-03-17 19:03:52 +00:00
AlexCatarino 0f57c2fd43 Fixes Custom Data for Python
In order to access the custom data classes, the module containing them was added to the ObjectActivator. This was unnecessary if it wasn't a custom data algorithm.
Also, this operation would not be taken into account if the custom data class were defined after the algorithm was created: this is the case for QuantBook.
We refactor how custom data is handled: a new class was added to provide a instance creation factory that creates an instance of each python custom type.
2018-03-01 19:28:30 +00:00
Jared 36a48a6824 Merge pull request #1554 from AlexCatarino/python-slice
Creates wrapper for Slice (python custom data)
2018-02-12 17:01:45 -05:00
Stefano Raggi 415542fcbc Set CashBuyingPowerModel as default for Crypto/GDAX 2018-02-12 17:38:12 +01:00
AlexCatarino 9dfc8ee3a0 Adds PythonSlice static constructor
With this constructor, SetConverter method, that was not respecting Lean pattern, is removed. The initialization of _converter field is done once the type is loaded.
2018-02-12 16:23:23 +00:00
AlexCatarino cff1243b86 Creates wrapper for Slice (python custom data)
Python algorithms with custom data requires an operation that converts a dictionary key into a attribute. In the current implementation the Slice object was converted into a python dictionary. This was not optimal, since we just need to make this conversion when the value of a key in the Slice is accessed.
This implementation proposes a wrapper for the Slice object, PythonSlice, that would just perform the operation described above when needed.
2018-02-12 15:49:09 +00:00
AlexCatarino dd14821e75 Enables custom volatility models in python algorithms
Creates a python wrapper for volatility models created in python algorithms and adds a method to the Security object to set such models.
Adds an algorithm to show how volatility models can be implemented.
2018-01-31 12:17:24 +00:00
Stefano Raggi c6693cb237 Disable automatic security seeding
In this PR we are disabling the default security seeding (automatically getting the last price for a security when added to the algorithm) for a couple reasons, both when using large universes:
- In live trading, these history requests are sent to a history server, potentially causing timeouts
- In backtesting, depending on the algorithm this could also cause slowdowns up to 30%
2017-12-22 21:49:14 +01:00
AlexCatarino 720c1f86d7 Minor improvements
- Rename variable `_type` for `_customDataType` for clarity
- `_baseDataProperties` as static member
2017-12-04 21:42:02 +00:00
AlexCatarino 3a6b18a470 Fixes PandasData support to C# custom data
Previous implementation didn't account for different subclasses that a custom ata class could inherit from.
2017-12-04 21:38:39 +00:00
AlexCatarino de2e877ce5 Fixes decimal to double convertion in PandasData 2017-12-04 21:38:39 +00:00
AlexCatarino 03eb342c8b Implements C# custom data support to PandasData
The previous custom data implementation did not account to custom data created in C# like FxcmVolume or DailyFx
2017-12-04 21:38:39 +00:00
AlexCatarino 52bded5a6a Minor changes
- We were excluding Exchange and Suspicious of quote ticks when they can be set with security types other than equity
- Custom data was not expecting non-numerical properties
2017-11-17 16:18:57 +00:00
AlexCatarino 812906b0c3 Refactors PandasConverter
- Moves PandasData class to its own file
- Refactors PandasData class to deal with list of tick
- Other minor changes requested by peer-review
- Adds unit test for PandasConverter's tick handling
2017-11-17 16:09:44 +00:00
AlexCatarino 9023892838 Implements Tick data support in PandasConverter 2017-11-17 16:09:44 +00:00
AlexCatarino 2ff636869c Fixes summary of members in python wrapper classes
Summary of members in python wrapper classes where pointing to other methods for reference when they should have a meaningful description to be used in documentation
2017-11-16 14:00:22 +00:00
AlexCatarino 209922e147 Minor fixes and improvements 2017-10-31 00:16:15 +00:00