Change positions fields
This commit is contained in:
parent
8ee56b0e37
commit
396d838416
|
@ -16,9 +16,9 @@
|
||||||
{% if item.unrealized_pl > 0 %}has-background-success-light
|
{% if item.unrealized_pl > 0 %}has-background-success-light
|
||||||
{% elif item.unrealized_pl < 0 %}has-background-danger-light
|
{% elif item.unrealized_pl < 0 %}has-background-danger-light
|
||||||
{% endif %}">
|
{% endif %}">
|
||||||
<td>{{ item.account_id }}</td>
|
<td>{{ item.account }}</td>
|
||||||
<td>{{ item.symbol }}</td>
|
<td>{{ item.symbol }}</td>
|
||||||
<td>{{ item.current_price }}</td>
|
<td>{{ item.price }}</td>
|
||||||
<td>{{ item.qty }}</td>
|
<td>{{ item.qty }}</td>
|
||||||
<td>{{ item.market_value }}</td>
|
<td>{{ item.market_value }}</td>
|
||||||
<td>{{ item.unrealized_pl }}</td>
|
<td>{{ item.unrealized_pl }}</td>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{% if type == 'page' %}
|
{% if type == 'page' %}
|
||||||
<a href="{% url 'position_action' type=type account_id=item.account_id asset_id=item.asset_id %}">
|
<a href="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}">
|
||||||
<button
|
<button
|
||||||
class="button is-success">
|
class="button is-success">
|
||||||
<span class="icon-text">
|
<span class="icon-text">
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<button
|
<button
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
hx-get="{% url 'position_action' type=type account_id=item.account_id asset_id=item.asset_id %}"
|
hx-get="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}"
|
||||||
hx-trigger="click"
|
hx-trigger="click"
|
||||||
hx-target="#{{ type }}s-here"
|
hx-target="#{{ type }}s-here"
|
||||||
hx-swap="innerHTML"
|
hx-swap="innerHTML"
|
||||||
|
|
|
@ -21,6 +21,8 @@ def get_positions(user, account_id=None):
|
||||||
if not success:
|
if not success:
|
||||||
items.append({"name": account.name, "status": "error"})
|
items.append({"name": account.name, "status": "error"})
|
||||||
continue
|
continue
|
||||||
|
for position in positions:
|
||||||
|
position["account"] = account.name
|
||||||
|
|
||||||
for item in positions:
|
for item in positions:
|
||||||
items.append(item)
|
items.append(item)
|
||||||
|
@ -40,6 +42,7 @@ class Positions(LoginRequiredMixin, View):
|
||||||
template_name = f"wm/{type}.html"
|
template_name = f"wm/{type}.html"
|
||||||
unique = str(uuid.uuid4())[:8]
|
unique = str(uuid.uuid4())[:8]
|
||||||
items = get_positions(request.user, account_id)
|
items = get_positions(request.user, account_id)
|
||||||
|
print("ITEMS", items)
|
||||||
if type == "page":
|
if type == "page":
|
||||||
type = "modal"
|
type = "modal"
|
||||||
context = {
|
context = {
|
||||||
|
@ -60,7 +63,7 @@ class PositionAction(LoginRequiredMixin, View):
|
||||||
window_content = "window-content/view-position.html"
|
window_content = "window-content/view-position.html"
|
||||||
parser_classes = [FormParser]
|
parser_classes = [FormParser]
|
||||||
|
|
||||||
async def get(self, request, type, account_id, asset_id):
|
async def get(self, request, type, account_id, symbol):
|
||||||
"""
|
"""
|
||||||
Get live information for a trade.
|
Get live information for a trade.
|
||||||
"""
|
"""
|
||||||
|
@ -70,7 +73,8 @@ class PositionAction(LoginRequiredMixin, View):
|
||||||
unique = str(uuid.uuid4())[:8]
|
unique = str(uuid.uuid4())[:8]
|
||||||
|
|
||||||
account = Account.get_by_id(account_id, request.user)
|
account = Account.get_by_id(account_id, request.user)
|
||||||
success, info = account.client.get_position_info(asset_id)
|
success, info = account.client.get_position_info(symbol)
|
||||||
|
print("ACCT INFO", info)
|
||||||
if not success:
|
if not success:
|
||||||
message = "Position does not exist"
|
message = "Position does not exist"
|
||||||
message_class = "danger"
|
message_class = "danger"
|
||||||
|
|
Loading…
Reference in New Issue