Created
June 21, 2022 15:18
-
-
Save ganigithub/034aa5bde75fb59e462ced7dd609dae1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
########################## EXIT CONDITION ######################### | |
for i in range(1000000): | |
try: | |
t = datetime.datetime.now() | |
ltp = kite.ltp(ticker_symbol)[ticker_symbol]['last_price'] | |
print('ltp :', ltp) | |
if (ltp >= target): | |
order(trading_symbol, "SELL", quantity, kite) | |
print(f'Target breached. Sold at Rs.{ltp}, PROFIT') | |
break | |
elif (ltp <= stop_loss): | |
order(trading_symbol, "SELL", quantity, kite) | |
print(f'stoploss breached. Sold at Rs.{ltp}, LOSS') | |
break | |
elif (t.hour == exit_hour) and (t.minute == exit_minute): | |
order(trading_symbol, "SELL", quantity, kite) | |
print(f'Trade Exit : No breach. Sold at Rs.{ltp}') | |
break | |
except BaseException as error: | |
print(f'{error} Exception occurred.') | |
sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment