Merge pull request #206 from itsdeka/liquidations-rest

implemented liquidations endpoint (rest)
This commit is contained in:
Vigan Abdurrahmani
2022-10-04 16:31:56 +02:00
committed by GitHub
5 changed files with 44 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
2.0.3
-) Implemented Liquidations endpoint (REST)
2.0.2
-) Use private host for auth-based requests

View File

@@ -0,0 +1,21 @@
import os
import sys
import asyncio
import time
sys.path.append('../../../')
from bfxapi import Client, PUB_REST_HOST
bfx = Client(
logLevel='INFO',
rest_host=PUB_REST_HOST
)
now = int(round(time.time() * 1000))
then = now - (1000 * 60 * 60 * 24 * 10) # 10 days ago
async def get_liquidations():
liquidations = await bfx.rest.get_liquidations(start=then, end=now)
print(liquidations)
asyncio.get_event_loop().run_until_complete(get_liquidations())

View File

@@ -219,6 +219,24 @@ class BfxRest:
status = await self.fetch(endpoint)
return status
async def get_liquidations(self, start, end, limit=100, sort=-1):
"""
Endpoint to retrieve liquidations. By default it will retrieve the most recent liquidations,
but time-specific data can be retrieved using timestamps.
# Attributes
@param start int: millisecond start time
@param end int: millisecond end time
@param limit int: max number of items in response (max. 500)
@param sort int: if = 1 it sorts results returned with old > new
@return Array [ POS_ID, MTS, SYMBOL, AMOUNT, BASE_PRICE, IS_MATCH, IS_MARKET_SOLD, PRICE_ACQUIRED ]
"""
endpoint = "liquidations/hist"
params = "?start={}&end={}&limit={}&sort={}".format(
start, end, limit, sort)
liquidations = await self.fetch(endpoint, params=params)
return liquidations
async def get_public_pulse_hist(self, end=None, limit=25):
"""
View the latest pulse messages. You can specify an end timestamp to view older messages.

View File

@@ -2,4 +2,4 @@
This module contains the current version of the bfxapi lib
"""
__version__ = '2.0.2'
__version__ = '2.0.3'

View File

@@ -11,7 +11,7 @@ from os import path
here = path.abspath(path.dirname(__file__))
setup(
name='bitfinex-api-py',
version='2.0.2',
version='2.0.3',
description='Official Bitfinex Python API',
long_description='A Python reference implementation of the Bitfinex API for both REST and websocket interaction',
long_description_content_type='text/markdown',