-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcreate_quote_store.py
52 lines (37 loc) · 1.18 KB
/
create_quote_store.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import json
import pandas as pd
from bitmex_s3.src.downloader import (
QuoteData
)
def create_date_strings(start_date, end_date):
def month_str(month):
if month < 10:
return f"0{month}"
else:
return f"{month}"
def day_str(day):
if day < 10:
return f"0{day}"
else:
return f"{day}"
if end_date <= start_date:
raise ValueError("Check dates")
range = pd.date_range(start=start_date, end=end_date, freq='D')
dates = []
for date in range:
dates.append(f"{date.year}{month_str(date.month)}{day_str(date.day)}")
return dates
def main():
with open('store.quote.config.json', 'r') as json_file:
config = json.load(json_file)
bucket_name = config["bucket-name"]
data_type = config["data-type"]
store_path = config["store-path"]
quote_data = QuoteData(bucket_name)
dates = create_date_strings(config["start-date"], config["end-date"])
for date in dates:
data = quote_data.get(date)
data.to_csv(f"{store_path}/{bucket_name}-{date}")
print("Downloaded quote data for date: ", date)
if __name__ == '__main__':
main()