Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
github.com:443
objects.githubusercontent.com:443
pypi.org:443
raw.githubusercontent.com:443
release-assets.githubusercontent.com:443

- name: Checkout repository
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_test_futures_private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
github.com:443
objects.githubusercontent.com:443
pypi.org:443
raw.githubusercontent.com:443
release-assets.githubusercontent.com:443

- name: Checkout repository
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_test_futures_public.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
futures.kraken.com:443
github.com:443
objects.githubusercontent.com:443
raw.githubusercontent.com:443
release-assets.githubusercontent.com:443
pypi.org:443

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_test_spot_private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
github.com:443
objects.githubusercontent.com:443
pypi.org:443
raw.githubusercontent.com:443
release-assets.githubusercontent.com:443
ws-auth.kraken.com:443
ws.kraken.com:443
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_test_spot_public.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
github.com:443
objects.githubusercontent.com:443
pypi.org:443
raw.githubusercontent.com:443
release-assets.githubusercontent.com:443
ws.kraken.com:443

Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.6
rev: v0.15.7
hooks:
- id: ruff-check
args:
Expand All @@ -20,7 +20,7 @@ repos:
# - --preview
# - --exit-non-zero-on-fix
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
rev: v1.19.1
hooks:
- id: mypy
name: mypy
Expand All @@ -31,11 +31,11 @@ repos:
- --install-types
- --non-interactive
- repo: https://github.com/gitleaks/gitleaks
rev: v8.29.1
rev: v8.30.1
hooks:
- id: gitleaks
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
rev: v2.4.2
hooks:
- id: codespell
additional_dependencies: [tomli]
Expand Down Expand Up @@ -72,21 +72,21 @@ repos:
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/psf/black
rev: 25.11.0
rev: 26.3.1
hooks:
- id: black
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.6.2
rev: v3.8.1
hooks:
- id: prettier
- repo: https://github.com/PyCQA/isort # TODO: remove as soon as ruff is stable
rev: 7.0.0
rev: 8.0.1
hooks:
- id: isort
args:
- --profile=black
- repo: https://github.com/PyCQA/bandit
rev: 1.9.1
rev: 1.9.4
hooks:
- id: bandit
exclude: "^tests/.*|examples/.*"
Expand Down
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#

UV ?= uv
PYTHON := python
PYTEST := $(UV) run pytest
PYTEST_OPTS := -vv --junit-xml=pytest.xml
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=kraken --cov-report=xml:coverage.xml --cov-report=term-missing --cov-report=html
TEST_DIR := tests
PYTHON ?= python
PYTEST ?= $(UV) run pytest
PYTEST_OPTS ?= -vv --junit-xml=pytest.xml
PYTEST_COV_OPTS ?= $(PYTEST_OPTS) --cov=kraken --cov-report=xml:coverage.xml --cov-report=term-missing --cov-report=html
TEST_DIR ?= tests

## ======= M A K E F I L E - T A R G E T S =====================================
## help Show this help message
Expand Down Expand Up @@ -136,7 +136,8 @@ clean:
dist/ \
doc/_build \
src/python_kraken_sdk.egg-info \
build/
build/ \
htmlcov/

rm -f .coverage \
*.csv \
Expand All @@ -146,7 +147,8 @@ clean:
src/kraken/_version.py \
mypy.xml \
pytest.xml \
tests/*.zip
tests/*.zip \
uv.lock

find tests -name "__pycache__" | xargs rm -rf
find src -name "__pycache__" | xargs rm -rf
Expand Down
4 changes: 1 addition & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
# Add the package to sys.path:
sys.path.insert(0, str(Path("..").resolve() / "src"))

rst_epilog = ""
# Read link all targets from file
with Path("links.rst").open(encoding="utf-8") as f:
rst_epilog += f.read()
rst_epilog = Path("links.rst").read_text(encoding="utf-8")


def setup(app: Any) -> None: # noqa: ARG001,ANN401
Expand Down
4 changes: 2 additions & 2 deletions examples/futures_ws_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ async def main() -> None:
await asyncio.sleep(6)
finally:
# Close the sessions properly.
for _client in clients:
await _client.close()
for open_client in clients:
await open_client.close()


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions examples/spot_ws_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ async def main() -> None:
await asyncio.sleep(6)
finally:
# Stop the sessions properly.
for _client in clients:
await _client.close()
for open_client in clients:
await open_client.close()


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ ignore = [
"E203", # Whitespace before ':' # false positive on list slices
"PLR6301", # Method `…` could be a function or static method # false positive for no-self-use
"RUF022", # `__all__` is not sorted
"RUF067", # __init__ doing more than docs and re-exports
]

task-tags = ["todo", "TODO", "fixme", "FIXME"]
Expand Down
18 changes: 7 additions & 11 deletions tests/futures/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from __future__ import annotations

import contextlib
import logging
from pathlib import Path

Expand Down Expand Up @@ -61,17 +62,12 @@ async def on_message(
self.LOG.info(message) # the log is read within the tests

log: str = ""
try:
with Path(CACHE_DIR / "futures_ws.log").open(
mode="r",
with contextlib.suppress(FileNotFoundError):
log = Path(CACHE_DIR / "futures_ws.log").read_text( # noqa: ASYNC240
encoding="utf-8",
) as logfile:
log = logfile.read()
except FileNotFoundError:
pass
)

with Path(CACHE_DIR / "futures_ws.log").open(
mode="w",
Path(CACHE_DIR / "futures_ws.log").write_text( # noqa: ASYNC240
f"{log}\n{message}",
encoding="utf-8",
) as logfile:
logfile.write(f"{log}\n{message}")
)
11 changes: 3 additions & 8 deletions tests/spot/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from __future__ import annotations

import contextlib
import json
import logging
from pathlib import Path
Expand Down Expand Up @@ -99,14 +100,8 @@ def ensure_log(cls, content: dict | list) -> None:
cls.LOG.info(json.dumps(content))

log: str = ""
try:
with Path(CACHE_DIR / "spot_orderbook-2.log").open(
mode="r",
encoding="utf-8",
) as logfile:
log = logfile.read()
except FileNotFoundError:
pass
with contextlib.suppress(FileNotFoundError):
log = Path(CACHE_DIR / "spot_orderbook-2.log").read_text(encoding="utf-8")

with Path(CACHE_DIR / "spot_orderbook.log").open(
mode="a",
Expand Down
6 changes: 3 additions & 3 deletions tests/spot/test_spot_orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_get_first(self) -> None:
Checks the ``get_first`` method.
"""
assert (
float(10)
float(10) # noqa: RUF069
== SpotOrderBookClientWrapper.get_first(("10", "5"))
== SpotOrderBookClientWrapper.get_first((10, 5))
)
Expand Down Expand Up @@ -161,9 +161,9 @@ async def execute_add_book() -> None:
asyncio.run(execute_add_book())

for expected in (
'{"method": "subscribe", "result": {"channel": "book", "depth": 10, '
'{"method": "subscribe", "result": {"channel": "book", "depth": 10, ' # noqa: ISC004
'"snapshot": true, "symbol": "BTC/USD"}, "success": true, "time_in": ',
'{"channel": "book", "type": "snapshot", "data": '
'{"channel": "book", "type": "snapshot", "data": ' # noqa: ISC004
'[{"symbol": "BTC/USD", "bids": ',
):
assert expected in caplog.text
Expand Down
14 changes: 1 addition & 13 deletions tests/spot/test_spot_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def test_truncate_volume(self: Self, spot_trade: Trade) -> None:
different inputs for volume.

NOTE: This test may break in the future since the lot_decimals,
pair_decimals, ordermin and costmin attributes could change.
pair_decimals, ordermin, and costmin attributes could change.
"""
for volume, expected in (
(1, "1.00000000"),
Expand All @@ -326,18 +326,6 @@ def test_truncate_volume(self: Self, spot_trade: Trade) -> None:
)
sleep(3)

for volume, expected in (
(2, "2.00000000"),
(12.158, "12.15800000"),
(13.1052093, "13.10520930"),
(4.32595342455, "4.32595342"),
):
assert (
spot_trade.truncate(amount=volume, amount_type="volume", pair="DOTUSD")
== expected
)
sleep(3)

def test_truncate_fail_price_costmin(self: Self, spot_trade: Trade) -> None:
"""
Checks if the truncate function fails if the price is less than the costmin.
Expand Down
Loading