Compare commits
2 Commits
0eeff8d0fb
...
fa7c5c3c83
Author | SHA1 | Date | |
---|---|---|---|
fa7c5c3c83 | |||
2a563daf57 |
|
@ -4,8 +4,8 @@ Python library for automatic fetching of personal asset depo information.
|
|||
|
||||
Supports:
|
||||
|
||||
- **Kraken**: Uses their API
|
||||
- **Kucoin**: Uses their API
|
||||
- **Kraken**: Uses their [publicly documented API](https://docs.kraken.com/rest/).
|
||||
- **Kucoin**: Uses their [publicly documented API](https://www.kucoin.com/docs/beginners/introduction).
|
||||
- **Partisia Blockchain Account**: Uses a reader node to check the account
|
||||
state.
|
||||
- **Nordnet**: Through their
|
||||
|
@ -20,6 +20,11 @@ Supports:
|
|||
- [ ] 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
|
||||
|
|
|
@ -14,6 +14,7 @@ import logging
|
|||
from decimal import Decimal
|
||||
|
||||
import fin_defs
|
||||
from frozendict import frozendict
|
||||
|
||||
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']
|
||||
return fin_defs.Stock(symbol, fin_defs.EXCHANGES_BY_IDS[exchange_id])
|
||||
|
||||
EMPTY_DICT: dict[str,str | int] = frozendict()
|
||||
|
||||
class NordnetDepoFetcher:
|
||||
"""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):
|
||||
assert session is not None, 'missing session'
|
||||
self.session = session
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.is_logged_in = False
|
||||
|
||||
assert self.username is not None, 'Username is missing'
|
||||
assert self.password is not None, 'Password is missing'
|
||||
if self.session is None:
|
||||
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] = {}) -> dict:
|
||||
def get_json(self, url: str, params: dict[str, str | int] = EMPTY_DICT)-> dict:
|
||||
if not url.startswith(API_ROOT):
|
||||
msg = f'Given url must be located below API ROOT: {url}'
|
||||
raise ValueError(msg)
|
||||
|
@ -110,7 +117,7 @@ class NordnetDepoFetcher:
|
|||
|
||||
json_accounts = self.get_json(API_ACCOUNTS)
|
||||
|
||||
nested = []
|
||||
nested: list[Depo] = []
|
||||
for json_account in json_accounts:
|
||||
account_id = json_account['accid']
|
||||
|
||||
|
@ -149,7 +156,7 @@ class NordnetDepoFetcher:
|
|||
)
|
||||
|
||||
return DepoGroup(
|
||||
name=f'Nordnet',
|
||||
name='Nordnet',
|
||||
updated_time=now,
|
||||
nested=nested,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user