Advertisement
rishiswethan

get_quote()

Mar 22nd, 2019
1,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1.  
  2. def get_quote(symbol_name): # Pass symbol name in this format [<exchange>:<symbol_name_1>, <exchange>:<symbol_name_2>, etc]
  3.     limit_cnt = 0
  4.     while limit_cnt < 10:
  5.         try:
  6.             x = kite.quote(symbol_name)
  7.             # print(('prices', len(x), x))
  8.             if len(x) == 0:
  9.                 limit_cnt += 1
  10.                 print('Error in get_quote()', 'Empty result')
  11.                 time.sleep(0.5)
  12.                 continue
  13.             return x
  14.         except:
  15.             traceback.print_exc()
  16.             limit_cnt += 1
  17.             print('Error in get_quote()', sys.exc_info())
  18.             time.sleep(0.5)
  19.             continue
  20.  
  21. print(get_quote(['NSE:TCS', 'NSE:INFY']))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement