mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 22:34:21 +01:00
52 lines
1.0 KiB
Python
52 lines
1.0 KiB
Python
# python -c "import examples.rest.get_public_data"
|
|
|
|
import time
|
|
|
|
from bfxapi.client import Client, REST_HOST
|
|
|
|
bfx = Client(
|
|
REST_HOST=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() |