mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-21 15:54:26 +01:00
Merge bfxapi.rest.types and bfxapi.websocket.types in bfxapi.tests sub-package.
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
# python -c "import examples.websocket.public.derivatives_status"
|
||||
|
||||
from bfxapi import Client, PUB_WSS_HOST
|
||||
from bfxapi.websocket.enums import Error, Channel
|
||||
from bfxapi.websocket.types import DerivativesStatus
|
||||
from bfxapi.types import DerivativesStatus
|
||||
from bfxapi.websocket.subscriptions import Status
|
||||
|
||||
from bfxapi.websocket import subscriptions
|
||||
from bfxapi.websocket.enums import Error, Channel
|
||||
|
||||
bfx = Client(wss_host=PUB_WSS_HOST)
|
||||
|
||||
@bfx.wss.on("derivatives_status_update")
|
||||
def on_derivatives_status_update(subscription: subscriptions.Status, data: DerivativesStatus):
|
||||
def on_derivatives_status_update(subscription: Status, data: DerivativesStatus):
|
||||
print(f"{subscription}:", data)
|
||||
|
||||
@bfx.wss.on("wss-error")
|
||||
|
||||
@@ -6,9 +6,9 @@ from typing import List
|
||||
|
||||
from bfxapi import Client, PUB_WSS_HOST
|
||||
|
||||
from bfxapi.websocket import subscriptions
|
||||
from bfxapi.types import TradingPairBook
|
||||
from bfxapi.websocket.subscriptions import Book
|
||||
from bfxapi.websocket.enums import Channel, Error
|
||||
from bfxapi.websocket.types import TradingPairBook
|
||||
|
||||
class OrderBook:
|
||||
def __init__(self, symbols: List[str]):
|
||||
@@ -54,12 +54,12 @@ def on_subscribed(subscription):
|
||||
print(f"Subscription successful for pair <{subscription['pair']}>")
|
||||
|
||||
@bfx.wss.on("t_book_snapshot")
|
||||
def on_t_book_snapshot(subscription: subscriptions.Book, snapshot: List[TradingPairBook]):
|
||||
def on_t_book_snapshot(subscription: Book, snapshot: List[TradingPairBook]):
|
||||
for data in snapshot:
|
||||
order_book.update(subscription["symbol"], data)
|
||||
|
||||
@bfx.wss.on("t_book_update")
|
||||
def on_t_book_update(subscription: subscriptions.Book, data: TradingPairBook):
|
||||
def on_t_book_update(subscription: Book, data: TradingPairBook):
|
||||
order_book.update(subscription["symbol"], data)
|
||||
|
||||
bfx.wss.run()
|
||||
|
||||
@@ -6,9 +6,9 @@ from typing import List
|
||||
|
||||
from bfxapi import Client, PUB_WSS_HOST
|
||||
|
||||
from bfxapi.websocket import subscriptions
|
||||
from bfxapi.types import TradingPairRawBook
|
||||
from bfxapi.websocket.subscriptions import Book
|
||||
from bfxapi.websocket.enums import Channel, Error
|
||||
from bfxapi.websocket.types import TradingPairRawBook
|
||||
|
||||
class RawOrderBook:
|
||||
def __init__(self, symbols: List[str]):
|
||||
@@ -54,12 +54,12 @@ def on_subscribed(subscription):
|
||||
print(f"Subscription successful for pair <{subscription['pair']}>")
|
||||
|
||||
@bfx.wss.on("t_raw_book_snapshot")
|
||||
def on_t_raw_book_snapshot(subscription: subscriptions.Book, snapshot: List[TradingPairRawBook]):
|
||||
def on_t_raw_book_snapshot(subscription: Book, snapshot: List[TradingPairRawBook]):
|
||||
for data in snapshot:
|
||||
raw_order_book.update(subscription["symbol"], data)
|
||||
|
||||
@bfx.wss.on("t_raw_book_update")
|
||||
def on_t_raw_book_update(subscription: subscriptions.Book, data: TradingPairRawBook):
|
||||
def on_t_raw_book_update(subscription: Book, data: TradingPairRawBook):
|
||||
raw_order_book.update(subscription["symbol"], data)
|
||||
|
||||
bfx.wss.run()
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
from bfxapi import Client, PUB_WSS_HOST
|
||||
|
||||
from bfxapi.websocket import subscriptions
|
||||
from bfxapi.types import TradingPairTicker
|
||||
from bfxapi.websocket.subscriptions import Ticker
|
||||
from bfxapi.websocket.enums import Channel
|
||||
from bfxapi.websocket.types import TradingPairTicker
|
||||
|
||||
bfx = Client(wss_host=PUB_WSS_HOST)
|
||||
|
||||
@bfx.wss.on("t_ticker_update")
|
||||
def on_t_ticker_update(subscription: subscriptions.Ticker, data: TradingPairTicker):
|
||||
def on_t_ticker_update(subscription: Ticker, data: TradingPairTicker):
|
||||
print(f"Subscription with subId: {subscription['subId']}")
|
||||
|
||||
print(f"Data: {data}")
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# python -c "import examples.websocket.public.trades"
|
||||
|
||||
from bfxapi import Client, PUB_WSS_HOST
|
||||
from bfxapi.websocket.enums import Error, Channel
|
||||
from bfxapi.websocket.types import Candle, TradingPairTrade
|
||||
|
||||
from bfxapi.websocket import subscriptions
|
||||
from bfxapi.types import Candle, TradingPairTrade
|
||||
from bfxapi.websocket.subscriptions import Candles, Trades
|
||||
from bfxapi.websocket.enums import Error, Channel
|
||||
|
||||
bfx = Client(wss_host=PUB_WSS_HOST)
|
||||
|
||||
@bfx.wss.on("candles_update")
|
||||
def on_candles_update(_sub: subscriptions.Candles, candle: Candle):
|
||||
def on_candles_update(_sub: Candles, candle: Candle):
|
||||
print(f"New candle: {candle}")
|
||||
|
||||
@bfx.wss.on("t_trade_execution")
|
||||
def on_t_trade_execution(_sub: subscriptions.Trades, trade: TradingPairTrade):
|
||||
def on_t_trade_execution(_sub: Trades, trade: TradingPairTrade):
|
||||
print(f"New trade: {trade}")
|
||||
|
||||
@bfx.wss.on("wss-error")
|
||||
|
||||
Reference in New Issue
Block a user