1
0

Compare commits

..

2 Commits

Author SHA1 Message Date
fa7c5c3c83
Code quality
Some checks failed
Test Python / Test (push) Failing after 25s
2024-07-16 22:00:28 +02:00
2a563daf57
Documentation improvements 2024-07-16 21:54:13 +02:00
2 changed files with 23 additions and 11 deletions

View File

@ -4,8 +4,8 @@ Python library for automatic fetching of personal asset depo information.
Supports: Supports:
- **Kraken**: Uses their API - **Kraken**: Uses their [publicly documented API](https://docs.kraken.com/rest/).
- **Kucoin**: Uses their API - **Kucoin**: Uses their [publicly documented API](https://www.kucoin.com/docs/beginners/introduction).
- **Partisia Blockchain Account**: Uses a reader node to check the account - **Partisia Blockchain Account**: Uses a reader node to check the account
state. state.
- **Nordnet**: Through their - **Nordnet**: Through their
@ -20,6 +20,11 @@ Supports:
- [ ] Personal Bank: Personal Bank Account (Open Banking) Maybe use AIIA? - [ ] Personal Bank: Personal Bank Account (Open Banking) Maybe use AIIA?
""" """
__all__ = ['defi_kraken', 'defi_kucoin', 'defi_partisia_blockchain'] __all__ = [
'defi_kraken',
'defi_kucoin',
'defi_partisia_blockchain',
'investbank_nordnet',
]
from . import defi_kraken, defi_kucoin, defi_partisia_blockchain from . import defi_kraken, defi_kucoin, defi_partisia_blockchain, investbank_nordnet

View File

@ -14,6 +14,7 @@ import logging
from decimal import Decimal from decimal import Decimal
import fin_defs import fin_defs
from frozendict import frozendict
from .data import Depo, DepoGroup, DepoSingle from .data import Depo, DepoGroup, DepoSingle
@ -38,6 +39,7 @@ def asset_from_instrument_json(json) -> fin_defs.Asset | None:
exchange_id = json['tradables'][0]['mic'] exchange_id = json['tradables'][0]['mic']
return fin_defs.Stock(symbol, fin_defs.EXCHANGES_BY_IDS[exchange_id]) return fin_defs.Stock(symbol, fin_defs.EXCHANGES_BY_IDS[exchange_id])
EMPTY_DICT: dict[str,str | int] = frozendict()
class NordnetDepoFetcher: class NordnetDepoFetcher:
"""Depository fetcher for [Nordnet](https://nordnet.dk), the online investment bank. """Depository fetcher for [Nordnet](https://nordnet.dk), the online investment bank.
@ -56,17 +58,22 @@ class NordnetDepoFetcher:
""" """
def __init__(self, session, username: str, password: str): def __init__(self, session, username: str, password: str):
assert session is not None, 'missing session'
self.session = session self.session = session
self.username = username self.username = username
self.password = password self.password = password
self.is_logged_in = False self.is_logged_in = False
assert self.username is not None, 'Username is missing' if self.session is None:
assert self.password is not None, 'Password is missing' msg = 'Session argument is missing'
raise TypeError(msg)
if self.username is not None:
msg = 'Username argument s missing'
raise TypeError(msg)
if self.password is not None:
msg = 'Password argument is missing'
raise TypeError(msg)
def get_json(self, url: str, params: dict[str, str | int] = EMPTY_DICT)-> dict:
def get_json(self, url: str, params: dict[str, str | int] = {}) -> dict:
if not url.startswith(API_ROOT): if not url.startswith(API_ROOT):
msg = f'Given url must be located below API ROOT: {url}' msg = f'Given url must be located below API ROOT: {url}'
raise ValueError(msg) raise ValueError(msg)
@ -110,7 +117,7 @@ class NordnetDepoFetcher:
json_accounts = self.get_json(API_ACCOUNTS) json_accounts = self.get_json(API_ACCOUNTS)
nested = [] nested: list[Depo] = []
for json_account in json_accounts: for json_account in json_accounts:
account_id = json_account['accid'] account_id = json_account['accid']
@ -149,7 +156,7 @@ class NordnetDepoFetcher:
) )
return DepoGroup( return DepoGroup(
name=f'Nordnet', name='Nordnet',
updated_time=now, updated_time=now,
nested=nested, nested=nested,
) )