add rest examples

This commit is contained in:
itsdeka
2023-01-15 23:19:09 +01:00
parent 35cc360e37
commit e9ef39c1d6
3 changed files with 69 additions and 3 deletions

View 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}")

View 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()