Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_ratner_stock'
Browse files Browse the repository at this point in the history
  • Loading branch information
GjjvdBurg committed Dec 12, 2024
2 parents c1a70fa + 27fd401 commit 83b3039
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion datasets/ratner_stock/get_ratner_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def write_csv(target_path=None):
rounding=False,
)
sig.index = sig.index.tz_localize(None)

if sig.columns.nlevels > 1:
sig.columns = sig.columns.droplevel(1)

sig.round(6).to_csv(target_path, float_format="%.6f")
return
except URLError as err:
Expand All @@ -103,6 +107,7 @@ def write_json(csv_path, target_path=None):
rows = list(reader)

header = rows.pop(0)
close_idx = header.index("Close")

rows = [r for i, r in enumerate(rows) if i % SAMPLE == 0]

Expand All @@ -114,7 +119,10 @@ def write_json(csv_path, target_path=None):
time = [r[0] for r in rows]
time_fmt = "%Y-%m-%d"

values = [None if r[4].strip() == "" else float(r[4]) for r in rows]
values = [
None if r[close_idx].strip() == "" else float(r[close_idx])
for r in rows
]

series = [{"label": "Close Price", "type": "float", "raw": values}]

Expand Down

0 comments on commit 83b3039

Please sign in to comment.