Created
November 16, 2023 16:40
-
-
Save pannet1/53773f6e4e67f74311024e1e25f92a10 to your computer and use it in GitHub Desktop.
check orders status of norenapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def order_status(self, **dat): | |
try: | |
status_codes = ['COMPLETE', 'REJECTED', | |
'CANCELED', 'TRIGGER_PENDING'] | |
dat['fn'] = self.order_status | |
orders = pd.DataFrame(self.obj.get_order_book()) | |
dct_order = orders[orders.norenordno == dat['norenordno']] | |
entry_order_status = dct_order['status'].values[0] | |
if dat['txt'] != "ORDER STATUS: ": | |
dat['txt'] = "ORDER STATUS: " | |
logging.info( | |
f"{dat['txt']}{dat['Signal']} {entry_order_status} " | |
f"#{dat['norenordno']} @ {dat['order_price']} " | |
f"{dat['Stock']}@ {dat['ltp']}") | |
if entry_order_status == "COMPLETE": | |
filled = int(dct_order['fillshares'].sum()) | |
total_quantity = int(dat['total_quantity']) | |
if filled == total_quantity: | |
logging.info( | |
f"{dat['txt']}{dat['Stock']} fully {filled =}/{total_quantity =}") | |
dat['fn'] = self.gtt_oco_1 | |
else: | |
if Utils.is_within_range( | |
dat['ltp'], | |
dat['entry_price'], | |
dat['trigger_price'] | |
): | |
logging.info( | |
f"{dat['txt']}{dat['Stock']} monitoring partially {filled =}/{total_quantity =}?") | |
else: | |
logging.info( | |
f"{dat['txt']}{dat['Stock']} canceling remaining " | |
f" {(total_quantity-filled)}q for #{dat['norenordno']}") | |
dat['total_quantity'] = filled | |
dat = self.recalc_qty(**dat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment