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