Fix price parsing
This commit is contained in:
parent
1f75da40af
commit
48858bf20b
|
@ -86,7 +86,7 @@ class OANDAExchange(BaseExchange):
|
||||||
print("Positions", response)
|
print("Positions", response)
|
||||||
for item in response["itemlist"]:
|
for item in response["itemlist"]:
|
||||||
item["account"] = self.account.name
|
item["account"] = self.account.name
|
||||||
item["account_id"] = self.account_id
|
item["account_id"] = self.account.id
|
||||||
item["unrealized_pl"] = float(item["unrealized_pl"])
|
item["unrealized_pl"] = float(item["unrealized_pl"])
|
||||||
items.append(item)
|
items.append(item)
|
||||||
return (True, items)
|
return (True, items)
|
||||||
|
|
|
@ -104,7 +104,7 @@ get_all_positions_schema = {
|
||||||
{
|
{
|
||||||
"symbol": "symbol",
|
"symbol": "symbol",
|
||||||
"unrealized_pl": "unrealized_pl",
|
"unrealized_pl": "unrealized_pl",
|
||||||
"price:": "current_price",
|
"price": "current_price",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -115,9 +115,26 @@ class OpenPositions(BaseModel):
|
||||||
],
|
],
|
||||||
"lastTransactionID": "73",
|
"lastTransactionID": "73",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def parse_prices(x):
|
||||||
|
if int(x["long"]["units"]) > 0:
|
||||||
|
return x["long"]["averagePrice"]
|
||||||
|
elif int(x["short"]["units"]) > 0:
|
||||||
|
return x["short"]["averagePrice"]
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
OpenPositions_schema = {
|
OpenPositions_schema = {
|
||||||
"itemlist": (
|
"itemlist": (
|
||||||
"positions",
|
"positions",
|
||||||
[{"symbol": "instrument", "unrealized_pl": "unrealizedPL"}],
|
[
|
||||||
|
{
|
||||||
|
"symbol": "instrument",
|
||||||
|
"unrealized_pl": "unrealizedPL",
|
||||||
|
"price": parse_prices,
|
||||||
|
}
|
||||||
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{% include 'partials/notify.html' %}
|
{% include 'partials/notify.html' %}
|
||||||
|
|
||||||
<table class="table is-fullwidth is-hoverable" id="positions-table">
|
<table class="table is-fullwidth is-hoverable" id="positions-table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>account</th>
|
<th>account</th>
|
||||||
|
|
Loading…
Reference in New Issue