Implement strategies and posting trades

This commit is contained in:
2022-10-27 18:08:40 +01:00
parent 7e4f3f52d1
commit 061c6f6ca7
32 changed files with 1060 additions and 178 deletions

View File

@@ -6,6 +6,7 @@
<th>user</th>
<th>name</th>
<th>hook</th>
<th>direction</th>
<th>received hooks</th>
<th>actions</th>
</thead>
@@ -15,6 +16,7 @@
<td>{{ item.user }}</td>
<td>{{ item.name }}</td>
<td><code>{{settings.URL}}/{{settings.HOOK_PATH}}/{{ item.hook }}/</code></td>
<td>{{ item.direction }}</td>
<td>{{ item.received }}</td>
<td>
<div class="buttons">
@@ -43,7 +45,7 @@
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'callbacks' type=type hook_id=item.id %}"><button
<a href="{% url 'callbacks' type='page' hook_id=item.id %}"><button
class="button is-success">
<span class="icon-text">
<span class="icon">

View File

@@ -27,7 +27,7 @@
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#trade-edit"
hx-get="#"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-info">
@@ -50,7 +50,7 @@
</span>
</button>
{% if type == 'page' %}
<a href="#trade-info">
<a href="{% url 'position_action' type=type account_id=item.account_id asset_id=item.asset_id %}">
<button
class="button is-success">
<span class="icon-text">
@@ -63,7 +63,7 @@
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#trade-info"
hx-get="{% url 'position_action' type=type account_id=item.account_id asset_id=item.asset_id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-success">

View File

@@ -0,0 +1,88 @@
{% include 'partials/notify.html' %}
<table class="table is-fullwidth is-hoverable" id="strategies-table">
<thead>
<th>id</th>
<th>name</th>
<th>description</th>
<th>account</th>
<th>enabled</th>
<th>TP</th>
<th>SL</th>
<th>actions</th>
</thead>
{% for item in items %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
<td>{{ item.description }}</td>
<td>{{ item.account }}</td>
<td>
{% if item.enabled %}
<span class="icon">
<i class="fa-solid fa-check"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
<td>{{ item.take_profit_percent }}</td>
<td>{{ item.stop_loss_percent }}</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'strategies_action' type=type strategy_id=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-info">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'strategies_action' type=type strategy_id=item.id %}"
hx-trigger="click"
hx-target="#strategies-table"
class="button is-danger">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-trash"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'strategies_action' type=type strategy_id=item.id %}"><button
class="button is-success">
<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 'strategies_action' type=type strategy_id=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-success">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table>

View File

@@ -3,6 +3,7 @@
<table class="table is-fullwidth is-hoverable" id="trades-table">
<thead>
<th>id</th>
<th>status</th>
<th>account id</th>
<th>symbol</th>
<th>type</th>
@@ -15,6 +16,7 @@
{% for item in items %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.status }}</td>
<td>{{ item.account.id }}</td>
<td>{{ item.symbol }}</td>
<td>{{ item.type }}</td>