Skip to content

Commit 8f0f7a0

Browse files
Update project settings (#385)
1 parent 3926dd7 commit 8f0f7a0

25 files changed

+195
-191
lines changed

.github/workflows/_pre_commit.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
2323
with:
2424
disable-sudo: true
25-
egress-policy: block
26-
allowed-endpoints: >
27-
api.github.com:443
28-
files.pythonhosted.org:443
29-
github.com:443
30-
proxy.golang.org:443
31-
pypi.org:443
32-
registry.npmjs.org:443
25+
egress-policy: audit
26+
# allowed-endpoints: >
27+
# api.github.com:443
28+
# files.pythonhosted.org:443
29+
# github.com:443
30+
# proxy.golang.org:443
31+
# pypi.org:443
32+
# registry.npmjs.org:443
3333
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3434
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
3535
with:

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.8.0
10+
rev: v0.12.7
1111
hooks:
1212
- id: ruff
1313
args:
1414
- --preview
1515
- --fix
1616
- --exit-non-zero-on-fix
1717
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v1.13.0
18+
rev: v1.17.1
1919
hooks:
2020
- id: mypy
2121
name: mypy
@@ -26,11 +26,11 @@ repos:
2626
- --install-types
2727
- --non-interactive
2828
- repo: https://github.com/gitleaks/gitleaks
29-
rev: v8.21.2
29+
rev: v8.28.0
3030
hooks:
3131
- id: gitleaks
3232
- repo: https://github.com/codespell-project/codespell
33-
rev: v2.3.0
33+
rev: v2.4.1
3434
hooks:
3535
- id: codespell
3636
additional_dependencies: [tomli]
@@ -67,21 +67,21 @@ repos:
6767
- id: rst-inline-touching-normal
6868
- id: text-unicode-replacement-char
6969
- repo: https://github.com/psf/black
70-
rev: 24.10.0
70+
rev: 25.1.0
7171
hooks:
7272
- id: black
7373
- repo: https://github.com/rbubley/mirrors-prettier
74-
rev: v3.3.3
74+
rev: v3.6.2
7575
hooks:
7676
- id: prettier
7777
- repo: https://github.com/PyCQA/isort # TODO: remove as soon as ruff is stable
78-
rev: 5.13.2
78+
rev: 6.0.1
7979
hooks:
8080
- id: isort
8181
args:
8282
- --profile=black
8383
- repo: https://github.com/PyCQA/bandit
84-
rev: 1.7.10
84+
rev: 1.8.6
8585
hooks:
8686
- id: bandit
8787
exclude: "^tests/.*|examples/.*"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Projects using this SDK:
7171

7272
- https://github.com/btschwertfeger/kraken-infinity-grid
7373
- https://github.com/btschwertfeger/kraken-rebalance-bot
74+
- https://github.com/btschwertfeger/python-kraken-sdk/network/dependents
7475

7576
---
7677

examples/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# python-kraken-sdk usage examples
22

33
This directory contains several examples demonstrating how to use the
4-
`python-kraken-sdk`. These examples cover various functionalities such as spot
5-
trading, futures trading, and market data retrieval using both REST and
4+
`python-kraken-sdk`. These examples cover various functionalities such as Spot
5+
trading, Futures trading, and market data retrieval using both REST and
66
WebSocket APIs.
77

88
Ideal examples of successful running trading algorithms based on the
99
python-kraken-sdk are listed below:
1010

1111
- https://github.com/btschwertfeger/kraken-infinity-grid
1212
- https://github.com/btschwertfeger/kraken-rebalance-bot
13+
- https://github.com/btschwertfeger/python-kraken-sdk/network/dependents
1314

1415
For more detailed and up-to-date usage, refer to the unit tests provided in the
1516
main package.

examples/futures_examples.py

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
#
88

99
"""
10-
Module that implements some example usage for the Kraken Futures REST clients.
11-
12-
This module may not be maintained on a regular basis, so please refer to the
13-
unit tests of this package as they provide a much deeper dive into the usage.
10+
Module that implements *some* examples for the Kraken Futures REST clients
11+
usage.
1412
"""
1513

1614
import logging
@@ -33,22 +31,35 @@
3331

3432

3533
def market_examples() -> None:
36-
"""Example market client usage"""
37-
# market = Market()
38-
# print(market.get_tick_types())
39-
# print(market.get_tradeable_products(tick_type='trade'))
40-
# print(market.get_resolutions(tick_type='trade', tradeable='PI_XBTUSD'))
41-
# print(market.get_ohlc(tick_type='trade', symbol='PI_XBTUSD', resolution='5m', from_='1668989233'))
42-
# print(market.get_fee_schedules())
43-
# # print(market.get_orderbook(symbol='fi_xbtusd_180615')) # this endpoint is broken
44-
# print(market.get_tickers())
45-
# print(market.get_instruments())
46-
# print(market.get_instruments_status())
47-
# print(market.get_instruments_status(instrument='PI_XBTUSD'))
48-
# print(market.get_trade_history(symbol='PI_XBTUSD'))
49-
# print(market.get_historical_funding_rates(symbol='PI_XBTUSD'))
50-
# time.sleep(2)
34+
"""Example Futures Market client usage"""
5135

36+
# Usage of the Market client to access public endpoints:
37+
market = Market()
38+
print(market.get_tick_types())
39+
print(market.get_tradeable_products(tick_type="trade"))
40+
print(market.get_resolutions(tick_type="trade", tradeable="PI_XBTUSD"))
41+
print(
42+
market.get_ohlc(
43+
tick_type="trade",
44+
symbol="PI_XBTUSD",
45+
resolution="5m",
46+
from_="1668989233",
47+
),
48+
)
49+
print(market.get_fee_schedules())
50+
print(
51+
market.get_orderbook(symbol="fi_xbtusd_180615"),
52+
) # might need adjustment of the symbol
53+
print(market.get_tickers())
54+
print(market.get_instruments())
55+
print(market.get_instruments_status())
56+
print(market.get_instruments_status(instrument="PI_XBTUSD"))
57+
print(market.get_trade_history(symbol="PI_XBTUSD"))
58+
print(market.get_historical_funding_rates(symbol="PI_XBTUSD"))
59+
time.sleep(2) # Just to avoid rate limits
60+
61+
# Usage of the Market client to access private endpoints:
62+
# (commented out to avoid accidental usage)
5263
priv_market = Market(key=key, secret=secret, sandbox=True)
5364
# print(priv_market.get_fee_schedules_vol())
5465
print(priv_market.get_leverage_preference())
@@ -66,20 +77,25 @@ def market_examples() -> None:
6677

6778

6879
def user_examples() -> None:
69-
"""Example User client usage"""
80+
"""Example Futures User client usage"""
81+
# NOTE: This only works if you have set valid credentials for the the
82+
# Futures demo environment. Remove the `sandbox=True` argument to use
83+
# the production environment.
84+
#
85+
# Usage of the User client to access private endpoints:
7086
user = User(key=key, secret=secret, sandbox=True)
7187
print(user.get_wallets())
72-
7388
print(user.get_subaccounts())
7489
print(user.get_unwind_queue())
7590
print(user.get_notifications())
76-
7791
print(user.get_open_positions())
7892
print(user.get_open_orders())
7993

94+
# You can retrieve the account log like so:
8095
print(user.get_account_log(before="1604937694000"))
8196
print(user.get_account_log(info="futures liquidation"))
82-
time.sleep(2)
97+
time.sleep(2) # Just to avoid rate limits
98+
8399
response = user.get_account_log_csv()
84100
assert response.status_code in {200, "200"}
85101
with Path("account_log.csv").open("wb") as file:
@@ -89,10 +105,16 @@ def user_examples() -> None:
89105

90106

91107
def trade_examples() -> None:
92-
"""Example Trade client usage"""
93-
raise ValueError(
94-
"Attention: Please check if you really want to execute the trade endpoints!",
108+
"""Example Futures Trade client usage"""
109+
print(
110+
"Attention: Please check if you want to execute the trade endpoints!"
111+
" Check the script manually before running this example.",
95112
)
113+
return
114+
# return
115+
# NOTE: This only works if you have set valid credentials for the the
116+
# Futures demo environment. Remove the `sandbox=True` argument to use
117+
# the production environment.
96118
trade = Trade(key=key, secret=secret, sandbox=True)
97119
print(trade.get_fills())
98120
print(trade.get_fills(lastFillTime="2020-07-21T12:41:52.790Z"))
@@ -171,10 +193,11 @@ def funding_examples() -> None:
171193

172194

173195
def main() -> None:
174-
user_examples()
175-
market_examples()
176-
trade_examples()
177-
funding_examples()
196+
"""Uncomment the examples you want to run:"""
197+
# user_examples()
198+
# market_examples()
199+
# trade_examples()
200+
# funding_examples()
178201

179202

180203
if __name__ == "__main__":

examples/futures_ws_examples.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import asyncio
1616
import logging
17-
import logging.config
1817
import os
1918
import time
2019

0 commit comments

Comments
 (0)