Skip to content

Commit

Permalink
#66 bug fixed: if not "oK" status received then TP/SL orders also not…
Browse files Browse the repository at this point in the history
… opens now
  • Loading branch information
Tim55667757 committed Nov 13, 2022
1 parent 1ebad8f commit 831b5ed
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tksbrokerapi/TKSBrokerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -2960,14 +2960,14 @@ def Trade(self, operation: str, lots: int = 1, tp: float = 0., sl: float = 0., e
NanoToFloat(response["executedOrderPrice"]["units"], response["executedOrderPrice"]["nano"]), response["executedOrderPrice"]["currency"],
))

else:
uLogger.warning("Not `oK` status received! Market order not executed. See full debug log or try again and open order later.")
if tp > 0:
self.Order(operation="Sell" if operation == "Buy" else "Buy", orderType="Stop", lots=lots, targetPrice=tp, limitPrice=tp, stopType="TP", expDate=expDate)

if tp > 0:
self.Order(operation="Sell" if operation == "Buy" else "Buy", orderType="Stop", lots=lots, targetPrice=tp, limitPrice=tp, stopType="TP", expDate=expDate)
if sl > 0:
self.Order(operation="Sell" if operation == "Buy" else "Buy", orderType="Stop", lots=lots, targetPrice=sl, limitPrice=sl, stopType="SL", expDate=expDate)

if sl > 0:
self.Order(operation="Sell" if operation == "Buy" else "Buy", orderType="Stop", lots=lots, targetPrice=sl, limitPrice=sl, stopType="SL", expDate=expDate)
else:
uLogger.warning("Not `oK` status received! Market order not executed. See full debug log or try again and open order later.")

return response

Expand Down Expand Up @@ -4506,7 +4506,7 @@ def Main(**kwargs):

exitCode = 0
start = datetime.now(tzutc())
uLogger.debug("=-" * 60)
uLogger.debug("=-" * 50)
uLogger.debug(">>> TKSBrokerAPI module started at: [{}] UTC, it is [{}] local time".format(
start.strftime(TKS_PRINT_DATE_TIME_FORMAT),
start.astimezone(tzlocal()).strftime(TKS_PRINT_DATE_TIME_FORMAT),
Expand Down Expand Up @@ -4887,7 +4887,7 @@ def Main(**kwargs):
finish.strftime(TKS_PRINT_DATE_TIME_FORMAT),
finish.astimezone(tzlocal()).strftime(TKS_PRINT_DATE_TIME_FORMAT),
))
uLogger.debug("=-" * 60)
uLogger.debug("=-" * 50)

if not kwargs:
sys.exit(exitCode)
Expand Down

0 comments on commit 831b5ed

Please sign in to comment.