OpenPositions¶
-
class
oandapyV20.endpoints.positions.
OpenPositions
(accountID)¶ Bases:
oandapyV20.endpoints.positions.Positions
OpenPositions.
List all open Positions for an Account. An open Position is a Position in an Account that currently has a Trade opened for it.
-
ENDPOINT
= 'v3/accounts/{accountID}/openPositions'¶
-
EXPECTED_STATUS
= 200¶
-
METHOD
= 'GET'¶
-
__init__
(accountID)¶ Instantiate an OpenPositions request.
Parameters: accountID (string (required)) – id of the account to perform the request on. >>> import oandapyV20 >>> import oandapyV20.endpoints.positions as positions >>> accountID = ... >>> client = oandapyV20.API(access_token=...) >>> r = positions.OpenPositions(accountID=accountID) >>> client.request(r) >>> print r.response
Output:
{ "positions": [ { "short": { "units": "0", "resettablePL": "-14164.3000", "unrealizedPL": "0.0000", "pl": "-14164.3000" }, "unrealizedPL": "-284.0000", "long": { "unrealizedPL": "-284.0000", "tradeIDs": [ "2315" ], "resettablePL": "404.5000", "units": "10", "averagePrice": "10678.3", "pl": "404.5000" }, "instrument": "DE30_EUR", "resettablePL": "-13759.8000", "pl": "-13759.8000" }, { "short": { "unrealizedPL": "-0.0738", "tradeIDs": [ "2323" ], "resettablePL": "0.0000", "units": "-100", "averagePrice": "1.09843", "pl": "0.0000" }, "unrealizedPL": "-0.0738", "long": { "units": "0", "resettablePL": "-44.6272", "unrealizedPL": "0.0000", "pl": "-44.6272" }, "instrument": "EUR_USD", "resettablePL": "-44.6272", "pl": "-44.6272" } ], "lastTransactionID": "2327" }
-