diff --git a/bfxbot/utils.py b/bfxbot/utils.py index e0b3285..a25cb9b 100644 --- a/bfxbot/utils.py +++ b/bfxbot/utils.py @@ -1,6 +1,20 @@ +from bfxbot.models import PositionWrapper + TAKER_FEE = 0.2 MAKER_FEE = 0.1 def net_pl_percentage(perc: float, reference_fee_perc: float): return perc - reference_fee_perc + + +def pos_to_json(pw: PositionWrapper): + return { + "id": pw.position.id, + "amount": pw.position.amount, + "base_price": pw.position.base_price, + "state": str(pw.state()), + "symbol": pw.position.symbol, + "profit_loss": pw.net_profit_loss(), + "profit_loss_percentage": pw.net_profit_loss_percentage() + }