1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
e032d4ed1f
Kraken WIP
Some checks failed
Python Ruff Code Quality / ruff (push) Failing after 23s
Run Python tests (through Pytest) / Test (push) Successful in 32s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 26s
2024-12-18 17:41:33 +01:00
99a5dc82e4
Kucoin order details now handle pagination correctly 2024-12-14 23:38:47 +01:00
2 changed files with 35 additions and 4 deletions

View File

@ -7,7 +7,14 @@ from decimal import Decimal
import fin_defs
import krakenex
from .data import Depo, DepoFetcher, DepoSingle
from .data import (
DepoFetcher,
DepoSingle,
DepositDetails,
DoubleRegister,
TradeOrderDetails,
WithdrawalDetails,
)
logger = logging.getLogger(__name__)
@ -56,6 +63,23 @@ class KrakenDepoFetcher(DepoFetcher):
)
def _get_withdrawals(self) -> list[WithdrawalDetails]:
raise NotImplementedError("_get_withdrawals is a work in progress")
def _get_deposits(self) -> list[DepositDetails]:
raise NotImplementedError("_get_deposits is a work in progress")
def _get_historic_spot_orders(self) -> Iterator[TradeOrderDetails]:
raise NotImplementedError("_get_historic_spot_orders is a work in progress")
def _get_double_registers(self) -> list[DoubleRegister]:
double_registers: list[DoubleRegister] = []
double_registers += self._get_deposits()
double_registers += self._get_withdrawals()
double_registers += self._get_historic_spot_orders()
double_registers.sort(key=lambda x: x.executed_time)
return double_registers
def parse_asset_from_ticker(ticker: str) -> fin_defs.Asset:
account = ticker.removesuffix('.HOLD')
if account == 'ZEUR':

View File

@ -242,9 +242,16 @@ class KucoinDepoFetcher(DepoFetcher):
for _weeks_back in range(20):
end_time = end_time - datetime.timedelta(days=7)
timestamp = int(end_time.timestamp() * 1000)
raw_details = self.kucoin_client.get_orders(end=timestamp)
yield from (order_from_json(item) for item in raw_details['items'])
del _weeks_back, raw_details
page_index = 1
while True:
raw_details = self.kucoin_client.get_orders(end=timestamp, page=page_index)
yield from (order_from_json(item) for item in raw_details['items'])
page_index = raw_details['currentPage'] + 1
if page_index > raw_details['totalPage']:
break
del raw_details
del _weeks_back
def _get_double_registers(self) -> list[DoubleRegister]:
double_registers: list[DoubleRegister] = []