|
|
|
@ -115,9 +115,26 @@ class OpenPositions(BaseModel):
|
|
|
|
|
],
|
|
|
|
|
"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 = {
|
|
|
|
|
"itemlist": (
|
|
|
|
|
"positions",
|
|
|
|
|
[{"symbol": "instrument", "unrealized_pl": "unrealizedPL"}],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
"symbol": "instrument",
|
|
|
|
|
"unrealized_pl": "unrealizedPL",
|
|
|
|
|
"price": parse_prices,
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|