1
0

Compare commits

..

No commits in common. "88717fbb8e24cfc419d8c3bcd134850c2c3a9c03" and "bcae3d4e29743ddb4daf3bcbc0139f7846c1d233" have entirely different histories.

5 changed files with 14 additions and 47 deletions

View File

@ -55,31 +55,12 @@ __all__ = [
'static', 'static',
] ]
import importlib
import logging
from . import ( from . import (
data, data,
defi_kraken,
defi_kucoin,
defi_partisia_blockchain,
investbank_nordnet,
static, static,
) )
from ._version import __version__ from ._version import __version__
logger = logging.getLogger(__name__)
def load_backend(name: str) -> object | None:
try:
return importlib.import_module(f'{__name__}.{name}')
except Exception:
logger.exception(
'Backend %s could not be imported? Are all module dependencies installed?',
name,
)
return None
# Import modules
defi_kraken = load_backend('defi_kraken')
defi_kucoin = load_backend('defi_kucoin')
investbank_nordnet = load_backend('investbank_nordnet')
defi_partisia_blockchain = load_backend('defi_partisia_blockchain')

View File

@ -1 +1 @@
__version__ = '0.1.29' __version__ = '0.1.28'

View File

@ -139,10 +139,7 @@ class KucoinDepoFetcher(DepoFetcher):
return self._get_order_details(response['orderId'], input_asset, output_asset) return self._get_order_details(response['orderId'], input_asset, output_asset)
def _get_order_details( def _get_order_details(
self, self, order_id: str, input_asset: fin_defs.Asset, output_asset: fin_defs.Asset,
order_id: str,
input_asset: fin_defs.Asset,
output_asset: fin_defs.Asset,
) -> TradeOrderDetails: ) -> TradeOrderDetails:
"""Determine the order details for the order with the given id. """Determine the order details for the order with the given id.
@ -167,19 +164,14 @@ class KucoinDepoFetcher(DepoFetcher):
fee_asset=fin_defs.WELL_KNOWN_SYMBOLS[order_details['feeCurrency']], fee_asset=fin_defs.WELL_KNOWN_SYMBOLS[order_details['feeCurrency']],
fee_amount=Decimal(order_details['fee']), fee_amount=Decimal(order_details['fee']),
executed_time=datetime.datetime.fromtimestamp( executed_time=datetime.datetime.fromtimestamp(
order_details['createdAt'] / 1000, order_details['createdAt'] / 1000, tz=datetime.UTC,
tz=datetime.UTC,
), ),
order_id=order_id, order_id=order_id,
raw_order_details=order_details, raw_order_details=order_details,
) )
def _get_order_with_retries( def _get_order_with_retries(
self, self, order_id: str, *, num_retries: int, sleep_between_tries: float = 1.0,
order_id: str,
*,
num_retries: int,
sleep_between_tries: float = 1.0,
) -> dict: ) -> dict:
"""Get the order details from KuCoin backend. """Get the order details from KuCoin backend.

View File

@ -18,23 +18,18 @@ import fin_defs
import requests import requests
from frozendict import frozendict from frozendict import frozendict
from nordnet_api_client import NordnetClient from nordnet_api_client import NordnetClient
from nordnet_api_client.data import Instrument
from .data import Depo, DepoFetcher, DepoGroup, DepoSingle from .data import Depo, DepoFetcher, DepoGroup, DepoSingle
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def asset_from_instrument(instrument: Instrument) -> fin_defs.Asset | None: def asset_from_instrument(intrument) -> fin_defs.Asset | None:
if instrument.instrument_group_type == 'FND': if intrument.instrument_group_type == 'FND':
return None return None
symbol = instrument.symbol symbol = intrument.symbol
exchange_id = instrument.tradables[0].mic exchange_id = intrument.tradables[0].mic
return fin_defs.Stock( return fin_defs.Stock(symbol, fin_defs.EXCHANGES_BY_IDS[exchange_id])
symbol,
fin_defs.EXCHANGES_BY_IDS[exchange_id],
nordnet_id=instrument.instrument_id,
)
EMPTY_DICT: Mapping[str, str | int] = frozendict() EMPTY_DICT: Mapping[str, str | int] = frozendict()

View File

@ -7,8 +7,7 @@ import fin_depo
def test_get_depo(): def test_get_depo():
fetcher = fin_depo.static.StaticDepoFetcher( fetcher = fin_depo.static.StaticDepoFetcher(
'Test', 'Test', {fin_defs.BTC: Decimal(1000), fin_defs.USD: Decimal(2000)},
{fin_defs.BTC: Decimal(1000), fin_defs.USD: Decimal(2000)},
) )
depo = fetcher.get_depo() depo = fetcher.get_depo()