Skip to content

Commit

Permalink
add logs for pairs with liquidations
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLep committed May 2, 2022
1 parent ddf867d commit aedd90f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions strategies/cryptofeed_strategy/cryptofeed_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ def loop(self) -> None:
"sell": sum([round(data.quantity * data.price, 2) for data in sells])
}

if self.computed_liquidations[exchange][timeframe][pair]['buy'] > 0 \
or self.computed_liquidations[exchange][timeframe][pair]['sell'] > 0:
logging.info(f"[{timeframe} sec - BUY] Liquidations: {exchange} - {pair} - "
f"${self.computed_liquidations[exchange][timeframe][pair]['buy']}")
logging.info(f"[{timeframe} sec - SELL] Liquidations: {exchange} - {pair} - "
f"${self.computed_liquidations[exchange][timeframe][pair]['sell']}")

# Put your custom logic here
# ...

Expand Down Expand Up @@ -127,8 +134,10 @@ def get_liquidations(self, exchanges: List[str] = None, symbols: List[str] = Non
liquidations))

if side is not None:
liquidations = list(filter(lambda data: data.side == "sell" if side is CryptofeedSideEnum.SELL else "buy",
liquidations))
liquidations = list(
filter(lambda data: data.side == "sell" if side is CryptofeedSideEnum.SELL else data.side == "buy",
liquidations)
)

if max_age > -1:
liquidations = list(filter(lambda data: data.timestamp > time.time() - max_age, liquidations))
Expand Down

0 comments on commit aedd90f

Please sign in to comment.