extracted pos_to_json

This commit is contained in:
Giulio De Pasquale 2020-12-16 11:28:48 +00:00
parent a20a06b3fe
commit 780aae0fb1

View File

@ -1,6 +1,20 @@
from bfxbot.models import PositionWrapper
TAKER_FEE = 0.2 TAKER_FEE = 0.2
MAKER_FEE = 0.1 MAKER_FEE = 0.1
def net_pl_percentage(perc: float, reference_fee_perc: float): def net_pl_percentage(perc: float, reference_fee_perc: float):
return perc - reference_fee_perc 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()
}