1
0

Documentation
All checks were successful
Test Python / Test (push) Successful in 22s

This commit is contained in:
Jon Michael Aanes 2024-06-20 23:43:45 +02:00
parent a816adacbb
commit 71402d2fec
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
5 changed files with 73 additions and 1 deletions

View File

@ -11,6 +11,16 @@ from fin_defs import Asset
@enforce_typing.enforce_types @enforce_typing.enforce_types
@dataclasses.dataclass @dataclasses.dataclass
class Depo(abc.ABC): class Depo(abc.ABC):
"""A depository tracking some amount of assets.
Depo can either be DepoSingle, which is the base layer of the depository
structure, or nested in DepoGroup, which allows for a complex hierarcy of
depositories.
The depository structure exposed by each backend depends upon the logical
structure of the relevant service and the API of this service.
"""
name: str name: str
updated_time: datetime.datetime updated_time: datetime.datetime
@ -29,6 +39,8 @@ class Depo(abc.ABC):
@enforce_typing.enforce_types @enforce_typing.enforce_types
@dataclasses.dataclass @dataclasses.dataclass
class DepoSingle(Depo): class DepoSingle(Depo):
"""Base level of depository."""
_assets: Mapping[Asset, Decimal] _assets: Mapping[Asset, Decimal]
def assets(self) -> Iterable[Asset]: def assets(self) -> Iterable[Asset]:
@ -41,6 +53,8 @@ class DepoSingle(Depo):
@enforce_typing.enforce_types @enforce_typing.enforce_types
@dataclasses.dataclass @dataclasses.dataclass
class DepoGroup(Depo): class DepoGroup(Depo):
"""Nested depository."""
nested: list[Depo] nested: list[Depo]
def assets(self) -> Iterable[Asset]: def assets(self) -> Iterable[Asset]:

View File

@ -1,3 +1,5 @@
"""See `KrakenDepoFetcher` for documentation."""
import datetime import datetime
import logging import logging
from decimal import Decimal from decimal import Decimal
@ -11,6 +13,19 @@ logger = logging.getLogger(__name__)
class KrakenDepoFetcher: class KrakenDepoFetcher:
"""Depository fetcher for [Kraken](https://www.kraken.com), the online crypto currency exchange.
Requirements for use:
- Account on [Kraken](https://www.kraken.com).
- Have performed Know Your Customer (KYC) for your account.
- Created API key from [Kraken Pro
settings](https://pro.kraken.com/app/settings/api).
API key must have the **Query Funds Permission**, and **should not have
any additional permissions**. Employ principle of least priviledge.
Depository structure: A `DepoSingle`. No nesting.
"""
def __init__(self, kraken_key: str, kraken_secret: str): def __init__(self, kraken_key: str, kraken_secret: str):
assert kraken_key is not None, 'Missing kraken_key' assert kraken_key is not None, 'Missing kraken_key'
assert kraken_secret is not None, 'Missing kraken_secret' assert kraken_secret is not None, 'Missing kraken_secret'

View File

@ -1,3 +1,5 @@
"""See `KucoinDepoFetcher` for documentation."""
import datetime import datetime
import logging import logging
from decimal import Decimal from decimal import Decimal
@ -11,6 +13,19 @@ logger = logging.getLogger(__name__)
class KucoinDepoFetcher: class KucoinDepoFetcher:
"""Depository fetcher for [Kucoin](https://www.kucoin.com), the online crypto currency exchange.
Requirements for use:
- Account on [Kucoin](https://www.kucoin.com).
- Have performed Know Your Customer (KYC) for your account.
- Created API key from [settings menu](https://www.kucoin.com/account/api).
API key must have the **General Permission**, and **should not have
any additional permissions**. Employ principle of least priviledge.
Depository structure: An upper level depo split for each of the
sub-accounts (Funding, Trading, Margin, Futures...)
"""
def __init__(self, kucoin_key: str, kucoin_secret: str, kucoin_pass: str): def __init__(self, kucoin_key: str, kucoin_secret: str, kucoin_pass: str):
assert kucoin_key is not None, 'Missing kucoin_key' assert kucoin_key is not None, 'Missing kucoin_key'
assert kucoin_secret is not None, 'Missing kucoin_secret' assert kucoin_secret is not None, 'Missing kucoin_secret'

View File

@ -1,3 +1,5 @@
"""See `PartisiaBlockchainAccountDepoFetcher` for documentation."""
import dataclasses import dataclasses
import datetime import datetime
import email.utils import email.utils
@ -137,6 +139,17 @@ BYOC_ASSETS = {
class PartisiaBlockchainAccountDepoFetcher: class PartisiaBlockchainAccountDepoFetcher:
"""Depository fetcher for individual [Partisia
Blockchain](https://partisiablockchain.com/) accounts, including [MPC](https://partisiablockchain.gitlab.io/documentation/pbc-fundamentals/mpc-token-model-and-account-elements.html) and
[Bring-Your-Own-Coin](https://partisiablockchain.gitlab.io/documentation/pbc-fundamentals/byoc/introduction-to-byoc.html).
Requirements for use:
- Account on Partisia Blockchain.
Depository structure: A nested depo containing both a `Native` and a `BYOC`
depo.
"""
def __init__(self, session, blockchain_address: str): def __init__(self, session, blockchain_address: str):
assert session is not None, 'missing session' assert session is not None, 'missing session'
assert blockchain_address is not None, 'missing blockchain_address' assert blockchain_address is not None, 'missing blockchain_address'

View File

@ -1,4 +1,4 @@
"""Nordnet Depository fetching for Nordnet, the scandinavian investment bank. """Nordnet Depository fetching for [Nordnet](https://nordnet.dk), the online scandinavian investment bank.
This fetcher uses the [Nordnet This fetcher uses the [Nordnet
API](https://www.nordnet.dk/externalapi/docs/api), which requires a Nordnet API](https://www.nordnet.dk/externalapi/docs/api), which requires a Nordnet
@ -40,6 +40,21 @@ def asset_from_instrument_json(json) -> fin_defs.Asset | None:
class NordnetDepoFetcher: class NordnetDepoFetcher:
"""Depository fetcher for [Nordnet](https://nordnet.dk), the online investment bank.
Requirements for use:
- Account on [Nordnet](https://nordnet.dk). This requires a MitID.
- Password login enabled from [settings](https://www.nordnet.dk/indstillinger/min-profil)
**Warning**: This system uses an unofficial API which uses your normal
Nordnet username and password for login access, with full read/write
access! **This is dangerous**, and any potential leak would give an
attacker full access to your account.
Depository structure: Each account you have access to will be given its own
`Depo`, with all of them nested under a "Nordnet" nested depository.
"""
def __init__(self, session, username: str, password: str): def __init__(self, session, username: str, password: str):
assert session is not None, 'missing session' assert session is not None, 'missing session'
self.session = session self.session = session