added get_balance_delta function in wrapper

This commit is contained in:
Giulio De Pasquale 2020-12-19 10:53:55 +00:00
parent fd54ae2ca2
commit 6c6d85ba78

View File

@ -26,6 +26,13 @@ class BfxWrapper(BfxRest):
return await super().get_active_orders(symbol)
@retry()
async def get_trades(self, symbol, start, end):
if isinstance(symbol, Symbol):
symbol = str(symbol)
return await super().get_trades(symbol, start, end)
async def get_current_prices(self, symbol) -> (float, float, float):
if isinstance(symbol, Symbol):
symbol = str(symbol)
@ -51,3 +58,8 @@ class BfxWrapper(BfxRest):
balance += current_price * w.balance
return balance
async def get_balance_delta(self, symbol: Symbol, start: float, end: float):
trades = await self.get_trades(symbol, start, end)
return sum([t.amount for t in trades])