Skip to content

Commit a788d3a

Browse files
Resolve "Rename kraken.spot.KrakenSpotWSClient to kraken.spot.KrakenSpotWSClientV1" (#160)
1 parent dc82f12 commit a788d3a

13 files changed

Lines changed: 49 additions & 49 deletions

docs/src/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ and documented.
3232
initialized with valid credentials.
3333
- For Futures there is only one websocket client -
3434
:class:`kraken.futures.KrakenFuturesWSClient`. For Spot there are two:
35-
:class:`kraken.spot.KrakenSpotWSClient` (for API version 1) and
35+
:class:`kraken.spot.KrakenSpotWSClientV1` (for API version 1) and
3636
:class:`kraken.spot.KrakenSpotWSClientV2` (for API version 2).
3737

3838

docs/src/spot/websockets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Spot Websockets
1010
:show-inheritance:
1111
:inherited-members:
1212

13-
.. autoclass:: kraken.spot.KrakenSpotWSClient
13+
.. autoclass:: kraken.spot.KrakenSpotWSClientV1
1414
:members:
1515
:show-inheritance:
1616
:inherited-members:

examples/spot_orderbook_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Orderbook(OrderbookClientV1):
4848
This is a wrapper class that is used to overload the :func:`on_book_update`
4949
function. It can also be used as a base for trading strategy. Since the
5050
:class:`kraken.spot.OrderbookClientV1` is derived from
51-
:class:`kraken.spot.KrakenSpotWSClient` it can also be used to access the
51+
:class:`kraken.spot.KrakenSpotWSClientV1` it can also be used to access the
5252
:func:`subscribe` function and any other provided utility.
5353
"""
5454

examples/spot_trading_bot_template_v1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import urllib3
2323

2424
from kraken.exceptions import KrakenException
25-
from kraken.spot import Funding, KrakenSpotWSClient, Market, Staking, Trade, User
25+
from kraken.spot import Funding, KrakenSpotWSClientV1, Market, Staking, Trade, User
2626

2727
logging.basicConfig(
2828
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
@@ -33,7 +33,7 @@
3333
logging.getLogger("urllib3").setLevel(logging.WARNING)
3434

3535

36-
class TradingBot(KrakenSpotWSClient):
36+
class TradingBot(KrakenSpotWSClientV1):
3737
"""
3838
Class that implements the trading strategy
3939
@@ -52,7 +52,7 @@ class TradingBot(KrakenSpotWSClient):
5252
"""
5353

5454
def __init__(self: TradingBot, config: dict) -> None:
55-
super().__init__( # initialize the KrakenSpotWSClient
55+
super().__init__( # initialize the KrakenSpotWSClientV1
5656
key=config["key"],
5757
secret=config["secret"],
5858
)
@@ -160,7 +160,7 @@ async def __main(self: ManagedBot) -> None:
160160
run the loop.
161161
162162
This variable `exception_occur` which is an attribute of the
163-
KrakenSpotWSClient can be set individually but is also being set to
163+
KrakenSpotWSClientV1 can be set individually but is also being set to
164164
`True` if the websocket connection has some fatal error. This is used to
165165
exit the asyncio loop - but you can also apply your own reconnect rules.
166166
"""

examples/spot_trading_bot_template_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def __main(self: ManagedBot) -> None:
167167
loop.
168168
169169
The variable `exception_occur` which is an attribute of the
170-
KrakenSpotWSClient can be set individually but is also being set to
170+
KrakenSpotWSClientV2 can be set individually but is also being set to
171171
`True` if the websocket connection has some fatal error. This is used to
172172
exit the asyncio loop - but you can also apply your own reconnect rules.
173173
"""

examples/spot_ws_examples_v1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from contextlib import suppress
1919
from typing import Union
2020

21-
from kraken.spot import KrakenSpotWSClient
21+
from kraken.spot import KrakenSpotWSClientV1
2222

2323
logging.basicConfig(
2424
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
@@ -35,7 +35,7 @@ async def main() -> None:
3535
key: str = os.getenv("SPOT_API_KEY")
3636
secret: str = os.getenv("SPOT_SECRET_KEY")
3737

38-
class Client(KrakenSpotWSClient):
38+
class Client(KrakenSpotWSClientV1):
3939
"""Can be used to create a custom trading strategy"""
4040

4141
async def on_message(self: Client, message: Union[list, dict]) -> None:
@@ -107,14 +107,14 @@ async def on_message(self: Client, message: Union[list, dict]) -> None:
107107
# ============================================================
108108
# Alternative - as ContextManager:
109109

110-
# from kraken.spot import KrakenSpotWSClient
110+
# from kraken.spot import KrakenSpotWSClientV1
111111
# import asyncio
112112

113113
# async def on_message(msg):
114114
# print(msg)
115115

116116
# async def main() -> None:
117-
# async with KrakenSpotWSClient(callback=on_message) as session:
117+
# async with KrakenSpotWSClientV1(callback=on_message) as session:
118118
# await session.subscribe(subscription={"name": "ticker"}, pair=["XBT/USD"])
119119

120120
# while True:

kraken/spot/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from kraken.spot.staking import Staking
1414
from kraken.spot.trade import Trade
1515
from kraken.spot.user import User
16-
from kraken.spot.websocket_v1 import KrakenSpotWSClient
16+
from kraken.spot.websocket_v1 import KrakenSpotWSClientV1
1717
from kraken.spot.websocket_v2 import KrakenSpotWSClientV2
1818

1919
__all__ = [
@@ -24,6 +24,6 @@
2424
"User",
2525
"OrderbookClientV1",
2626
"OrderbookClientV2",
27-
"KrakenSpotWSClient",
27+
"KrakenSpotWSClientV1",
2828
"KrakenSpotWSClientV2",
2929
]

kraken/spot/orderbook_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from inspect import iscoroutinefunction
1616
from typing import Callable, Optional
1717

18-
from kraken.spot.websocket_v1 import KrakenSpotWSClient
18+
from kraken.spot.websocket_v1 import KrakenSpotWSClientV1
1919

2020

2121
class OrderbookClientV1:
@@ -123,7 +123,7 @@ def __init__(
123123
self.__depth: int = depth
124124
self.__callback: Optional[Callable] = callback
125125

126-
self.ws_client: KrakenSpotWSClient = KrakenSpotWSClient(
126+
self.ws_client: KrakenSpotWSClientV1 = KrakenSpotWSClientV1(
127127
callback=self.on_message,
128128
)
129129

kraken/spot/websocket/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class KrakenSpotWSClientBase(KrakenSpotBaseAPI):
2626
"""
27-
This is the base class for :class:`kraken.spot.KrakenSpotWSClient` and
27+
This is the base class for :class:`kraken.spot.KrakenSpotWSClientV1` and
2828
:class:`kraken.spot.KrakenSpotWSClientV2`. It extends the REST API base
2929
class and is used to provide the base functionalities that are used
3030
for Kraken Websocket API v1 and v2.
@@ -138,7 +138,7 @@ async def on_message(
138138
have to overwrite this function since it will receive all incoming
139139
messages that will be sent by Kraken.
140140
141-
See :class:`kraken.spot.KrakenSpotWSClient` and
141+
See :class:`kraken.spot.KrakenSpotWSClientV1` and
142142
:class:`kraken.spot.KrakenSpotWSClientV2` for examples to use this
143143
function.
144144

kraken/spot/websocket_v1.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from kraken.spot.websocket import KrakenSpotWSClientBase
2323

2424

25-
class KrakenSpotWSClient(KrakenSpotWSClientBase):
25+
class KrakenSpotWSClientV1(KrakenSpotWSClientBase):
2626
"""
2727
Class to access public and private/authenticated websocket connections.
2828
@@ -61,10 +61,10 @@ class KrakenSpotWSClient(KrakenSpotWSClientBase):
6161
:caption: HowTo: Use the Kraken Spot websocket client (v1)
6262
6363
import asyncio
64-
from kraken.spot import KrakenSpotWSClient
64+
from kraken.spot import KrakenSpotWSClientV1
6565
6666
67-
class Client(KrakenSpotWSClient):
67+
class Client(KrakenSpotWSClientV1):
6868
6969
async def on_message(self, message):
7070
print(message)
@@ -99,14 +99,14 @@ async def main():
9999
:caption: HowTo: Use the websocket client (v1) as instance
100100
101101
import asyncio
102-
from kraken.spot import KrakenSpotWSClient
102+
from kraken.spot import KrakenSpotWSClientV1
103103
104104
105105
async def main() -> None:
106106
async def on_message(message) -> None:
107107
print(message)
108108
109-
client = KrakenSpotWSClient(callback=on_message)
109+
client = KrakenSpotWSClientV1(callback=on_message)
110110
await client.subscribe(
111111
subscription={"name": "ticker"},
112112
pair=["XBT/USD"]
@@ -128,13 +128,13 @@ async def on_message(message) -> None:
128128
:caption: HowTo: Use the websocket client (v1) as context manager
129129
130130
import asyncio
131-
from kraken.spot import KrakenSpotWSClient
131+
from kraken.spot import KrakenSpotWSClientV1
132132
133133
async def on_message(message):
134134
print(message)
135135
136136
async def main() -> None:
137-
async with KrakenSpotWSClient(
137+
async with KrakenSpotWSClientV1(
138138
key="api-key",
139139
secret="secret-key",
140140
callback=on_message
@@ -156,7 +156,7 @@ async def main() -> None:
156156
"""
157157

158158
def __init__(
159-
self: KrakenSpotWSClient,
159+
self: KrakenSpotWSClientV1,
160160
key: str = "",
161161
secret: str = "",
162162
callback: Optional[Callable] = None,
@@ -174,7 +174,7 @@ def __init__(
174174
)
175175

176176
async def send_message( # pylint: disable=arguments-differ
177-
self: KrakenSpotWSClient,
177+
self: KrakenSpotWSClientV1,
178178
message: dict,
179179
*,
180180
private: bool = False,
@@ -215,7 +215,7 @@ async def send_message( # pylint: disable=arguments-differ
215215
await socket.send(json.dumps(message))
216216

217217
async def subscribe( # pylint: disable=arguments-differ
218-
self: KrakenSpotWSClient,
218+
self: KrakenSpotWSClientV1,
219219
subscription: dict,
220220
pair: Optional[list[str]] = None,
221221
) -> None:
@@ -237,7 +237,7 @@ async def subscribe( # pylint: disable=arguments-differ
237237
:type pair: list[str], optional
238238
239239
Initialize your client as described in
240-
:class:`kraken.spot.KrakenSpotWSClient` to run the following example:
240+
:class:`kraken.spot.KrakenSpotWSClientV1` to run the following example:
241241
242242
.. code-block:: python
243243
:linenos:
@@ -287,7 +287,7 @@ async def subscribe( # pylint: disable=arguments-differ
287287
# await self.send_message(payload, private=False)
288288

289289
async def unsubscribe( # pylint: disable=arguments-differ
290-
self: KrakenSpotWSClient,
290+
self: KrakenSpotWSClientV1,
291291
subscription: dict,
292292
pair: Optional[list[str]] = None,
293293
) -> None:
@@ -309,7 +309,7 @@ async def unsubscribe( # pylint: disable=arguments-differ
309309
:type pair: list[str], optional
310310
311311
Initialize your client as described in
312-
:class:`kraken.spot.KrakenSpotWSClient` to run the following example:
312+
:class:`kraken.spot.KrakenSpotWSClientV1` to run the following example:
313313
314314
.. code-block:: python
315315
:linenos:
@@ -359,7 +359,7 @@ async def unsubscribe( # pylint: disable=arguments-differ
359359
# await self.send_message(payload, private=False)
360360

361361
@property
362-
def public_channel_names(self: KrakenSpotWSClient) -> list[str]:
362+
def public_channel_names(self: KrakenSpotWSClientV1) -> list[str]:
363363
"""
364364
Returns the public subscription names
365365
@@ -370,7 +370,7 @@ def public_channel_names(self: KrakenSpotWSClient) -> list[str]:
370370
return ["ticker", "spread", "book", "ohlc", "trade", "*"]
371371

372372
@property
373-
def private_channel_names(self: KrakenSpotWSClient) -> list[str]:
373+
def private_channel_names(self: KrakenSpotWSClientV1) -> list[str]:
374374
"""
375375
Returns the private subscription names
376376
@@ -382,7 +382,7 @@ def private_channel_names(self: KrakenSpotWSClient) -> list[str]:
382382

383383
@ensure_string("oflags")
384384
async def create_order( # noqa: PLR0913
385-
self: KrakenSpotWSClient,
385+
self: KrakenSpotWSClientV1,
386386
ordertype: str,
387387
side: str,
388388
pair: str,
@@ -473,7 +473,7 @@ async def create_order( # noqa: PLR0913
473473
:rtype: None
474474
475475
Initialize your client as described in
476-
:class:`kraken.spot.KrakenSpotWSClient` to run the following example:
476+
:class:`kraken.spot.KrakenSpotWSClientV1` to run the following example:
477477
478478
.. code-block:: python
479479
:linenos:
@@ -549,7 +549,7 @@ async def create_order( # noqa: PLR0913
549549

550550
@ensure_string("oflags")
551551
async def edit_order( # noqa: PLR0913
552-
self: KrakenSpotWSClient,
552+
self: KrakenSpotWSClientV1,
553553
orderid: str,
554554
reqid: Optional[str | int] = None,
555555
pair: Optional[str] = None,
@@ -600,7 +600,7 @@ async def edit_order( # noqa: PLR0913
600600
:rtype: None
601601
602602
Initialize your client as described in
603-
:class:`kraken.spot.KrakenSpotWSClient` to run the following example:
603+
:class:`kraken.spot.KrakenSpotWSClientV1` to run the following example:
604604
605605
.. code-block:: python
606606
:linenos:
@@ -648,7 +648,7 @@ async def edit_order( # noqa: PLR0913
648648

649649
await self.send_message(message=payload, private=True)
650650

651-
async def cancel_order(self: KrakenSpotWSClient, txid: list[str]) -> None:
651+
async def cancel_order(self: KrakenSpotWSClientV1, txid: list[str]) -> None:
652652
"""
653653
Cancel a specific order or a list of orders.
654654
@@ -664,7 +664,7 @@ async def cancel_order(self: KrakenSpotWSClient, txid: list[str]) -> None:
664664
:return: None
665665
666666
Initialize your client as described in
667-
:class:`kraken.spot.KrakenSpotWSClient` to run the following example:
667+
:class:`kraken.spot.KrakenSpotWSClientV1` to run the following example:
668668
669669
.. code-block:: python
670670
:linenos:
@@ -681,7 +681,7 @@ async def cancel_order(self: KrakenSpotWSClient, txid: list[str]) -> None:
681681
private=True,
682682
)
683683

684-
async def cancel_all_orders(self: KrakenSpotWSClient) -> None:
684+
async def cancel_all_orders(self: KrakenSpotWSClientV1) -> None:
685685
"""
686686
Cancel all open Spot orders.
687687
@@ -695,7 +695,7 @@ async def cancel_all_orders(self: KrakenSpotWSClient) -> None:
695695
:return: None
696696
697697
Initialize your client as described in
698-
:class:`kraken.spot.KrakenSpotWSClient` to run the following example:
698+
:class:`kraken.spot.KrakenSpotWSClientV1` to run the following example:
699699
700700
.. code-block:: python
701701
:linenos:
@@ -710,7 +710,7 @@ async def cancel_all_orders(self: KrakenSpotWSClient) -> None:
710710
await self.send_message(message={"event": "cancelAll"}, private=True)
711711

712712
async def cancel_all_orders_after(
713-
self: KrakenSpotWSClient,
713+
self: KrakenSpotWSClientV1,
714714
timeout: int = 0,
715715
) -> None:
716716
"""
@@ -729,7 +729,7 @@ async def cancel_all_orders_after(
729729
:return: None
730730
731731
Initialize your client as described in
732-
:class:`kraken.spot.KrakenSpotWSClient` to run the following example:
732+
:class:`kraken.spot.KrakenSpotWSClientV1` to run the following example:
733733
734734
.. code-block:: python
735735
:linenos:
@@ -747,4 +747,4 @@ async def cancel_all_orders_after(
747747
)
748748

749749

750-
__all__ = ["KrakenSpotWSClient"]
750+
__all__ = ["KrakenSpotWSClientV1"]

0 commit comments

Comments
 (0)