Compare commits
No commits in common. "d319769fe086f94183626d1d7615df380647ee73" and "1f75da40afff6996abc97e6db23b2563d243ce0d" have entirely different histories.
d319769fe0
...
1f75da40af
@ -86,7 +86,7 @@ class OANDAExchange(BaseExchange):
|
||||
print("Positions", response)
|
||||
for item in response["itemlist"]:
|
||||
item["account"] = self.account.name
|
||||
item["account_id"] = self.account.id
|
||||
item["account_id"] = self.account_id
|
||||
item["unrealized_pl"] = float(item["unrealized_pl"])
|
||||
items.append(item)
|
||||
return (True, items)
|
||||
|
@ -104,10 +104,7 @@ get_all_positions_schema = {
|
||||
{
|
||||
"symbol": "symbol",
|
||||
"unrealized_pl": "unrealized_pl",
|
||||
"price": "current_price",
|
||||
"units": "qty",
|
||||
"side": "side",
|
||||
"value": "market_value",
|
||||
"price:": "current_price",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
@ -115,56 +115,9 @@ class OpenPositions(BaseModel):
|
||||
],
|
||||
"lastTransactionID": "73",
|
||||
}
|
||||
|
||||
|
||||
def parse_prices(x):
|
||||
if float(x["long"]["units"]) > 0:
|
||||
return x["long"]["averagePrice"]
|
||||
elif float(x["short"]["units"]) > 0:
|
||||
return x["short"]["averagePrice"]
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def parse_units(x):
|
||||
if float(x["long"]["units"]) > 0:
|
||||
return x["long"]["units"]
|
||||
elif float(x["short"]["units"]) > 0:
|
||||
return x["short"]["units"]
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def parse_value(x):
|
||||
if float(x["long"]["units"]) > 0:
|
||||
return float(x["long"]["units"]) * float(x["long"]["averagePrice"])
|
||||
elif float(x["short"]["units"]) > 0:
|
||||
return float(x["short"]["units"]) * float(x["short"]["averagePrice"])
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def parse_side(x):
|
||||
if float(x["long"]["units"]) > 0:
|
||||
return "long"
|
||||
elif float(x["short"]["units"]) > 0:
|
||||
return "short"
|
||||
else:
|
||||
return "unknown"
|
||||
|
||||
|
||||
OpenPositions_schema = {
|
||||
"itemlist": (
|
||||
"positions",
|
||||
[
|
||||
{
|
||||
"symbol": "instrument",
|
||||
"unrealized_pl": "unrealizedPL",
|
||||
"price": parse_prices,
|
||||
"units": parse_units,
|
||||
"side": parse_side,
|
||||
"value": parse_value,
|
||||
}
|
||||
],
|
||||
[{"symbol": "instrument", "unrealized_pl": "unrealizedPL"}],
|
||||
)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
{% include 'partials/notify.html' %}
|
||||
|
||||
<table class="table is-fullwidth is-hoverable" id="positions-table">
|
||||
<thead>
|
||||
<th>account</th>
|
||||
@ -18,8 +19,8 @@
|
||||
<td>{{ item.account }}</td>
|
||||
<td>{{ item.symbol }}</td>
|
||||
<td>{{ item.price }}</td>
|
||||
<td>{{ item.units }}</td>
|
||||
<td>{{ item.value }}</td>
|
||||
<td>{{ item.qty }}</td>
|
||||
<td>{{ item.market_value }}</td>
|
||||
<td>{{ item.unrealized_pl }}</td>
|
||||
<td>{{ item.side }}</td>
|
||||
<td>
|
||||
|
Loading…
Reference in New Issue
Block a user