Convert API responses with Glom

This commit is contained in:
2022-11-02 18:25:34 +00:00
parent 396d838416
commit 5cb7d08614
8 changed files with 140 additions and 16 deletions

View File

@@ -77,3 +77,47 @@ class Position(BaseModel):
class OpenPositions(BaseModel):
positions: list[Position]
lastTransactionID: str
{
"positions": [
{
"instrument": "EUR_USD",
"long": {
"units": "1",
"averagePrice": "0.99361",
"pl": "-0.1014",
"resettablePL": "-0.1014",
"financing": "-0.0002",
"dividendAdjustment": "0.0000",
"guaranteedExecutionFees": "0.0000",
"tradeIDs": ["71"],
"unrealizedPL": "-0.0044",
},
"short": {
"units": "0",
"pl": "0.0932",
"resettablePL": "0.0932",
"financing": "0.0000",
"dividendAdjustment": "0.0000",
"guaranteedExecutionFees": "0.0000",
"unrealizedPL": "0.0000",
},
"pl": "-0.0082",
"resettablePL": "-0.0082",
"financing": "-0.0002",
"commission": "0.0000",
"dividendAdjustment": "0.0000",
"guaranteedExecutionFees": "0.0000",
"unrealizedPL": "-0.0044",
"marginUsed": "0.0287",
}
],
"lastTransactionID": "73",
}
OpenPositions_schema = {
"itemlist": (
"positions",
[{"symbol": "instrument", "unrealized_pl": "unrealizedPL"}],
)
}