mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
Merge bfxapi.rest.types and bfxapi.websocket.types in bfxapi.tests sub-package.
This commit is contained in:
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
|
||||
from bfxapi.rest.types import Notification, PositionClaim
|
||||
from bfxapi.types import Notification, PositionClaim
|
||||
|
||||
bfx = Client(
|
||||
rest_host=REST_HOST,
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
import os
|
||||
|
||||
from typing import List
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
|
||||
from bfxapi.rest.types import List, Wallet, Transfer, \
|
||||
DepositAddress, LightningNetworkInvoice, Withdrawal, \
|
||||
Notification
|
||||
from bfxapi.types import Wallet, Transfer, DepositAddress, \
|
||||
LightningNetworkInvoice, Withdrawal, Notification
|
||||
|
||||
bfx = Client(
|
||||
rest_host=REST_HOST,
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
|
||||
from bfxapi.rest.types import DerivativePositionCollateral, DerivativePositionCollateralLimits
|
||||
from bfxapi.types import DerivativePositionCollateral, DerivativePositionCollateralLimits
|
||||
|
||||
bfx = Client(
|
||||
rest_host=REST_HOST,
|
||||
@@ -3,8 +3,8 @@
|
||||
import os
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
from bfxapi.types import Notification, FundingOffer
|
||||
from bfxapi.enums import FundingOfferType, Flag
|
||||
from bfxapi.rest.types import Notification, FundingOffer
|
||||
|
||||
bfx = Client(
|
||||
rest_host=REST_HOST,
|
||||
@@ -3,8 +3,8 @@
|
||||
import os
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
from bfxapi.types import Notification, Order
|
||||
from bfxapi.enums import OrderType, Flag
|
||||
from bfxapi.rest.types import Notification, Order
|
||||
|
||||
bfx = Client(
|
||||
rest_host=REST_HOST,
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
import os
|
||||
|
||||
from typing import List
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
|
||||
from bfxapi.rest.types import List, FundingLoan, Notification
|
||||
from bfxapi.types import FundingLoan, Notification
|
||||
|
||||
bfx = Client(
|
||||
rest_host=REST_HOST,
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
|
||||
from bfxapi.rest.types import InvoiceSubmission
|
||||
from bfxapi.types import InvoiceSubmission
|
||||
|
||||
bfx = Client(
|
||||
rest_host=REST_HOST,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# python -c "import examples.rest.public.book"
|
||||
|
||||
from typing import List
|
||||
|
||||
from bfxapi import Client, PUB_REST_HOST
|
||||
|
||||
from bfxapi.rest.types import List, TradingPairBook, TradingPairRawBook, \
|
||||
from bfxapi.types import TradingPairBook, TradingPairRawBook, \
|
||||
FundingCurrencyBook, FundingCurrencyRawBook
|
||||
|
||||
bfx = Client(rest_host=PUB_REST_HOST)
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
import datetime
|
||||
|
||||
from typing import List
|
||||
|
||||
from bfxapi import Client, PUB_REST_HOST
|
||||
|
||||
from bfxapi.rest.types import List, PulseMessage, PulseProfile
|
||||
from bfxapi.types import PulseMessage, PulseProfile
|
||||
|
||||
bfx = Client(rest_host=PUB_REST_HOST)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from bfxapi import Client, PUB_REST_HOST
|
||||
|
||||
from bfxapi.rest.types import TradingMarketAveragePrice, FundingMarketAveragePrice, FxRate
|
||||
from bfxapi.types import TradingMarketAveragePrice, FundingMarketAveragePrice, FxRate
|
||||
|
||||
bfx = Client(rest_host=PUB_REST_HOST)
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# python -c "import examples.rest.public.trades"
|
||||
|
||||
from typing import List
|
||||
|
||||
from bfxapi import Client, PUB_REST_HOST
|
||||
from bfxapi.types import TradingPairTrade, FundingCurrencyTrade
|
||||
from bfxapi.rest.enums import Sort
|
||||
from bfxapi.rest.types import List, TradingPairTrade, FundingCurrencyTrade
|
||||
|
||||
bfx = Client(rest_host=PUB_REST_HOST)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
from bfxapi import Client, WSS_HOST
|
||||
from bfxapi.enums import Error, OrderType
|
||||
from bfxapi.websocket.types import Notification, Order
|
||||
from bfxapi.types import Notification, Order
|
||||
|
||||
bfx = Client(
|
||||
wss_host=WSS_HOST,
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
from bfxapi import Client
|
||||
from bfxapi.enums import Error
|
||||
from bfxapi.websocket.types import List, Wallet
|
||||
from bfxapi.types import List, Wallet
|
||||
|
||||
bfx = Client(
|
||||
api_key=os.getenv("BFX_API_KEY"),
|
||||
@@ -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