mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
add rest examples
This commit is contained in:
@@ -190,10 +190,10 @@ class _RestPublicEndpoints(_Requests):
|
||||
data = self._GET(f"candles/{resource}/last", params=params)
|
||||
return serializers.Candle.parse(*data)
|
||||
|
||||
def get_derivatives_status(self, type: str, keys: List[str]) -> List[DerivativesStatus]:
|
||||
params = { "keys": ",".join(keys) }
|
||||
def get_derivatives_status(self, symbols: Union[List[str], Literal["ALL"]]) -> List[DerivativesStatus]:
|
||||
params = { "keys": ",".join(symbols) if type(symbols) == List else "ALL" }
|
||||
|
||||
data = self._GET(f"status/{type}", params=params)
|
||||
data = self._GET(f"status/deriv", params=params)
|
||||
|
||||
return [ serializers.DerivativesStatus.parse(*subdata) for subdata in data ]
|
||||
|
||||
|
||||
14
examples/rest/get_liquidations.py
Normal file
14
examples/rest/get_liquidations.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# python -c "from examples.rest.get_liquidations import *"
|
||||
|
||||
import time
|
||||
|
||||
from bfxapi.client import Client, Constants
|
||||
|
||||
bfx = Client(
|
||||
REST_HOST=Constants.REST_HOST
|
||||
)
|
||||
|
||||
now = int(round(time.time() * 1000))
|
||||
|
||||
liquidations = bfx.rest.public.get_liquidations(start=0, end=now)
|
||||
print(f"Liquidations: {liquidations}")
|
||||
52
examples/rest/get_public_data.py
Normal file
52
examples/rest/get_public_data.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# python -c "from examples.rest.get_public_data import *"
|
||||
|
||||
import time
|
||||
|
||||
from bfxapi.client import Client, Constants
|
||||
|
||||
bfx = Client(
|
||||
REST_HOST=Constants.REST_HOST
|
||||
)
|
||||
|
||||
now = int(round(time.time() * 1000))
|
||||
|
||||
|
||||
def log_historical_candles():
|
||||
candles = bfx.rest.public.get_candles_hist(start=0, end=now, resource='trade:1m:tBTCUSD')
|
||||
print("Candles:")
|
||||
[print(c) for c in candles]
|
||||
|
||||
|
||||
def log_historical_trades():
|
||||
trades = bfx.rest.public.get_t_trades(pair='tBTCUSD', start=0, end=now)
|
||||
print("Trades:")
|
||||
[print(t) for t in trades]
|
||||
|
||||
|
||||
def log_books():
|
||||
orders = bfx.rest.public.get_t_book(pair='BTCUSD', precision='P0')
|
||||
print("Order book:")
|
||||
[print(o) for o in orders]
|
||||
|
||||
|
||||
def log_tickers():
|
||||
tickers = bfx.rest.public.get_t_tickers(pairs=['BTCUSD'])
|
||||
print("Tickers:")
|
||||
print(tickers)
|
||||
|
||||
|
||||
def log_derivative_status():
|
||||
status = bfx.rest.public.get_derivatives_status('ALL')
|
||||
print("Deriv status:")
|
||||
print(status)
|
||||
|
||||
|
||||
def run():
|
||||
log_historical_candles()
|
||||
log_historical_trades()
|
||||
log_books()
|
||||
log_tickers()
|
||||
log_derivative_status()
|
||||
|
||||
|
||||
run()
|
||||
Reference in New Issue
Block a user