PositionDetails¶
-
class
oandapyV20.endpoints.positions.
PositionDetails
(accountID, instrument)¶ Bases:
oandapyV20.endpoints.positions.Positions
PositionDetails.
Get the details of a single instrument’s position in an Account. The position may be open or not.
-
ENDPOINT
= 'v3/accounts/{accountID}/positions/{instrument}'¶
-
EXPECTED_STATUS
= 200¶
-
METHOD
= 'GET'¶
-
__init__
(accountID, instrument)¶ Instantiate a PositionDetails request.
Parameters: - accountID (string (required)) – id of the account to perform the request on.
- instrument (string (required)) – id of the instrument to get the position details for.
>>> import oandapyV20 >>> import oandapyV20.endpoints.positions as positions >>> accountID = ... >>> instrument = ... >>> client = oandapyV20.API(access_token=...) >>> r = positions.PositionDetails(accountID=accountID, instrument) >>> client.request(r) >>> print r.response
Output:
{ "position": { "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" }
-