diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 78a7e1d..f923e87 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,7 +8,7 @@ What has being changed - provide code snippets, examples, screenshots, lists - any kind of information hat helps to understand the update. **Make sure to address all topics of the [self-review -checklist](https://github.com/github/docs/blob/main/contributing/self-review.md#self-review).** +checklist](https://github.com/btschwertfeger/python-kraken-sdk/blob/master/.github/self-review.md).** Closes: Don't forget to link an existing issue for your change. If there is no open issue for your change - create one to make it more likely that his update diff --git a/.github/self-review.md b/.github/self-review.md index 492e592..d438760 100644 --- a/.github/self-review.md +++ b/.github/self-review.md @@ -5,30 +5,24 @@ must be addressed before a PR will be accepted. - [ ] **All** pre-commit hooks must run through - successfully. - [ ] Make sure that the changes confirm the coding style of the - [python-kraken-sdk](https://github.com/btschwertfeger/python-kraken-sdk). Most - issues will be resolve through the pre-commit hooks. + [python-kraken-sdk](https://github.com/btschwertfeger/python-kraken-sdk). + Most issues will be resolve through the pre-commit hooks. - [ ] Also take care to follow the community guidelines and the [Code of Conduct](./CODE_OF_CONDUCT.md). - [ ] Self-review your changes to detect typos, syntax errors and any kind of unwanted behavior. - [ ] If you changed the source code you have to **ensure that all unit tests - run through**. If you added a new function you also have to **write a test** - for that. Also make sure to **follow the doc string style** of the package and - **provide at least one working example** within a function doc string. This is - important since doc strings will be reflected within the documentation. + run through**. If you added a new function you also have to **write a + test** for that. Also make sure to **follow the doc string style** of the + package and **provide at least one working example** within a function doc + string. This is important since doc strings will be reflected within the + documentation. - [ ] Take your time to prepare your code before creating a PR. A good PR will save a lot of time for everyone. -- [ ] There are several workflows/actions within this repository. Any relevant - workflow must be run successfully within your fork. In the following these - workflows are listed, but **please also read the respective workflow files to - get further information**. - - PR Manual Pre-Commit (`manual_pre_commit.yaml`): This workflow must be green - in any case. - - PR Manual Build (`manual_build.yaml`): Must be green in any case. - - PR Manual CodeQL (`manual_codeql.yaml`): same here - - PR Manual Test Spot (`manual_test_spot.yaml`): If any Spot related change - happened - - PR Manual Test Futures (`manual_test_futures.yaml`): For any Futures related - changes +- [ ] There are several workflows/actions within this repository. Relevant + workflows must be run successfully within your fork. In the following + these workflows are listed, but **please also read the respective workflow + files to get further information**. Actions must be enabled within the + fork, so that workflows can run within the context of a PR. - CI/CD (`cicd.yaml`): Can be used to run all actions at once - but requires having API keys for Spot, Futures and the Futures demo environment. diff --git a/.github/workflows/manual_build.yaml b/.github/workflows/manual_build.yaml deleted file mode 100644 index 039781a..0000000 --- a/.github/workflows/manual_build.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2023 Benjamin Thomas Schwertfeger -# GitHub: https://github.com/btschwertfeger -# -# NOTE: This workflow is intended to be used manually for example on fork -# branches to validate that the building of the python-kraken-sdk package -# runs through. These is a requirement for a successfully PR. -# - -name: PR Manual Build - -on: - workflow_dispatch: - -permissions: - contents: read - -jobs: - Build: - uses: ./.github/workflows/_build.yaml - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - python-version: ["3.11", "3.12"] - with: - os: ${{ matrix.os }} - python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/manual_codeql.yaml b/.github/workflows/manual_codeql.yaml deleted file mode 100644 index a7ecbf9..0000000 --- a/.github/workflows/manual_codeql.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2023 Benjamin Thomas Schwertfeger -# GitHub: https://github.com/btschwertfeger -# -# NOTE: This workflow is intended to be used manually for example on fork -# branches to validate that the CodeQL action do not finds any issues -# within the code base. -# - -name: PR Manual CodeQL - -on: - workflow_dispatch: - -# Don't change this permissions. These must match those of the analyze job. -permissions: - actions: read - contents: read - security-events: write - -jobs: - CodeQL: - uses: ./.github/workflows/_codeql.yaml diff --git a/.github/workflows/manual_pre_commit.yaml b/.github/workflows/manual_pre_commit.yaml deleted file mode 100644 index 08b2952..0000000 --- a/.github/workflows/manual_pre_commit.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2023 Benjamin Thomas Schwertfeger -# GitHub: https://github.com/btschwertfeger -# -# NOTE: This workflow is intended to be used manually for example on fork -# branches to validate that the pre-commit hooks run through. This ensures -# the coding style and quality of the package and is a requirement for -# every PR. -# - -name: PR Manual Pre-Commit - -on: - workflow_dispatch: - -permissions: - contents: read - -jobs: - Pre-Commit: - uses: ./.github/workflows/_pre_commit.yaml diff --git a/.github/workflows/manual_test_futures.yaml b/.github/workflows/manual_test_futures.yaml deleted file mode 100644 index 3272383..0000000 --- a/.github/workflows/manual_test_futures.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2023 Benjamin Thomas Schwertfeger -# GitJub: https://github.com/btschwertfeger -# -# NOTE: This workflow is intended to be used manually for example on fork -# branches to validate that all Futures REST and websocket unit tests -# run through successfully. -# -# This is required in PR when changes were made that (could) affect -# the Futures related code parts. -# -# To run this action the following secrets must be set in the forked -# repository: -# * FUTURES_API_KEY -# * FUTURES_SECRET_KEY -# * FUTURES_SANDBOX_KEY -# * FUTURES_SANDBOX_SECRET -# -# ... see the README for information about how to generate Futures API -# keys for the live and demo/sandbox environment. Please also make sure -# to set the "Read Only" permission for the live account to not risk any -# funds during testing! The demo account requires full permissions. -# - -name: PR Manual Test Futures - -on: - workflow_dispatch: - -permissions: - contents: read - -jobs: - Test-Futures-Public: - uses: ./.github/workflows/_test_futures_public.yaml - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11", "3.12"] - with: - os: ${{ matrix.os }} - python-version: ${{ matrix.python-version }} - - Test-Futures-Private: - uses: ./.github/workflows/_test_futures_private.yaml - strategy: - max-parallel: 1 # to avoid failing tests because of API Rate limits - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11", "3.12"] - with: - os: ${{ matrix.os }} - python-version: ${{ matrix.python-version }} - secrets: inherit diff --git a/.github/workflows/manual_test_spot.yaml b/.github/workflows/manual_test_spot.yaml deleted file mode 100644 index cafbc90..0000000 --- a/.github/workflows/manual_test_spot.yaml +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2023 Benjamin Thomas Schwertfeger -# GitHub: https://github.com/btschwertfeger -# -# NOTE: This workflow is intended to be used manually for example on fork -# branches to validate that all Spot REST and websocket unit tests -# run through successfully. -# -# This is required in PR when changes were made that (could) affect -# the Spot related code parts. -# -# To run this action the following secrets must be set in the forked -# repository: -# * SPOT_API_KEY -# * SPOT_SECRET_KEY -# -# ... see the README for information about how to generate Spot API keys. -# Please also make sure to enable the following API permissions: -# * Query funds -# * Deposit funds -# * Query open orders & trades -# * Query closed orders & trades -# * Query ledger entries -# * Export data -# * Access WebSockets API -# -# Disable all other permissions since we don't want to create or cancel -# real orders or withdraw funds during testing. These tests are disabled -# by default but having the permissions disabled is the safest way of -# testing. -# - -name: PR Manual Test Spot - -on: - workflow_dispatch: - -permissions: - contents: read - -jobs: - Test-Spot-Public: - uses: ./.github/workflows/_test_spot_public.yaml - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11", "3.12"] - with: - os: ${{ matrix.os }} - python-version: ${{ matrix.python-version }} - - Test-Spot-Private: - uses: ./.github/workflows/_test_spot_private.yaml - strategy: - max-parallel: 1 # to avoid failing tests because of API Rate limits - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11", "3.12"] - with: - os: ${{ matrix.os }} - python-version: ${{ matrix.python-version }} - secrets: inherit diff --git a/CHANGELOG.md b/CHANGELOG.md index f7dd917..b8c578b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,20 @@ # Changelog -## [Unreleased](https://github.com/btschwertfeger/python-kraken-sdk/tree/HEAD) +## [v3.1.0](https://github.com/btschwertfeger/python-kraken-sdk/tree/v3.1.0) (2024-07-31) -[Full Changelog](https://github.com/btschwertfeger/python-kraken-sdk/compare/v3.0.0...HEAD) +[Full Changelog](https://github.com/btschwertfeger/python-kraken-sdk/compare/v3.0.0...v3.1.0) + +**Implemented enhancements:** + +- Add proxy support for futures and spot clients \(async and sync\) [\#257](https://github.com/btschwertfeger/python-kraken-sdk/pull/257) ([Graeme22](https://github.com/Graeme22)) Uncategorized merged pull requests: +- Bump github/codeql-action from 3.25.13 to 3.25.15 [\#260](https://github.com/btschwertfeger/python-kraken-sdk/pull/260) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump ossf/scorecard-action from 2.3.3 to 2.4.0 [\#259](https://github.com/btschwertfeger/python-kraken-sdk/pull/259) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump step-security/harden-runner from 2.8.1 to 2.9.0 [\#255](https://github.com/btschwertfeger/python-kraken-sdk/pull/255) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump github/codeql-action from 3.25.12 to 3.25.13 [\#254](https://github.com/btschwertfeger/python-kraken-sdk/pull/254) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Skip test which requires to be executed from an institutional account [\#253](https://github.com/btschwertfeger/python-kraken-sdk/pull/253) ([btschwertfeger](https://github.com/btschwertfeger)) - Bump actions/dependency-review-action from 4.3.3 to 4.3.4 [\#251](https://github.com/btschwertfeger/python-kraken-sdk/pull/251) ([dependabot[bot]](https://github.com/apps/dependabot)) - Bump github/codeql-action from 3.25.11 to 3.25.12 [\#250](https://github.com/btschwertfeger/python-kraken-sdk/pull/250) ([dependabot[bot]](https://github.com/apps/dependabot)) - Bump actions/setup-python from 5.1.0 to 5.1.1 [\#249](https://github.com/btschwertfeger/python-kraken-sdk/pull/249) ([dependabot[bot]](https://github.com/apps/dependabot)) @@ -14,6 +23,8 @@ Uncategorized merged pull requests: - Bump github/codeql-action from 2.2.4 to 3.25.11 [\#246](https://github.com/btschwertfeger/python-kraken-sdk/pull/246) ([dependabot[bot]](https://github.com/apps/dependabot)) - CI: Change rules for harden-runner job in codeql [\#245](https://github.com/btschwertfeger/python-kraken-sdk/pull/245) ([btschwertfeger](https://github.com/btschwertfeger)) - Bump actions/dependency-review-action from 2.5.1 to 4.3.3 [\#243](https://github.com/btschwertfeger/python-kraken-sdk/pull/243) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Update the CI trigger rules to allow workflow runs on pull requests from outside this repository [\#262](https://github.com/btschwertfeger/python-kraken-sdk/pull/262) ([btschwertfeger](https://github.com/btschwertfeger)) +- Update the CI environment URL [\#258](https://github.com/btschwertfeger/python-kraken-sdk/pull/258) ([btschwertfeger](https://github.com/btschwertfeger)) ## [v3.0.0](https://github.com/btschwertfeger/python-kraken-sdk/tree/v3.0.0) (2024-06-23) diff --git a/tests/spot/test_spot_websocket.py b/tests/spot/test_spot_websocket.py index 37496fe..6efb766 100644 --- a/tests/spot/test_spot_websocket.py +++ b/tests/spot/test_spot_websocket.py @@ -18,6 +18,7 @@ from __future__ import annotations import logging +import re from asyncio import run as asyncio_run from asyncio import sleep as async_sleep from copy import deepcopy @@ -212,7 +213,8 @@ async def create_client() -> None: asyncio_run(create_client()) - assert '{"method": "pong", "req_id": 123456789, "time_in":' in caplog.text + assert '{"method": "pong", "req_id": 123456789' in caplog.text + assert '"success": false' not in caplog.text @pytest.mark.spot() @@ -236,8 +238,9 @@ async def test_subscription() -> None: assert ( '{"method": "subscribe", "req_id": 12345678, "result": {"channel":' ' "ticker", "event_trigger": "trades", "snapshot": true, "symbol":' - ' "BTC/USD"}, "success": true, "time_in":' in caplog.text + ' "BTC/USD"}, "success": true' in caplog.text ) + assert '"success": false' not in caplog.text @pytest.mark.spot() @@ -289,11 +292,11 @@ async def test_subscription() -> None: asyncio_run(test_subscription()) - for phrase in ( - '{"method": "subscribe", "req_id": 123456789, "result": {"channel": "executions", "maxratecount": 180, "snapshot": true,', # for some reason they provide a "warnings" key - '"success": true, "time_in": ', - ): - assert phrase in caplog.text + assert re.search( + r'\{"method": "subscribe", "req_id": 123456789, "result": \{"channel": "executions".*"success": true', + caplog.text, + ) + assert '"success": false' not in caplog.text @pytest.mark.spot() @@ -316,11 +319,12 @@ async def test_unsubscribe() -> None: asyncio_run(test_unsubscribe()) for expected in ( - '{"method": "subscribe", "req_id": 123456789, "result": {"channel": "ticker", "event_trigger": "trades", "snapshot": true, "symbol": "BTC/USD"}, "success": true, "time_in": ', + '{"method": "subscribe", "req_id": 123456789, "result": {"channel": "ticker", "event_trigger": "trades", "snapshot": true, "symbol": "BTC/USD"}, "success": true', '{"channel": "ticker", "type": "snapshot", "data": [{"symbol": "BTC/USD", ', - '{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "ticker", "event_trigger": "trades", "symbol": "BTC/USD"}, "success": true, "time_in": ', + '{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "ticker", "event_trigger": "trades", "symbol": "BTC/USD"}, "success": true', ): assert expected in caplog.text + assert '"success": false' not in caplog.text @pytest.mark.spot() @@ -380,8 +384,8 @@ async def check_unsubscribe() -> None: asyncio_run(check_unsubscribe()) for expected in ( - '{"method": "subscribe", "req_id": 123456789, "result": {"channel": "executions", "maxratecount": 180, "snapshot": true', # , "success": true, "time_in": ', - '{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "executions"}, "success": true, "time_in": ', + '{"method": "subscribe", "req_id": 123456789, "result": {"channel": "executions"', + '{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "executions"}, "success": true', ): assert expected in caplog.text assert '"success": false' not in caplog.text @@ -512,9 +516,15 @@ async def check_reconnect() -> None: "got an exception sent 1000 (OK); then received 1000 (OK)", "Recover public subscriptions [{'channel': 'ticker', 'event_trigger': 'trades', 'snapshot': True, 'symbol': ['BTC/USD']}]: waiting", "Recover public subscriptions [{'channel': 'ticker', 'event_trigger': 'trades', 'snapshot': True, 'symbol': ['BTC/USD']}]: done", - "Recover authenticated subscriptions [{'channel': 'executions', 'snapshot': True}]: waiting", - "Recover authenticated subscriptions [{'channel': 'executions', 'snapshot': True}]: done", ): assert phrase in caplog.text + assert re.search( + r"Recover authenticated subscriptions .*'channel': 'executions'.* waiting", + caplog.text, + ) + assert re.search( + r"Recover authenticated subscriptions .*'channel': 'executions'.* done", + caplog.text, + ) assert '"success": False' not in caplog.text