Fix off by one issue in OANDA
This commit is contained in:
parent
f240c4b381
commit
f7242f4dd8
|
@ -82,7 +82,7 @@ def parse_side(x):
|
||||||
return "unknown"
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
def parse_trade_ids(x, sum=-1):
|
def parse_trade_ids(x, sum=0):
|
||||||
if float(x["long"]["units"]) > 0:
|
if float(x["long"]["units"]) > 0:
|
||||||
return [str(int(y) + sum) for y in x["long"]["tradeIDs"]]
|
return [str(int(y) + sum) for y in x["long"]["tradeIDs"]]
|
||||||
elif float(x["short"]["units"]) < 0:
|
elif float(x["short"]["units"]) < 0:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<th>quote</th>
|
<th>quote</th>
|
||||||
<th>P/L</th>
|
<th>P/L</th>
|
||||||
<th>side</th>
|
<th>side</th>
|
||||||
<th>stored</th>
|
<th>trades</th>
|
||||||
<th>actions</th>
|
<th>actions</th>
|
||||||
</thead>
|
</thead>
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ item.trades|length }}</td>
|
<td>{{ item.trade_ids|length }}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{% include 'partials/notify.html' %}
|
{% include 'partials/notify.html' %}
|
||||||
<h1 class="title">Live information</h1>
|
<h1 class="title">Live information</h1>
|
||||||
{{ valid_trade_ids }}
|
|
||||||
<table class="table is-fullwidth is-hoverable">
|
<table class="table is-fullwidth is-hoverable">
|
||||||
<thead>
|
<thead>
|
||||||
<th>attribute</th>
|
<th>attribute</th>
|
||||||
|
|
|
@ -39,6 +39,9 @@ class TradeAction(LoginRequiredMixin, OTPRequiredMixin, View):
|
||||||
return HttpResponseBadRequest("Trade not found.")
|
return HttpResponseBadRequest("Trade not found.")
|
||||||
if db_info.order_id is not None:
|
if db_info.order_id is not None:
|
||||||
try:
|
try:
|
||||||
|
if db_info.order_id == db_info.response["id"]:
|
||||||
|
db_info.order_id = str(int(db_info.order_id) + 1)
|
||||||
|
db_info.save()
|
||||||
live_info = db_info.account.client.get_trade(db_info.order_id)
|
live_info = db_info.account.client.get_trade(db_info.order_id)
|
||||||
except GenericAPIError as e:
|
except GenericAPIError as e:
|
||||||
live_info = {"error": e}
|
live_info = {"error": e}
|
||||||
|
|
Loading…
Reference in New Issue