diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2020-09-07 12:33:33 +0100 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2020-09-07 12:33:33 +0100 |
| commit | 8808f587eb502077a3eab24df69c03d9d1c29709 (patch) | |
| tree | 0db7411ea138c2f259121da96be9a0c85d32ea0a | |
| parent | Merge branch 'bugfix/measles_download' into master (diff) | |
| download | TCPD-8808f587eb502077a3eab24df69c03d9d1c29709.tar.gz TCPD-8808f587eb502077a3eab24df69c03d9d1c29709.zip | |
Bugfix for aapl download script
| -rw-r--r-- | datasets/apple/get_apple.py | 12 |
1 files changed, 12 insertions, 0 deletions
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: |
