Skip to content

Instantly share code, notes, and snippets.

@samchaaa
Created December 20, 2020 08:27
Show Gist options
  • Save samchaaa/ca5b4756be36f610cb7814f8cb48dcf0 to your computer and use it in GitHub Desktop.
Save samchaaa/ca5b4756be36f610cb7814f8cb48dcf0 to your computer and use it in GitHub Desktop.
def get_data(symbol, start, end):
results = pd.DataFrame()
while True:
if start < end:
# 15m bars
d = api.polygon.historic_agg_v2(symbol, 15, 'minute', _from=start, to=end, unadjusted=False, limit=None).df
time.sleep(.2)
start = d.index[-1].strftime('%Y-%m-%d')
results = pd.concat([results, d], axis=0)
else:
break
results.drop_duplicates(inplace=True)
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment