Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way I can download the Account Statement as .csv? #38

Open
matheusft opened this issue Jun 21, 2021 · 3 comments
Open

Is there any way I can download the Account Statement as .csv? #38

matheusft opened this issue Jun 21, 2021 · 3 comments

Comments

@matheusft
Copy link

No description provided.

@Jakub-CZ
Copy link

With the enhancement contributed in #16 you can make your own:

import csv
from datetime import date

degiro = ...  # connect & login here
ao = degiro.account_overview(date(2021, 4, 1), date.today())
cash_movements = ao["cashMovements"]  # type: List[Dict]
fieldnames = ['date', 'valueDate', 'description', 'currency', 'change', 'type', 'exchangeRate', 'orderId']
# productId, balance: also available but they would require further processing
with open('report.csv', 'w', newline='', encoding='utf-8') as csvfile:
    writer = csv.DictWriter(csvfile, fieldnames=fieldnames, extrasaction="ignore")
    writer.writeheader()
    writer.writerows(cash_movements)

@matheusft
Copy link
Author

Hummmm, I see, thanks @Jakub-CZ .
I was hoping to get something in the same shape as the .csv file available for download.

Date, Time, Value date, Product, ISIN, Description, FX, Change_Currency,  Change_Value, Balance_Currency, Balance_Value, and Order Id

Is the ISIN represented by any of the fields from fieldnames ?
What is type from fieldnames, by the way?
fieldnames = ['date', 'valueDate', 'description', 'currency', 'change', 'type', 'exchangeRate', 'orderId']

@Jakub-CZ
Copy link

In my report types is either of these two: {'TRANSACTION', 'CASH_TRANSACTION'}. Personally, I don't use that attribute for anything.


The field productId gives you some kind of Degiro's internal number for the stock. You can translate it to something meaningful (e.g. the ISINs) using degiro.product_info(). See https://github.com/lolokraus/DegiroAPI#product_info

This is how you can build a handy-dandy dictionary mapping all the productIds that appear in cash_movements to ISINs:

from pprint import pprint
from degiroapi.product import Product

pid_map = {p: Product(degiro.product_info(p)).isin for p in filter(None, {e.get("productId") for e in cash_movements})}
pprint(pid_map)

# {322171: 'US4581401001',
#  331916: 'US94106L1098',
#  332062: 'US7170811035',
#  ...

How to put this all together in a single CSV is left as an exercise to the reader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants