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

Feature Request: Return an "order" variable in the generated code when using tda-order-codegen.py command-line script #249

Open
meltdown03 opened this issue Jul 25, 2021 · 1 comment

Comments

@meltdown03
Copy link

meltdown03 commented Jul 25, 2021

Currently, it prints code that just sets everything in the class OrderBuilder, not an instance of it. The code could return a variable called "order" (or something else) that can then be used to edit/place the order more easily.
Example of current code:

from tda.orders.common import (
    Destination,
    OrderStrategyType,
    ComplexOrderStrategyType,
    Session,
    Duration,
    OptionInstruction,
    OrderType
)

OrderBuilder() \ 
    .set_complex_order_strategy_type(ComplexOrderStrategyType.VERTICAL) \
    .set_duration(Duration.DAY) \
    .set_order_strategy_type(OrderStrategyType.SINGLE) \
    .set_order_type(OrderType.NET_CREDIT) \
    .copy_price(1.2) \
    .set_quantity(1.0) \
    .set_requested_destination(Destination.AUTO) \
    .set_session(Session.NORMAL) \
    .add_option_leg(OptionInstruction.SELL_TO_OPEN, "SNAP_073021C80", 1.0) \
    .add_option_leg(OptionInstruction.BUY_TO_OPEN, "SNAP_073021C85", 1.0)

suggested output:

from tda.orders.generic import OrderBuilder
from tda.orders.common import (
    Destination,
    OrderStrategyType,
    ComplexOrderStrategyType,
    Session,
    Duration,
    OptionInstruction,
    OrderType
)

order = OrderBuilder() \    ### changed to set OrderBuilder instance named "order"
    .set_complex_order_strategy_type(ComplexOrderStrategyType.VERTICAL) \
    .set_duration(Duration.DAY) \
    .set_order_strategy_type(OrderStrategyType.SINGLE) \
    .set_order_type(OrderType.NET_CREDIT) \
    .copy_price(1.2) \
    .set_quantity(1.0) \
    .set_requested_destination(Destination.AUTO) \
    .set_session(Session.NORMAL) \
    .add_option_leg(OptionInstruction.SELL_TO_OPEN, "SNAP_073021C80", 1.0) \
    .add_option_leg(OptionInstruction.BUY_TO_OPEN, "SNAP_073021C85", 1.0)
@meltdown03 meltdown03 changed the title Return an "order" variable in the generated code when using tda-order-codegen.py command-line script Feature Request: Return an "order" variable in the generated code when using tda-order-codegen.py command-line script Jul 25, 2021
@meltdown03
Copy link
Author

An alternative would be to have an optional command line argument for the name of the variable that defaults to "order" if none is entered

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