Adjusted get_trades() to allow symbol to be None and get trades for all symbols

This commit is contained in:
itsdeka
2021-12-13 13:15:56 +01:00
parent 24e135201e
commit ddf0c14cec
5 changed files with 8 additions and 5 deletions

View File

@@ -1,3 +1,6 @@
1.3.0
-) Adjusted get_trades() to allow symbol to be None and get trades for all symbols
1.2.8 1.2.8
-) Bugfix - It is possible to call bfx.ws.run() from an already running event loop -) Bugfix - It is possible to call bfx.ws.run() from an already running event loop

View File

@@ -39,7 +39,7 @@ async def log_active_positions():
[ print (p) for p in positions ] [ print (p) for p in positions ]
async def log_trades(): async def log_trades():
trades = await bfx.rest.get_trades('tBTCUSD', 0, then) trades = await bfx.rest.get_trades(symbol='tBTCUSD', start=0, end=then)
print ("Trades:") print ("Trades:")
[ print (t) for t in trades] [ print (t) for t in trades]

View File

@@ -465,7 +465,7 @@ class BfxRest:
raw_trades = await self.post(endpoint) raw_trades = await self.post(endpoint)
return [Trade.from_raw_rest_trade(rt) for rt in raw_trades] return [Trade.from_raw_rest_trade(rt) for rt in raw_trades]
async def get_trades(self, symbol, start, end, limit=25): async def get_trades(self, start, end, symbol=None, limit=25):
""" """
Get all of the trades between the start and end period associated with API_KEY Get all of the trades between the start and end period associated with API_KEY
- Requires authentication. - Requires authentication.
@@ -477,7 +477,7 @@ class BfxRest:
@param limit int: max number of items in response @param limit int: max number of items in response
@return Array <models.Trade> @return Array <models.Trade>
""" """
endpoint = "auth/r/trades/{}/hist".format(symbol) endpoint = "auth/r/trades/{}/hist".format(symbol) if symbol else "auth/r/trades/hist"
params = "?start={}&end={}&limit={}".format(start, end, limit) params = "?start={}&end={}&limit={}".format(start, end, limit)
raw_trades = await self.post(endpoint, params=params) raw_trades = await self.post(endpoint, params=params)
return [Trade.from_raw_rest_trade(rt) for rt in raw_trades] return [Trade.from_raw_rest_trade(rt) for rt in raw_trades]

View File

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

View File

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