Skip to content

Commit ef0f49f

Browse files
Let kraken.spot.OrderbookClient use Spot Websocket API v2 (#139)
1 parent 16627d8 commit ef0f49f

15 files changed

Lines changed: 10136 additions & 1305 deletions

File tree

examples/spot_orderbook.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ async def on_book_update(self: Orderbook, pair: str, message: list) -> None:
6666
bid: List[Tuple[str, str]] = list(book["bid"].items())
6767
ask: List[Tuple[str, str]] = list(book["ask"].items())
6868

69-
print("Bid Volume\t\t Ask Volume")
69+
print("Bid Volume\t\t Ask Volume")
7070
for level in range(self.depth):
7171
print(
7272
f"{bid[level][0]} ({bid[level][1][0]}) \t {ask[level][0]} ({ask[level][1][0]})"
7373
)
7474

7575
assert book["valid"] # ensure that the checksum is valid
76+
# … the client will automatically resubscribe to a book feed if the
77+
# checksum is not valid. The user must not do anything for that, but
78+
# will get informed.
7679

7780

7881
async def main() -> None:
@@ -86,10 +89,10 @@ async def main() -> None:
8689
Finally we need some "game loop" - so we create a while loop
8790
that runs as long as there is no error.
8891
"""
89-
orderbook: Orderbook = Orderbook()
92+
orderbook: Orderbook = Orderbook(depth=10)
9093

9194
await orderbook.add_book(
92-
pairs=["XBT/USD"] # we can also subscribe to more currency pairs
95+
pairs=["BTC/USD"] # we can also subscribe to more currency pairs
9396
)
9497

9598
while not orderbook.exception_occur:

kraken/spot/funding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from typing import List, Optional, Union
1212

13-
from ..base_api import KrakenBaseSpotAPI, defined
13+
from kraken.base_api import KrakenBaseSpotAPI, defined
1414

1515

1616
class Funding(KrakenBaseSpotAPI):

kraken/spot/market.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from functools import lru_cache
1212
from typing import List, Optional, Union
1313

14-
from ..base_api import KrakenBaseSpotAPI, defined, ensure_string
14+
from kraken.base_api import KrakenBaseSpotAPI, defined, ensure_string
1515

1616

1717
class Market(KrakenBaseSpotAPI):

0 commit comments

Comments
 (0)