From 6c6d85ba789190b5b77a2d8f8e3d23959e488c6e Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Sat, 19 Dec 2020 10:53:55 +0000 Subject: [PATCH] added get_balance_delta function in wrapper --- bfxbot/bfxwrapper.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bfxbot/bfxwrapper.py b/bfxbot/bfxwrapper.py index d58d1f6..1f1d373 100644 --- a/bfxbot/bfxwrapper.py +++ b/bfxbot/bfxwrapper.py @@ -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])