Add initial balance to template and adjust PL calculation to use initial balance
This commit is contained in:
parent
9a69120695
commit
3f05553c71
|
@ -13,6 +13,7 @@
|
|||
<th>name</th>
|
||||
<th>exchange</th>
|
||||
<th>currency</th>
|
||||
<th>initial</th>
|
||||
<th>API key</th>
|
||||
<th>sandbox</th>
|
||||
<th>enabled</th>
|
||||
|
@ -25,6 +26,7 @@
|
|||
<td>{{ item.name }}</td>
|
||||
<td>{{ item.exchange }}</td>
|
||||
<td>{{ item.currency }}</td>
|
||||
<td>{{ item.initial_balance }}</td>
|
||||
<td>{{ item.api_key }}</td>
|
||||
<td>
|
||||
{% if item.sandbox %}
|
||||
|
|
|
@ -23,6 +23,7 @@ class AccountInfo(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
|
|||
"api_key",
|
||||
"sandbox",
|
||||
"supported_symbols",
|
||||
"initial_balance",
|
||||
# "instruments",
|
||||
]
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from decimal import Decimal as D
|
||||
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from two_factor.views.mixins import OTPRequiredMixin
|
||||
|
||||
|
@ -29,8 +31,8 @@ class Profit(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
|||
details = account.client.get_account()
|
||||
item = {
|
||||
"account": account,
|
||||
"pl": float(details["pl"]),
|
||||
"unrealizedPL": float(details["unrealizedPL"]),
|
||||
"pl": D(account.initial_balance) - D(details["balance"]),
|
||||
"unrealizedPL": D(details["unrealizedPL"]),
|
||||
"balance": details["balance"],
|
||||
"currency": details["currency"],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue