Skip to content

Commit ee028f4

Browse files
Resolve "Stock trade compatibility" (#399)
1 parent 113f376 commit ee028f4

37 files changed

+438
-144
lines changed

.github/workflows/_codecov.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
required: true
2626
SPOT_SECRET_KEY:
2727
required: true
28+
XSTOCKS_API_KEY:
29+
required: true
30+
XSTOCKS_SECRET_KEY:
31+
required: true
2832
FUTURES_API_KEY:
2933
required: true
3034
FUTURES_SECRET_KEY:
@@ -81,6 +85,8 @@ jobs:
8185
env:
8286
SPOT_API_KEY: ${{ secrets.SPOT_API_KEY }}
8387
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
88+
XSTOCKS_API_KEY: ${{ secrets.XSTOCKS_API_KEY }}
89+
XSTOCKS_SECRET_KEY: ${{ secrets.XSTOCKS_SECRET_KEY }}
8490
FUTURES_API_KEY: ${{ secrets.FUTURES_API_KEY }}
8591
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
8692
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}

.github/workflows/_test_spot_private.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
required: true
2828
SPOT_SECRET_KEY:
2929
required: true
30+
XSTOCKS_API_KEY:
31+
required: true
32+
XSTOCKS_SECRET_KEY:
33+
required: true
3034

3135
permissions:
3236
contents: read
@@ -94,6 +98,8 @@ jobs:
9498
env:
9599
SPOT_API_KEY: ${{ secrets.SPOT_API_KEY }}
96100
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
101+
XSTOCKS_API_KEY: ${{ secrets.XSTOCKS_API_KEY }}
102+
XSTOCKS_SECRET_KEY: ${{ secrets.XSTOCKS_SECRET_KEY }}
97103
run: pytest -vv -m "spot and spot_auth and not spot_websocket" tests
98104

99105
- name: Testing Spot websocket client

.github/workflows/cicd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# for Spot:
1818
# * SPOT_API_KEY
1919
# * SPOT_SECRET_KEY
20+
# for xStocks (Kraken UAT):
21+
# * XSTOCKS_API_KEY
22+
# * XSTOCKS_SECRET_KEY
2023
# ... see the README for information about how to generate
2124
# Spot API keys. Please also make sure to enable the
2225
# following API permissions:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ UV ?= uv
1010
PYTHON := python
1111
PYTEST := $(UV) run pytest
1212
PYTEST_OPTS := -vv --junit-xml=pytest.xml
13-
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=kraken --cov-report=xml:coverage.xml --cov-report=term
13+
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=kraken --cov-report=xml:coverage.xml --cov-report=term-missing
1414
TEST_DIR := tests
1515

1616
## ======= M A K E F I L E - T A R G E T S =====================================

README.md

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1 align="center">Futures and Spot REST and Websocket API Python SDK for the Kraken Crypto Asset Exchange 🐙</h1>
1+
<h1 align="center">Spot, xStocks, and Futures REST and Websocket API Python SDK for the Kraken Crypto Asset Exchange 🐙</h1>
22

33
<div align="center">
44

@@ -56,10 +56,10 @@ General:
5656

5757
Available Clients:
5858

59-
- Spot REST Clients (sync and async)
60-
- Spot Websocket Client (using Websocket API v2)
61-
- Spot Orderbook Client (using Websocket API v2)
62-
- Futures REST Clients (sync and async)
59+
- Spot REST Clients - including xStocks capability
60+
- Spot Websocket Client (Websocket API v2)
61+
- Spot Orderbook Client (Websocket API v2)
62+
- Futures REST Clients
6363
- Futures Websocket Client
6464

6565
Documentation:
@@ -91,6 +91,7 @@ new releases.
9191
- [ Installation and setup ](#installation)
9292
- [ Command-line interface ](#cliusage)
9393
- [ Spot Clients ](#spotusage)
94+
- [ xStocks ](#xstocksusage)
9495
- [ Futures Clients ](#futuresusage)
9596
- [ Troubleshooting ](#trouble)
9697
- [ Contributions ](#contribution)
@@ -315,6 +316,57 @@ if __name__ == "__main__":
315316
asyncio.run(main())
316317
```
317318
319+
<a name="xstocksusage"></a>
320+
321+
# 📍 xStocks
322+
323+
Kraken recently added support for trading of tokenized stocks (xStocks) on their
324+
platform. The python-kraken-sdk fully supports this new feature, allowing users
325+
to trade xStocks seamlessly alongside other crypto assets.
326+
327+
For accessing xStocks, you can use the same `SpotClient` and `SpotAsyncClient`
328+
classes that are used for regular spot trading. The endpoints and methods for
329+
xStocks are integrated into these clients, making it easy to manage your xStock
330+
trades.
331+
332+
It is important to note that the xStocks feature is not available globally. Please
333+
check Kraken's documentation to understand the availability zones and ensure
334+
that you can trade xStocks from your location.
335+
336+
For trading or filtering for xStocks assets, the new asset class
337+
`tokenized_asset` must be used, e.g. when creating an order:
338+
339+
```python
340+
from kraken.spot import SpotClient, Trade
341+
342+
# Option 1: Create an order using the SpotClient directly:
343+
client = SpotClient(key="api-public-key", secret="api-secret-key")
344+
client.request(
345+
method="POST",
346+
uri="/0/private/AddOrder",
347+
params={
348+
"type": "buy",
349+
"volume": "1",
350+
"ordertype": "limit",
351+
"pair": "AAPLxUSD",
352+
"price": "100.0",
353+
"validate": True,
354+
"asset_class": "tokenized_asset", # <- important!
355+
},
356+
)
357+
# Option 2: Create an order using the Trade client:
358+
trade = Trade(key="api-public-key", secret="api-secret-key")
359+
trade.create_order(
360+
pair="AAPLxUSD",
361+
side="buy",
362+
ordertype="limit",
363+
volume="1",
364+
price="100.0",
365+
validate=True,
366+
extra_params={"asset_class": "tokenized_asset"}, # <- important!
367+
)
368+
```
369+
318370
<a name="futuresusage"></a>
319371
320372
# 📍 Futures Clients
@@ -475,6 +527,8 @@ if __name__ == "__main__":
475527
keys will result in invalid nonce errors.
476528
- Always keep an eye on https://status.kraken.com/ when encountering
477529
connectivity problems.
530+
- The xStocks feature is not available globally. Please checkout Kraken's
531+
documentation to get to know the availability zones.
478532
479533
---
480534
Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ and documented.
5151
accessed, provided that either the base class or one of the clients has been
5252
initialized with valid credentials.
5353
- For Futures there is the websocket client
54-
:class:`kraken.futures.FuturesWSClient` and for Spot
54+
:class:`kraken.futures.FuturesWSClient` and for Spot and xStocks
5555
:class:`kraken.spot.SpotWSClient`.
5656

5757

58-
Disclaimer
59-
----------
58+
⚠️ Disclaimer
59+
-------------
6060

6161
There is no guarantee that this software will work flawlessly at this or later
6262
times. Of course, no responsibility is taken for possible profits or losses.
@@ -66,8 +66,8 @@ investment. By using this software you release the author(s) from any liability
6666
regarding the use of this software.
6767

6868

69-
Features
70-
--------
69+
🚀 Features
70+
-----------
7171

7272
General:
7373

@@ -80,14 +80,20 @@ General:
8080

8181
Available Clients:
8282

83-
- Spot REST Clients (sync and async)
83+
- Spot REST Clients - including xStocks capability
8484
- Spot Websocket Client (Websocket API v2)
8585
- Spot Orderbook Client (Websocket API v2)
86-
- Futures REST Clients (sync and async)
86+
- Futures REST Clients
8787
- Futures Websocket Client
8888

89-
Important Notice
90-
-----------------
89+
Projects using this SDK:
90+
91+
- https://github.com/btschwertfeger/infinity-grid
92+
- https://github.com/btschwertfeger/kraken-rebalance-bot
93+
- https://github.com/btschwertfeger/python-kraken-sdk/network/dependents
94+
95+
📌 Important Notice
96+
-------------------
9197

9298
**ONLY tagged releases are available at PyPI**. The content of the master branch
9399
may not match with the content of the latest release. - Please have a look at
@@ -99,8 +105,9 @@ on new releases.
99105

100106
.. _section-troubleshooting:
101107

102-
Troubleshooting
103-
---------------
108+
💡 Troubleshooting
109+
------------------
110+
104111
- Check if you downloaded and installed the **latest version** of the
105112
python-kraken-sdk.
106113
- Check the **permissions of your API keys** and the required permissions on the
@@ -114,9 +121,11 @@ Troubleshooting
114121
- Always keep an eye on https://status.kraken.com/ when encountering
115122
connectivity problems.
116123
- Feel free to open an issue at `python-kraken-sdk/issues`_.
124+
- The xStocks feature is not available globally. Please checkout Kraken's
125+
documentation to get to know the availability zones.
117126

118-
References
119-
----------
127+
📜 References
128+
-------------
120129

121130
- https://python-kraken-sdk.readthedocs.io/en/stable
122131
- https://docs.kraken.com/api/
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ Projects that use the SDK are listed below:
3838
.. toctree::
3939
:maxdepth: 2
4040

41-
rest_ws_samples/spot_rest_examples.rst
42-
rest_ws_samples/spot_ws_examples.rst
41+
rest_examples/spot_rest_examples.rst
42+
rest_examples/spot_ws_examples.rst
43+
rest_examples/xstocks_rest_examples.rst
4344
market_client_example.ipynb
44-
rest_ws_samples/futures_ws_examples.rst
45-
rest_ws_samples/futures_rest_examples.rst
45+
rest_examples/futures_ws_examples.rst
46+
rest_examples/futures_rest_examples.rst

doc/examples/rest_ws_samples/futures_rest_examples.rst renamed to doc/03_examples/rest_examples/futures_rest_examples.rst

File renamed without changes.

0 commit comments

Comments
 (0)