From 8808f587eb502077a3eab24df69c03d9d1c29709 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Mon, 7 Sep 2020 12:33:33 +0100 Subject: Bugfix for aapl download script --- datasets/apple/get_apple.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/datasets/apple/get_apple.py b/datasets/apple/get_apple.py index 76d8e27..12c173b 100644 --- a/datasets/apple/get_apple.py +++ b/datasets/apple/get_apple.py @@ -86,6 +86,18 @@ def write_csv(target_path=None): rounding=False, threads=False, ) + # Somewhere between 2020-08-26 and 2020-09-07 an API change + # happened (I guess) that changed these prices and the volume by a + # factor of 4. Long term this is a fragile solution, but for now + # this condition ensures that the correct file is generated. + if 0.2131696 <= aapl["Close"][0] <= 0.2131697: + aapl["Open"] = aapl["Open"] * 4 + aapl["High"] = aapl["High"] * 4 + aapl["Low"] = aapl["Low"] * 4 + aapl["Close"] = aapl["Close"] * 4 + # Adj Close doesn't adhere to factor 4 + aapl["Volume"] = aapl["Volume"] // 4 + aapl.round(6).to_csv(target_path, float_format="%.6f") return except URLError as err: -- cgit v1.2.3