add option to query account details including personal data#159
add option to query account details including personal data#159marcusfey wants to merge 6 commits intopytr-org:masterfrom
Conversation
NiklasRosenstein
left a comment
There was a problem hiding this comment.
Thanks for the contribution @marcusfey
pytr/accountdetails.py
Outdated
| @@ -0,0 +1,16 @@ | |||
| import json | |||
|
|
|||
| class Accountdetails: | |||
There was a problem hiding this comment.
| class Accountdetails: | |
| class AccountDetails: |
There was a problem hiding this comment.
I don't think this class has any right to be here, it's such a thin wrapper. :)
What would be neat is this was a TypedDict instead that describes the fields returned by TradeRepublicApi.get_account_details().
pytr/main.py
Outdated
| elif args.command == "accountdetails": | ||
| ad = Accountdetails( | ||
| login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin), | ||
| ) | ||
| ad.get() | ||
| if args.jsonoutput is not None: | ||
| ad.data_to_file(args.jsonoutput) |
There was a problem hiding this comment.
| elif args.command == "accountdetails": | |
| ad = Accountdetails( | |
| login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin), | |
| ) | |
| ad.get() | |
| if args.jsonoutput is not None: | |
| ad.data_to_file(args.jsonoutput) | |
| elif args.command == "accountdetails": | |
| tr = login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin) | |
| account_details = tr.get_account_details() | |
| args.jsonoutput.write(json.dumps(account_details)) |
There was a problem hiding this comment.
A question here: this would write the json args.jsonoutput without checking if this parameter is actually set.
Are the any implicit checks I'm not aware of? Or should I change this to
elif args.command == "accountdetails":
tr = login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin)
account_details = tr.get_account_details()
if args.jsonoutput is not None:
args.jsonoutput.write(json.dumps(account_details))There was a problem hiding this comment.
The other change above I suggested makes it so args.jsonpath is always set, to a file-like object in write mode. If no argument is specified, it defaults to - which argparse.FileType interprets as "stdout".
There was a problem hiding this comment.
Ah, right! I wasn't aware initially that those -o parameter are per command. It's a nice solution.
|
Thanks for your review! I'm completely fine with what you requested. Actually for me Thus: Should I remove |
Yes, I think that's okay! If you care to invest the time, it would be nice to have a |
|
I added the TypedDict with 1ce3145. But I really not sure if that's what you had in mind 🫣 |
The API so far does not read the account data from Traderepublic. A lot of this data is not that interesting and pretty static (name, address, etc). But there is also the main account including IBAN.
I need this for my own asset management application where I aggregate all the current/saving accounts from all my banks. To achieve this I added modules for each bank, they send the account information to the main app. Thus only the balance is not enough, at least IBAN is needed to sort things out for the main app.
I'm aware that returning the dict and writing out the JSON is not that much of a processing. Please consider adding this "anyway", change the code or tell me what I should add.
Addmittedly I'm pretty new to Python.
This is roughly what you will get:
{ "phoneNumber":"+491xxxx", "jurisdiction":"DE", "name":{"first":"xxxx", "last":"xxx"}, "email":{"address":"xxxx@xxxx.de", "verified":true}, "duplicateTradingEmail":null, "postalAddress":{"street":"SomeStreet", "houseNo":"4", "zip":"123456", "city":"Somecity", "country":"DE"}, "birthdate":"1902-01-01", "birthplace":{"birthplace":"Somecity", "birthcountry":"DE"}, "mainNationality":"DE", "additionalNationalities":[], "mainTaxResidency":{"tin":"12345987", "countryCode":"DE"}, "usTaxResidency":false, "additionalTaxResidencies":[], "taxInformationSyncTimestamp":172177300000, "taxExemptionOrder":{"minimum":0, "maximum":9900, "current":111, "applied":2131, "syncStatus":12414, "validFrom":1242, "validUntil":2312}, "registrationAccount":false, "cashAccount":{"iban":"DE00000000000000000000", "bic":"TRBKDEBBXXX", "bankName":"J.P. Morgan SE", "logoUrl":null}, "referenceAccount":{"iban":"-", "bic":null}, "referenceAccountV2":null, "referenceAccountList":[{"iban":"DE00012134874564878747", "bic":null, "bankName":"Bank", "logoUrl":"logos/bank_bank/v2"}], "securitiesAccountNumber":"321354657", "experience":{"stock":{"tradeCount":0, "level":"LOSER", "showsRiskWarning":true}, "fund":{"tradeCount":0, "level":"LOSER", "showsRiskWarning":true}, "derivative":{"tradeCount":0, "level":"LOSER", "showsRiskWarning":true}, "crypto":{"tradeCount":100, "level":"GODMODE", "showsRiskWarning":true}, "bond":{"level":"xxxx", "showsRiskWarning":true}}, "referralDetails":null, "supportDocuments":{ "accountClosing":"https://assets.traderepublic.com/assets/files/foilename.pdf", "imprint":"https://traderepublic.com/de-de/imprint", "addressConfirmation":"https://support.traderepublic.com/de-de/102"}, "tinFormat":{"placeholder":"99999999999", "keyboardLayout":"numerical" }, "personId":"babdbddb-5441-23-124-423423542532112" }