furas

loop only 10 times to download again

Aug 2nd, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def get_data():
  2.  
  3.     stocks = ['A', 'B', 'C', 'D', 'E','F','G','H']
  4.  
  5.     for x in stocks:
  6.  
  7.         for _ in range(10):
  8.             tws.reqHistoricalData(x)
  9.  
  10.             data = pd.DataFrame(reqHistoricalData)
  11.      
  12.             if not data.empty:
  13.                 data.to_csv("Your Path")
  14.                 break
  15.  
  16.             print("Data is empty")
Add Comment
Please, Sign In to add comment