diff options
author | Camil Staps | 2025-07-11 15:31:59 +0200 |
---|---|---|
committer | Camil Staps | 2025-07-11 15:31:59 +0200 |
commit | 33ed0c43e48dadf90e6ba9341f645377b576b78f (patch) | |
tree | 1420f84464eb9046fdd5844865efd7da52141805 | |
parent | Add scripts to convert data from investment portfolios (diff) |
-rw-r--r-- | evi_to_asn.py | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/evi_to_asn.py b/evi_to_asn.py index 0531f30..e91fbd4 100644 --- a/evi_to_asn.py +++ b/evi_to_asn.py @@ -7,45 +7,27 @@ import sys # # Om de data te krijgen: # -# 1. Ga naar https://mijn.evivanlanschot.nl/deelnemer/vermogensontwikkeling -# 2. Er wordt een request gedaan naar /deelnemer/vermogensontwikkeling/postjsondata -# 3. Dit script converteert zulke data op stdin naar een CSV bestand op stdout - -MONTHS = { - 'jan': '01', 'feb': '02', 'mrt': '03', 'apr': '04', 'mei': '05', 'jun': '06', - 'jul': '07', 'aug': '08', 'sep': '09', 'okt': '10', 'nov': '11', 'dec': '12', - } - -def parse_date(s): - d, m, y = s.split('-') - return '{}-{}-20{}'.format(d, MONTHS[m], y) +# 1. Ga naar https://portal.evivanlanschot.nl/rekening +# 2. Klik op 'Vermogensontwikkeling' +# 3. Er wordt een request gedaan naar /api/dashboard/<ID>/chart/sinceStart?chartType=wealthDevelopment +# 4. Dit script converteert zulke data op stdin naar een CSV bestand op stdout def evi_to_asn(json): - dates = [e['label'] for e in obj['categories'][0]['Category']] - - cum = obj['dataset'][0] - assert cum['seriesName'] == 'Cumulatieve ontwikkeling' - prev = 0 - for date, entry in zip(dates, cum['data']): - if len(entry['value']) == 0: - continue - - value = float(entry['value'].replace(',', '.')) + for entry in json['dataPoints']: + value = entry['value'] if value == prev: continue diff = round(value - prev, 2) - date = parse_date(date) - yield '', '', '', '', '', '', '', 'EUR', prev, 'EUR', diff, date + yield '', '', '', '', '', '', '', 'EUR', prev, 'EUR', diff, entry['dateTime'] prev = value if __name__ == '__main__': for line in sys.stdin: - s = json.loads(line) - obj = json.loads(s) + obj = json.loads(line) wr = csv.writer(sys.stdout) for line in evi_to_asn(obj): |