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

Fetch Holdings or Transactions from Account without IBAN #104

Open
maltere opened this issue Jan 5, 2020 · 5 comments
Open

Fetch Holdings or Transactions from Account without IBAN #104

maltere opened this issue Jan 5, 2020 · 5 comments

Comments

@maltere
Copy link

maltere commented Jan 5, 2020

I am trying to fetch my current balances of an Deka Depot at the Sparkasse.

For an Deka Depot does not exist an IBAN so it only appears using client.get_information() but not with client.get_sepa_accounts().
My problem is that I can not provide an SEPAAccount-objejct for the Depot to fetch information from .get_transactions() or .get_holdings().

Is there a way to fetch the balances of the Depot?

I tried passing other SEPAAccounts to client.get_holdings(account), but this does not work, as I retrieve following error:

fints.exceptions.FinTSClientError: Error during dialog initialization, could not fetch BPD. Please check that you passed the correct bank identifier to the HBCI URL of the correct bank.

The same accounts work fine with client.get_transactions() and show their own transactions as expected.

The Deka Depot has following attributes when fetched with client.get_information():

  • type: 60
  • iban: None
  • account_number: xxx
  • supported_informations: [many]

While researching for a solution, I found similar problems with credit cards, but as credit card object types are 50 I did not expect that this would solve my problem.
Never less I tried using client.get_credit_card_transactions() with my deka depot. Suprise: It did not work.

I appreciate every idea. If you need me to provide more information, please feel free to ask.

@maltere
Copy link
Author

maltere commented Feb 10, 2020

Maybe this is related to #41 and #24?

@forgeorge
Copy link

A solution is to fetch the account information from the accounts list obtained by get_information and pass in into a SEPAAcoount object. The function get_account_from_information() pasted below replaces the function get_sepa_account().
I could get the balance from a Sparkasse Deka Depot, and also credit card transactions from the Sparkasse. Other accounts also seem to work, but are not completely tested.

from fints.models import SEPAAccount

def get_account_from_information(f):
    information = f.get_information()
    if isinstance(information, NeedTANResponse):
        information = ask_for_tan(information)
        
    accounts = information["accounts"]    
    if len(accounts) == 1:
        choice = 0
    else:
        print("Multiple accounts available, choose one")
        for i, mm in enumerate(accounts):
            print(i, mm["account_number"], mm["product_name"])
        choice = int( input("Choice: ").strip() )
          
    account = SEPAAccount(iban=accounts[choice]["iban"], bic="xxxxDExxxxx", # only [4:6] is used 
        accountnumber=accounts[choice]["account_number"], subaccount=accounts[choice]["subaccount_number"], 
            blz=f.bank_identifier.bank_code)
    return account

@lausser
Copy link

lausser commented Jan 30, 2021

I am customer of Augsburger Aktienbank and faced the same problem. I modified the above code a bit so that it returns a list (in my case just 1) of depots.

def get_depots_from_information(f):
    information = f.get_information()
    if isinstance(information, NeedTANResponse):
        information = ask_for_tan(information)

    for acc in information["accounts"]:
        if not accounts[choice].get("account_number", None):
            continue
        if acc["type"] == 30:
            # product_name (Depot) netbank Wertpapierdepo
            # all the other accounts (Tagesgeldkonto, Girokonto,...)
            # have a type of 1
            # blz is not copied from f (connection to bank2) but from acc.
            # when bank2 aquired my old bank1, my existing accounts were
            # transferred and still have the old blz.
            yield SEPAAccount(iban=accounts[choice]["iban"],
                bic="xxxxDExxxxx", # only [4:6] is used 
                accountnumber=accounts[choice]["account_number"],
                subaccount=accounts[choice]["subaccount_number"],
                blz=mm["bank_identifier"].bank_code)

The type 30 might be different in your case, i haven't found a documentation which would confirm that 30 stands for a stock portfolio/Aktiendepot.
First i wanted this function to return both accounts and stock portfolios, but that was no solution for my use case. Because the SEPAAccount does not have this type information. And i needed it because i wanted to run get_holdings(), which fails for all ordinary accounts.
So now i have basically:

    accounts = f.get_sepa_accounts()
    for acc in accounts:
        balance = f.get_balance(acc)
        print(" bal =====================")
        pprint.pprint(balance)
    for dep in get_depots_from_information(f):
        print("dep ====================")
        pprint.pprint(dep)
        holdings = f.get_holdings(dep)
        for hol in holdings:
            print("hol =========")
            pprint.pprint(hol)

@forgeorge
Copy link

Some addtional information:
Sparkasse Deka Depots are type 60, and MLP Bank Depots are type 30.
Sparkasse Deka Depot do not support get_holdings().
MLP Bank Depots require the full BIC for creating the SEPAAccount, not only characters [4:6].
Calling get_balance() fails for MLP Bank Depots, even as it is supported.
get_holdings() does work for MLP Bank Depots, but important information, i.e. the name of the holding, is missing.

@jmoeckel
Copy link

jmoeckel commented Aug 24, 2021

@forgeorge: I had the same "problem" with MLP Depots and the important information. The reason for the missing information is, that the MT535_Miniparser class expects ISIN, but MLP delivers WKN numbers.

Actually, it is quite a small workaround (quite dirty, because after this, it will no longer work for ISIN):

In fints.utils, change the regex in line 143 to
re_identification = re.compile(r"^:35B:(.*)\/(.*)\|(.*)")

Additionally change the field for isin in line 165:
isin = m.group(2)

Note, that the correspondig Holding still has the attribute ISIN although its the WKN.

I assume, for a more general fix, the corresponding field in the fints information has to be considered. Unfortunately in the case of WKN, there is no unique identifier string as in the case with ISIN (and I have no information, how it is for depots from other banks besides MLP).

Maybe this helps.

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

No branches or pull requests

5 participants