furas

example without repeat reading

Aug 4th, 2018
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. for x in stocks:
  2.  
  3.     tws.reqHistoricalData(x)
  4.  
  5.     for n in periods:
  6.         data = pd.DataFrame(reqHistoricalData(datetime.datetime.today()- datetime.timedelta(days=n)).strftime("%Y%m%d %H:%M:%S %Z"))
  7.  
  8.         if not data.empty:
  9.             data.to_csv("filename{}@{}.csv".format(x, n))
  10.         else:
  11.             print("empty data for", x, n)
RAW Paste Data