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
2 changes: 1 addition & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ coverage:
comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false # if false: post the comment even if coverage doesn't change
require_changes: true # if false: post the comment even if coverage doesn't change
require_base: no # [yes :: must have a base report to post]
require_head: yes # [yes :: must have a head report to post]
2 changes: 1 addition & 1 deletion .github/workflows/_codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
run: pytest -vv --cov --cov-report=xml:coverage.xml tests
run: pytest -vv --cov=kraken --cov-report=xml:coverage.xml --cov-report=term tests

- name: Export coverage report
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ UV ?= uv
PYTHON := python
PYTEST := $(UV) run pytest
PYTEST_OPTS := -vv --junit-xml=pytest.xml
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov --cov-report=xml:coverage.xml --cov-report=term
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=kraken --cov-report=xml:coverage.xml --cov-report=term
TEST_DIR := tests

## ======= M A K E F I L E - T A R G E T S =====================================
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,6 @@ longer be extended, but maintained to a certain degree.
- https://python-kraken-sdk.readthedocs.io/en/stable
- https://docs.kraken.com/api/
- https://docs.kraken.com/api/docs/guides/global-intro
- https://docs.kraken.com/rest
- https://docs.kraken.com/websockets-v2
- https://docs.futures.kraken.com
- https://support.kraken.com/hc/en-us/sections/360012894412-Futures-API

---
2 changes: 1 addition & 1 deletion doc/getting_started/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Getting Started

2. Register at Kraken and generate API Keys

- Spot Trading: https://www.kraken.com/u/security/api
- Spot Trading: https://pro.kraken.com/app/settings/api
- Futures Trading: https://futures.kraken.com/trade/settings/api
- Futures Sandbox: https://demo-futures.kraken.com/settings/api

Expand Down
3 changes: 0 additions & 3 deletions doc/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,4 @@ References
- https://python-kraken-sdk.readthedocs.io/en/stable
- https://docs.kraken.com/api/
- https://docs.kraken.com/api/docs/guides/global-intro
- https://docs.kraken.com/rest
- https://docs.kraken.com/websockets-v2
- https://docs.futures.kraken.com
- https://support.kraken.com/hc/en-us/sections/360012894412-Futures-API
2 changes: 1 addition & 1 deletion doc/issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Futures Trading
``order_id`` or ``orderId``, ``cliOrdId`` seems to work in all cases.
- Kraken's API doesn't seem to know the ``trailing_stop`` order type and raises
an error if this type is part of an order. This order type is documented here
https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-send-order
https://docs.kraken.com/api/docs/futures-api/trading/send-order

.. code-block:: python
:linenos:
Expand Down
1 change: 0 additions & 1 deletion src/kraken/exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ class MaxReconnectError(Exception):
"""To many reconnect tries."""


# https://docs.kraken.com/rest/#section/General-Usage/Requests-Responses-and-Errors
EXCEPTION_ASSIGNMENT: dict[str, Any] = {
# Spot, Margin, and Futures trading Errors
#
Expand Down
9 changes: 5 additions & 4 deletions src/kraken/futures/funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_historical_funding_rates(
Retrieve information about the historical funding rates of a specific
``symbol``

- https://docs.futures.kraken.com/#http-api-trading-v3-api-historical-funding-rates-historicalfundingrates
- https://docs.kraken.com/api/docs/futures-api/trading/historical-funding-rates

:param symbol: The futures symbol to filter for
:type symbol: str
Expand Down Expand Up @@ -129,7 +129,7 @@ def initiate_wallet_transfer(
Requires the ``General API - Full Access`` and ``Withdrawal API - Full
access`` permissions in the API key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-wallet-transfer
- https://docs.kraken.com/api/docs/futures-api/trading/transfer

:param amount: The volume to transfer
:type amount: str | float
Expand Down Expand Up @@ -187,7 +187,7 @@ def initiate_subaccount_transfer(
Requires the ``General API - Full Access`` and ``Withdrawal API - Full
access`` permissions in the API key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-sub-account-transfer
- https://docs.kraken.com/api/docs/futures-api/trading/sub-account-transfer

:param amount: The volume to transfer
:type amount: str | float
Expand Down Expand Up @@ -215,6 +215,7 @@ def initiate_subaccount_transfer(
... unit='XBT'
... ))
"""

return self.request( # type: ignore[return-value]
method="POST",
uri="/derivatives/api/v3/transfer/subaccount",
Expand Down Expand Up @@ -244,7 +245,7 @@ def initiate_withdrawal_to_spot_wallet(
Requires the ``General API - Full Access`` and ``Withdrawal API - Full
access`` permissions in the API key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-withdrawal-to-spot-wallet
- https://docs.kraken.com/api/docs/futures-api/trading/withdrawal

:param amount: The volume to transfer
:type amount: str | float
Expand Down
57 changes: 20 additions & 37 deletions src/kraken/futures/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def get_ohlc(
Retrieve the open, high, low, and close data for a specific symbol and
resolution. It is also possible to filter by time.

- https://docs.futures.kraken.com/#http-api-charts-ohlc-get-ohlc
- https://support.kraken.com/hc/en-us/articles/4403284627220-OHLC
- https://docs.kraken.com/api/docs/futures-api/charts/candles

:param tick_type: The kind of data, based on ``mark``, ``spot``, or
``trade``
Expand Down Expand Up @@ -154,7 +153,7 @@ def get_tick_types(
Retrieve the available tick types that can be used for example to access
the :func:`kraken.futures.Market.get_ohlc` endpoint.

- https://docs.futures.kraken.com/#http-api-charts-ohlc-get-tick-types
- https://docs.kraken.com/api/docs/futures-api/charts/tick-types

This function uses caching. Run ``get_tick_types.cache_clear()`` to
clear.
Expand Down Expand Up @@ -188,7 +187,7 @@ def get_tradeable_products(
"""
Retrieve a list containing the tradeable assets on the futures market.

- https://docs.futures.kraken.com/#http-api-charts-ohlc-get-tradeable-products
- https://docs.kraken.com/api/docs/futures-api/charts/symbols

This function uses caching. Run ``get_tradeable_products.cache_clear()``
to clear.
Expand Down Expand Up @@ -226,7 +225,7 @@ def get_resolutions(
"""
Retrieve the list of available resolutions for a specific asset.

- https://docs.futures.kraken.com/#http-api-charts-ohlc-get-resolutions
- https://docs.kraken.com/api/docs/futures-api/charts/resolutions

This function uses caching. Run ``get_resolutions.cache_clear()`` to
clear.
Expand Down Expand Up @@ -264,9 +263,9 @@ def get_fee_schedules(
"""
Retrieve information about the current fees

- https://docs.futures.kraken.com/#http-api-trading-v3-api-fee-schedules-get-fee-schedules
- https://docs.kraken.com/api/docs/futures-api/trading/get-fee-schedules-v-3

- https://support.kraken.com/hc/en-us/articles/360049269572-Fee-Schedules
- https://www.kraken.com/features/fee-schedule

This function uses caching. Run ``get_fee_schedules.cache_clear()`` to
clear.
Expand Down Expand Up @@ -316,7 +315,7 @@ def get_fee_schedules_vol(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-fee-schedules-get-fee-schedule-volumes
- https://docs.kraken.com/api/docs/futures-api/trading/get-user-fee-schedule-volumes-v-3

.. code-block:: python
:linenos:
Expand Down Expand Up @@ -354,9 +353,7 @@ def get_orderbook(
recommended to use the ``symbol`` parameter until they don't fix this
issue.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-orderbook

- https://support.kraken.com/hc/en-us/articles/360022839551-Order-Book
- https://docs.kraken.com/api/docs/futures-api/trading/get-orderbook

:param symbol: The asset/symbol to get the orderbook from
:type symbol: str, optional
Expand Down Expand Up @@ -408,9 +405,7 @@ def get_tickers(
"""
Retrieve information about the current tickers of all futures contracts.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-tickers

- https://support.kraken.com/hc/en-us/articles/360022839531-Tickers
- https://docs.kraken.com/api/docs/futures-api/trading/get-tickers

:return: The current tickers
:rtype: dict
Expand Down Expand Up @@ -462,9 +457,7 @@ def get_instruments(
Retrieve more specific information about the tradeable assets on the
Futures market

- https://docs.futures.kraken.com/#http-api-trading-v3-api-instrument-details-get-instruments

- https://support.kraken.com/hc/en-us/articles/360022635672-Instruments
- https://docs.kraken.com/api/docs/futures-api/trading/get-instruments

:return: Dictionary containing information for all tradeable assets
:rtype: dict
Expand Down Expand Up @@ -552,9 +545,7 @@ def get_instruments_status(
"""
Retrieve status information of a specific or all futures contracts.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-instrument-details-get-instrument-status-list

- https://docs.futures.kraken.com/#http-api-trading-v3-api-instrument-details-get-instrument-status
- https://docs.kraken.com/api/docs/futures-api/trading/instrument-status

:param instrument: Filter by asset
:type instrument: str | None, optional
Expand Down Expand Up @@ -600,9 +591,7 @@ def get_trade_history(
Retrieve the trade history (max 100 entries), can be filtered using the
parameters.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-trade-history

- https://support.kraken.com/hc/en-us/articles/360022839511-History
- https://docs.kraken.com/api/docs/futures-api/trading/get-history

:param symbol: The asset to filter for
:type symbol: str, optional
Expand Down Expand Up @@ -659,7 +648,7 @@ def get_historical_funding_rates(
Retrieve information about the historical funding rates for a specific
asset.

- https://support.kraken.com/hc/en-us/articles/360061979852-Historical-Funding-Rates
- https://docs.kraken.com/api/docs/futures-api/trading/historical-funding-rates

:param symbol: The symbol/asset/futures contract
:type symbol: str
Expand Down Expand Up @@ -708,7 +697,7 @@ def get_leverage_preference(
Requires at least the ``General API - Read Only`` permission in the API
key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-get-the-leverage-setting-for-a-market
- https://docs.kraken.com/api/docs/futures-api/trading/get-leverage-setting

:return: The leverage preferences for all futures contracts
:rtype: dict
Expand Down Expand Up @@ -747,7 +736,7 @@ def set_leverage_preference(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-set-the-leverage-setting-for-a-market
- https://docs.kraken.com/api/docs/futures-api/trading/set-leverage-setting

:param symbol: The symbol to set the preference
:type symbol: str, optional
Expand Down Expand Up @@ -789,7 +778,7 @@ def get_pnl_preference(
Requires at least the ``General API - Read Only`` permission in the API
key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-get-pnl-currency-preference-for-a-market
- https://docs.kraken.com/api/docs/futures-api/trading/get-pnl-currency-preference

:return: The current NPL preferences
:rtype: dict
Expand Down Expand Up @@ -825,7 +814,7 @@ def set_pnl_preference(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-set-pnl-currency-preference-for-a-market
- https://docs.kraken.com/api/docs/futures-api/trading/set-pnl-currency-preference

:param symbol: The asset pair or futures contract
:type symbol: str
Expand Down Expand Up @@ -919,9 +908,7 @@ def get_public_execution_events(
Retrieve information about the public execution events. The returned
``continuation_token`` can be used to request more data.

- https://docs.futures.kraken.com/#http-api-history-market-history-get-public-execution-events

- https://support.kraken.com/hc/en-us/articles/4401755685268-Market-History-Executions
- https://docs.kraken.com/api/docs/futures-api/history/get-public-execution-events

:param tradeable: The contract to filter for
:type tradeable: str
Expand Down Expand Up @@ -1014,9 +1001,7 @@ def get_public_order_events(
opened, etc, for a specific contract.The returned ``continuation_token``
can be used to request more data.

- https://docs.futures.kraken.com/#http-api-history-market-history-get-public-order-events

- https://support.kraken.com/hc/en-us/articles/4401755906452-Market-History-Orders
- https://docs.kraken.com/api/docs/futures-api/history/get-public-order-events

:param tradeable: The contract to filter for
:type tradeable: str
Expand Down Expand Up @@ -1089,9 +1074,7 @@ def get_public_mark_price_events(
Retrieve information about public mark price events. The returned
``continuation_token`` can be used to request more data.

- https://docs.futures.kraken.com/#http-api-history-market-history-get-public-mark-price-events

- https://support.kraken.com/hc/en-us/articles/4401748276116-Market-History-Mark-Price
- https://docs.kraken.com/api/docs/futures-api/history/get-public-price-events

:param tradeable: The contract to filter for
:type tradeable: str
Expand Down
18 changes: 9 additions & 9 deletions src/kraken/futures/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_fills(
Requires at least the ``General API - Read Only`` permission in the API
key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-historical-data-get-your-fills
- https://docs.kraken.com/api/docs/futures-api/trading/get-fills

:param lastFillTime: Filter by last filled timestamp
:type lastFillTime: str, optional
Expand Down Expand Up @@ -133,7 +133,7 @@ def create_batch_order(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-batch-order-management
- https://docs.kraken.com/api/docs/futures-api/trading/send-batch-order

:param batchorder_list: List of order instructions (see example below -
or the linked official Kraken documentation)
Expand Down Expand Up @@ -254,7 +254,7 @@ def cancel_all_orders(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-cancel-all-orders
- https://docs.kraken.com/api/docs/futures-api/trading/cancel-all-orders

:param symbol: Filter by symbol
:type symbol: str, optional
Expand Down Expand Up @@ -312,7 +312,7 @@ def dead_mans_switch(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-dead-man-39-s-switch
- https://docs.kraken.com/api/docs/futures-api/trading/cancel-all-orders-after

:param timeout: The timeout in seconds
:type timeout: int, optional
Expand Down Expand Up @@ -357,7 +357,7 @@ def cancel_order(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-cancel-order
- https://docs.kraken.com/api/docs/futures-api/trading/cancel-order

:param order_id: The order_id to cancel
:type order_id: str, optional
Expand Down Expand Up @@ -421,7 +421,7 @@ def edit_order(
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-send-order
- https://docs.kraken.com/api/docs/futures-api/trading/edit-order-spring

:param orderId: The order id to cancel
:type orderId: str, optional
Expand Down Expand Up @@ -496,7 +496,7 @@ def get_orders_status(
Requires at least the ``General API - Read Only`` permission in the API
key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-get-specific-orders-39-status
- https://docs.kraken.com/api/docs/futures-api/trading/get-order-status

:param orderIds: The order ids to cancel
:type orderIds: str | list[str], optional
Expand Down Expand Up @@ -555,7 +555,7 @@ def create_order( # pylint: disable=too-many-arguments # noqa: PLR0913,PLR0917,
Requires the ``General API - Full Access`` permission in the API key
settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-send-order
- https://docs.kraken.com/api/docs/futures-api/trading/send-order

:param orderType: The order type, one of ``lmt``, ``post``, ``ioc``,
``mkt``, ``stp``, ``take_profit``, ``trailing_stop``
Expand Down Expand Up @@ -771,7 +771,7 @@ def get_max_order_size(
Requires at least the ``General API - Read Access`` permission in the
API key settings.

- https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-get-maximum-order-size
- https://docs.kraken.com/api/docs/futures-api/trading/get-max-order-size

:param orderType: ``lmt`` or ``mkt``
:type orderType: str
Expand Down
Loading