Hi guys, i am new to python. i am coding a buy/sell order instruction for interactive brokers api. Is there a way to simplify the code here?
es_nos = 0 spy_nos = 0 nq_nos = 1 qqq_nos = 2 rty_nos = 3 iwm_nos = 4 zb_nos = 5 tlt_nos = 6 es_buy_sell = 'buy' if es_nos > 0 else 'sell' spy_buy_sell = 'buy' if spy_nos > 0 else 'sell' nq_buy_sell = 'buy' if nq_nos > 0 else 'sell' qqq_buy_sell = 'buy' if qqq_nos > 0 else 'sell' rty_buy_sell = 'buy' if rty_nos > 0 else 'sell' iwm_buy_sell = 'buy' if iwm_nos > 0 else 'sell' zb_buy_sell = 'buy' if zb_nos > 0 else 'sell' tlt_buy_sell = 'buy' if tlt_nos > 0 else 'sell'
Larz60+ write Aug-05-2022, 10:27 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time please use bbcode tags on future posts.