Skip to content

Instantly share code, notes, and snippets.

@ganigithub
Created June 21, 2022 15:16
Show Gist options
  • Select an option

  • Save ganigithub/020a313eb5e6af7607acc7c09db878a1 to your computer and use it in GitHub Desktop.

Select an option

Save ganigithub/020a313eb5e6af7607acc7c09db878a1 to your computer and use it in GitHub Desktop.
######################### ENTRY CONDITION ##########################
import datetime
for i in range(10000000):
try:
t = datetime.datetime.now()
ltp = kite.ltp(ticker_symbol)[ticker_symbol]['last_price']
print('ltp :', ltp)
if ltp > int_high:
order(trading_symbol, 'BUY', quantity, kite)
print(f'High breached. TradeEntry : Long at Rs {ltp}')
break
elif ltp < int_low:
order(trading_symbol, 'SELL', quantity, kite)
print(f'Low breached. Trade Entry : Short at Rs.{ltp}')
break
except BaseException as error:
print(f'{error} Exception occurred')
#exit at 15:25 if neither int_high nor int_low breached
if t.hour == 15 and t.minute == 25:
print('Trade not entered today.')
break
sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment