Skip to content

Instantly share code, notes, and snippets.

@gempesaw
Created December 12, 2024 16:29
Show Gist options
  • Save gempesaw/f17c6ae746f13c07f12862fef852cd06 to your computer and use it in GitHub Desktop.
Save gempesaw/f17c6ae746f13c07f12862fef852cd06 to your computer and use it in GitHub Desktop.
import requests
years_months = months = [
(2021, 5),
(2021, 6),
(2021, 7),
(2021, 8),
(2021, 9),
(2021, 10),
(2021, 11),
(2021, 12),
(2022, 1),
(2022, 2),
(2022, 3),
(2022, 4),
(2022, 5),
(2022, 6),
(2022, 7),
(2022, 8),
(2022, 9),
(2022, 10),
(2022, 11),
(2022, 12),
(2023, 1),
]
# 0-35, idk how many days in a month
days = range(35)
for year, month in years_months:
for day in days:
date = f"{year}{month:02}{day:02}"
url = f"https://cdn.finra.org/equity/regsho/daily/CNMSshvol{date}.txt"
head = requests.head(url)
if head.status_code == 200:
file = f"{date}.txt"
with open(file, "wb|") as f:
print(f"{date}: found text file, saving to {file}")
f.write(requests.get(url).content)
else:
print(f"{date}: no txt file found")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment