Add controls boilerplate to main page

This commit is contained in:
Mark Veidemanis 2022-11-14 18:29:07 +00:00
parent d2e0137c8d
commit 2aac7d1bb5
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
7 changed files with 405 additions and 4 deletions

View File

@ -202,3 +202,6 @@ class BaseExchange(object):
def get_all_positions(self):
raise NotImplementedError
def close_all_positions(self):
raise NotImplementedError

View File

@ -105,3 +105,13 @@ class OANDAExchange(BaseExchange):
item["unrealized_pl"] = float(item["unrealized_pl"])
items.append(item)
return items
def close_all_positions(self):
# all_positions = self.get_all_positions()
# for position in all_positions["itemlist"]:
# print("POS ITER", position)
r = positions.PositionClose(accountID=self.account_id)
response = self.call(r)
print("CLOSE ALL POSITIONS", response)
return response

View File

@ -4,7 +4,20 @@
{% block outer_content %}
<div class="grid-stack" id="grid-stack-main">
<div class="grid-stack-item" gs-w="7" gs-h="25" gs-y="0" gs-x="1">
<div class="grid-stack-item" gs-w="5" gs-h="14" gs-y="0" gs-x="1">
<div class="grid-stack-item-content">
<nav class="panel">
<p class="panel-heading" style="padding: .2em; line-height: .5em;">
<i class="fa-solid fa-arrows-up-down-left-right has-text-grey-light"></i>
Controls
</p>
<article class="panel-block is-active">
{% include 'window-content/controls.html' %}
</article>
</nav>
</div>
</div>
<div class="grid-stack-item" gs-w="4" gs-h="25" gs-y="0" gs-x="6">
<div class="grid-stack-item-content">
<nav class="panel">
<p class="panel-heading" style="padding: .2em; line-height: .5em;">
@ -17,8 +30,23 @@
</nav>
</div>
</div>
<div class="grid-stack-item" gs-w="5" gs-h="14" gs-y="14" gs-x="1">
<div class="grid-stack-item-content">
<nav class="panel">
<p class="panel-heading" style="padding: .2em; line-height: .5em;">
<i class="fa-solid fa-arrows-up-down-left-right has-text-grey-light"></i>
Offset
</p>
<article class="panel-block is-active">
{% include 'window-content/offset.html' %}
</article>
</nav>
</div>
</div>
</div>
<script>
var grid = GridStack.init({
cellHeight: 20,

View File

@ -0,0 +1,109 @@
<p class="subtitle">Close positions</p>
<div class="columns">
<div class="column">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="#"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to close all positions?"
class="button is-danger is-fullwidth">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>All</span>
</span>
</button>
</div>
<div class="column">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="#"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to close all profitable positions?"
class="button is-success is-fullwidth">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>Winners</span>
</span>
</button>
</div>
<div class="column">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="#"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to close all losing positions?"
class="button is-danger is-fullwidth">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>Losers</span>
</span>
</button>
</div>
</div>
<p class="subtitle">Break even</p>
<div class="columns">
<div class="column">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="#"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish set all the SLs for profitable positions to the entry price, and all the TPs for losing positions to the entry price"
class="button is-info is-fullwidth">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>All</span>
</span>
</button>
</div>
<div class="column">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="#"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish set all the SLs for profitable positions to the entry price?"
class="button is-success is-fullwidth">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>Winners</span>
</span>
</button>
</div>
<div class="column">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="#"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish set all the TPs for losing positions to the entry price?"
class="button is-warning is-fullwidth">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
<span>Losers</span>
</span>
</button>
</div>
</div>

View File

@ -1,5 +1,3 @@
<p class="title">Management panel</p>
<table class="table is-fullwidth is-hoverable">
<thead>
<th>name</th>

View File

@ -33,7 +33,7 @@
class="button is-info">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-plus"></i>
<i class="fa-solid fa-xmark"></i>
</span>
<span>Delete all {{ context_object_name }} </span>
</span>

View File

@ -0,0 +1,253 @@
<table class="table is-fullwidth is-hoverable">
<thead>
<th>-</th>
<th>All</th>
<th>Winners</th>
<th>Losers</th>
</thead>
<tbody>
<tr>
<th>Both</th>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-info is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP and SL for all in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-info is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP and SL for all from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-success is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP and SL for winners in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-success is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP and SL for winners from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-danger is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP and SL for losers in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-danger is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP and SL for losers from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
</tr>
<tr>
<th>TP</th>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-info is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP for all in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-info is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP for all from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-success is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP for winners in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-success is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP for winners from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-danger is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP for losers in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-danger is-small">
<span class="icon-text">
<span class="icon" data-tooltip="TP for losers from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
</tr>
<tr>
<th>SL</th>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-info is-small">
<span class="icon-text">
<span class="icon" data-tooltip="SL for all in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-info is-small">
<span class="icon-text">
<span class="icon" data-tooltip="SL for all from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-success is-small">
<span class="icon-text">
<span class="icon" data-tooltip="SL for winners in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-success is-small">
<span class="icon-text">
<span class="icon" data-tooltip="SL for winners from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-danger is-small">
<span class="icon-text">
<span class="icon" data-tooltip="SL for losers in %">
<i class="fa-solid fa-percent"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#modals-here"
class="button is-danger is-small">
<span class="icon-text">
<span class="icon" data-tooltip="SL for losers from current price in %">
<i class="fa-solid fa-money-bill"></i>
</span>
</span>
</button>
</td>
</tr>
</tbody>
</table>