added average to utils
This commit is contained in:
parent
806b98bc27
commit
01419e5927
@ -21,20 +21,24 @@ class CurrencyPair:
|
|||||||
return CurrencyPair(match.group("base"), match.group("quote"))
|
return CurrencyPair(match.group("base"), match.group("quote"))
|
||||||
|
|
||||||
|
|
||||||
def net_pl_percentage(perc: float, reference_fee_perc: float):
|
def average(a):
|
||||||
return perc - reference_fee_perc
|
return sum(a) / len(a)
|
||||||
|
|
||||||
|
|
||||||
def balance_to_json(balance: Balance):
|
def balance_to_json(balance: Balance):
|
||||||
return {
|
return {
|
||||||
'currency': balance.currency,
|
'currency': balance.currency().name(),
|
||||||
'amount': balance.amount,
|
'amount': balance.currency().amount(),
|
||||||
'kind': balance.kind.value,
|
'kind': balance.wallet().value,
|
||||||
'quote': balance.quote,
|
'quote': balance.quote().value,
|
||||||
'quote_equivalent': balance.quote_equivalent
|
'quote_equivalent': balance.quote_equivalent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def net_pl_percentage(perc: float, reference_fee_perc: float):
|
||||||
|
return perc - reference_fee_perc
|
||||||
|
|
||||||
|
|
||||||
def pw_to_posprop(pw: PositionWrapper):
|
def pw_to_posprop(pw: PositionWrapper):
|
||||||
pair = CurrencyPair.from_str(pw.position.symbol)
|
pair = CurrencyPair.from_str(pw.position.symbol)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user