diff --git a/CHANGELOG b/CHANGELOG index 8563409..c874132 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2.0.3 +-) Implemented Liquidations endpoint (REST) + 2.0.2 -) Use private host for auth-based requests diff --git a/bfxapi/examples/rest/get_liquidations.py b/bfxapi/examples/rest/get_liquidations.py new file mode 100644 index 0000000..f7dd896 --- /dev/null +++ b/bfxapi/examples/rest/get_liquidations.py @@ -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()) diff --git a/bfxapi/rest/bfx_rest.py b/bfxapi/rest/bfx_rest.py index b276f13..fabd4f9 100644 --- a/bfxapi/rest/bfx_rest.py +++ b/bfxapi/rest/bfx_rest.py @@ -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. diff --git a/bfxapi/version.py b/bfxapi/version.py index 2b350b7..42f2fa1 100644 --- a/bfxapi/version.py +++ b/bfxapi/version.py @@ -2,4 +2,4 @@ This module contains the current version of the bfxapi lib """ -__version__ = '2.0.2' +__version__ = '2.0.3' diff --git a/setup.py b/setup.py index a5c1f42..126d5c1 100644 --- a/setup.py +++ b/setup.py @@ -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',