2023-02-11 14:52:00 +00:00
|
|
|
{% load cache %}
|
2023-02-10 20:49:35 +00:00
|
|
|
{% include 'mixins/partials/notify.html' %}
|
2023-02-15 07:20:53 +00:00
|
|
|
{% cache 600 objects_positions request.user.id object_list type %}
|
2023-02-11 14:52:00 +00:00
|
|
|
<table
|
|
|
|
class="table is-fullwidth is-hoverable"
|
|
|
|
hx-target="#{{ context_object_name }}-table"
|
|
|
|
id="{{ context_object_name }}-table"
|
|
|
|
hx-swap="outerHTML"
|
|
|
|
hx-trigger="{{ context_object_name_singular }}Event from:body, every 5s"
|
|
|
|
hx-get="{{ list_url }}">
|
|
|
|
<thead>
|
|
|
|
<th>account</th>
|
|
|
|
<th>asset</th>
|
|
|
|
<th>price</th>
|
|
|
|
<th>units</th>
|
|
|
|
<th>quote</th>
|
|
|
|
<th>P/L</th>
|
|
|
|
<th>side</th>
|
|
|
|
<th>trades</th>
|
|
|
|
<th>actions</th>
|
|
|
|
</thead>
|
|
|
|
{% for item in object_list %}
|
|
|
|
<tr class="
|
|
|
|
{% if item.unrealized_pl > 0 %}has-background-success-light
|
|
|
|
{% elif item.unrealized_pl < 0 %}has-background-danger-light
|
|
|
|
{% endif %}">
|
|
|
|
<td>{{ item.account }}</td>
|
|
|
|
<td>{{ item.symbol }}</td>
|
|
|
|
<td>{{ item.price }}</td>
|
|
|
|
<td>{{ item.units }}</td>
|
|
|
|
<td>{{ item.value }}</td>
|
|
|
|
<td>{{ item.unrealized_pl }}</td>
|
|
|
|
<td>
|
|
|
|
{% if item.side == 'long' %}
|
|
|
|
<span class="icon has-text-success" data-tooltip="long">
|
|
|
|
<i class="fa-solid fa-up"></i>
|
2022-10-17 06:20:30 +00:00
|
|
|
</span>
|
2023-02-11 14:52:00 +00:00
|
|
|
{% elif item.side == 'short' %}
|
|
|
|
<span class="icon has-text-danger" data-tooltip="short">
|
|
|
|
<i class="fa-solid fa-down"></i>
|
2022-10-17 06:20:30 +00:00
|
|
|
</span>
|
2023-02-11 14:52:00 +00:00
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
<td>{{ item.trade_ids|length }}</td>
|
|
|
|
<td>
|
|
|
|
<div class="buttons">
|
|
|
|
<!-- <button
|
|
|
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
|
|
|
hx-get="#"
|
|
|
|
hx-trigger="click"
|
|
|
|
hx-target="#{{ type }}s-here"
|
|
|
|
class="button">
|
|
|
|
<span class="icon-text">
|
|
|
|
<span class="icon">
|
|
|
|
<i class="fa-solid fa-pencil"></i>
|
2022-10-17 06:20:30 +00:00
|
|
|
</span>
|
2023-02-11 14:52:00 +00:00
|
|
|
</span>
|
|
|
|
</button> -->
|
2022-10-17 06:20:30 +00:00
|
|
|
<button
|
|
|
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
2023-02-11 14:52:00 +00:00
|
|
|
hx-delete="{% url 'position_action' side=item.side account_id=item.account_id symbol=item.symbol %}"
|
2022-10-17 06:20:30 +00:00
|
|
|
hx-trigger="click"
|
2023-02-11 14:52:00 +00:00
|
|
|
hx-target="#notification"
|
|
|
|
hx-swap="outerHTML"
|
|
|
|
hx-confirm="Are you sure you wish to close {{ item.symbol }}?"
|
2022-12-08 07:20:46 +00:00
|
|
|
class="button">
|
2022-10-17 06:20:30 +00:00
|
|
|
<span class="icon-text">
|
|
|
|
<span class="icon">
|
2023-02-11 14:52:00 +00:00
|
|
|
<i class="fa-solid fa-xmark"></i>
|
2022-10-17 06:20:30 +00:00
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</button>
|
2023-02-11 14:52:00 +00:00
|
|
|
{% if type == 'page' %}
|
|
|
|
<a href="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}">
|
|
|
|
<button
|
|
|
|
class="button">
|
|
|
|
<span class="icon-text">
|
|
|
|
<span class="icon">
|
|
|
|
<i class="fa-solid fa-eye"></i>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</a>
|
|
|
|
{% else %}
|
|
|
|
<button
|
|
|
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
|
|
|
hx-get="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}"
|
|
|
|
hx-trigger="click"
|
|
|
|
hx-target="#{{ type }}s-here"
|
|
|
|
hx-swap="innerHTML"
|
|
|
|
class="button">
|
|
|
|
<span class="icon-text">
|
|
|
|
<span class="icon">
|
|
|
|
<i class="fa-solid fa-eye"></i>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
2022-10-17 06:20:30 +00:00
|
|
|
|
2023-02-11 14:52:00 +00:00
|
|
|
</table>
|
|
|
|
{% endcache %}
|