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

PositionsStore is not able to reconstruct, because the custom _init does not have the correct input parameters. #52

Open
ffahimi opened this issue Nov 4, 2024 · 0 comments
Assignees

Comments

@ffahimi
Copy link
Collaborator

ffahimi commented Nov 4, 2024

Proposal: change _init to _post_init to solve the issue and let the dataclass initialize with all possible attributes.

Error example is here:

Python.Runtime.PythonException: Position.init() got an unexpected keyword argument 'orderId'
File "/QuantConnect/live/./cache/algorithm/project/Tools/PositionsStore.py", line 135, in reconstruct_position
position = Position(**filtered_data)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/QuantConnect/live/./cache/algorithm/project/Tools/PositionsStore.py", line 149, in
return {int(k): self.reconstruct_position(v) for k, v in data.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/QuantConnect/live/./cache/algorithm/project/Tools/PositionsStore.py", line 149, in decode
return {int(k): self.reconstruct_position(v) for k, v in data.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/QuantConnect/live/./cache/algorithm/project/Tools/PositionsStore.py", line 204, in load_positions
unpacked_positions = decoder.decode(json_data)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/QuantConnect/live/./cache/algorithm/project/main.py", line 80, in Initialize
self.positions_store.load_positions()
at Python.Runtime.PythonException.ThrowLastAsClrException() in C:\Users\jhona\QuantConnect\PythonnetEnterprise\src\runtime\PythonException.cs:line 52
at Python.Runtime.PyObject.Invoke(PyObject[] args) in C:\Users\jhona\QuantConnect\PythonnetEnterprise\src\runtime\PythonTypes\PyObject.cs:line 787
at QuantConnect.Python.PythonWrapper.InvokeMethodImpl(PyObject method, Object[] args) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Common/Python/PythonWrapper.cs:line 133
at QuantConnect.Python.PythonWrapper.Invoke(PyObject method, Object[] args) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Common/Python/PythonWrapper.cs:line 120
at QuantConnect.Python.BasePythonWrapper1.InvokeMethod(String methodName, Object[] args) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Common/Python/BasePythonWrapper.cs:line 166
at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Initialize() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/AlgorithmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs:line 711
at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.<>c__DisplayClass28_0.b__1() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Engine/Setup/BrokerageSetupHandler.cs:line 273Position.init() got an unexpected keyword argument 'orderId'
at reconstruct_position
position = Position(**filtered_data)
^^^^^^^^^^^^^^^^^^^^^^^^^
in PositionsStore.py: line 134
at
return {int(k): self.reconstruct_position(v) for k, v in data.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
in PositionsStore.py: line 148
at decode
return {int(k): self.reconstruct_position(v) for k, v in data.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
in PositionsStore.py: line 148
at load_positions
unpacked_positions = decoder.decode(json_data)
^^^^^^^^^^^^^^^^^^^^^^^^^
in PositionsStore.py: line 203
at Initialize
self.positions_store.load_positions()
in main.py: line 79
Position.init() got an unexpected keyword argument 'orderId'

@ffahimi ffahimi self-assigned this Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant