Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The implementations of submit_order and submit_orders methods have been refactored with uniformity between brokers and ease of use as a priority.
In broker/tradier.py, broker/interactive_brokers_rest.py, etc. files, we have 2 functions: _submit_order and _submit_orders, handling single and multiple orders respectively.
In broker.py, these methods get wrapped by the submit_order and submit_orders methods. (No changes from before)
In strategy.py, these methods get combined into one submit_order method, which can handle both single and multiple orders. This was done as part of an effort to streamline the strategy class and make it more newcomer-friendly.
As per a user suggestion, when submitting multiple options orders at once, is_multileg is now automatically set to True
The submit_orders method in the strategy class remains for now, but is marked as deprecated in the docstring and internally relies on the new submit_order method. Might mark it as not deprecated later.
A lot of backend logic has been moved from strategy.py to _strategy.py. strategy.py should contain mainly stuff that the users/strategy builders should interract with.
Added the run_live() and backtest() methods to strategy.py as to make running and backtesting strategies simpler to newcomers.
Note: Everything is 100% backwards compatible
Also includes some general improvements for Interactive Brokers REST.
Description by Korbit AI
What change is being made?
Refactor order submission methods by encapsulating order processing logic, deprecating
submit_orders
method in favor of enhancingsubmit_order
to handle both single and multiple orders, and extracting order validation into a separate function.Why are these changes being made?
To improve code maintainability and clarity by consolidating order submission logic in a central method, making it easier to extend and manage, while also ensuring that orders are validated before submission, thus reducing potential errors during order processing. Additionally, streamlining the order-related methods paves the way for more flexible broker implementations and code reuse across different components.