Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BrokerageMessageHandler Python implementations #7880

Open
4 tasks done
jhonabreul opened this issue Mar 28, 2024 · 0 comments
Open
4 tasks done

BrokerageMessageHandler Python implementations #7880

jhonabreul opened this issue Mar 28, 2024 · 0 comments
Assignees

Comments

@jhonabreul
Copy link
Collaborator

jhonabreul commented Mar 28, 2024

Expected Behavior

We can use custom implementations of the DefaultBrokerageMessageHandler in Python.

Actual Behavior

If the custom brokerage message handler inherits DefaultBrokerageMessageHandler, the base methods are used instead of the derived ones.

A workaround is implementing directly IBrokerageMessageHandler but this requires setting the __namespace__ attribute in order for Pythonnet to be able to pick it up.

Potential Solution

Add and overload for the SetBrokerageMessageHandler method in AlgorithmPythonWrapper that takes a PyObject and wraps it in BrokerageMessageHandlerPythonWrapper

Reproducing the Problem

See the algorithm in https://github.com/QuantConnect/Lean/blob/8bcd491fc3cb42882db2bd5000f1aefe331f713a/Algorithm.Python/CustomBrokerageSideOrderHandlingRegressionAlgorithm.py which can be ran with the RunRegressionAlgorithm unit test in https://github.com/QuantConnect/Lean/blob/8bcd491fc3cb42882db2bd5000f1aefe331f713a/Tests/Engine/CustomBrokerageMessageHandlerTests.cs

System Information

Windows 11
QC Cloud

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants