定義
get_open_trades(account_id)
引数
引数 | 型 | 必須 | 説明 |
account_id | str | ◯ | アカウントID |
概要
建玉の一覧を取得します。
OANDAのfxTradeの「チケット」の一覧に相当します。
復帰値
jsonオブジェクトが返却されます。
以下はサンプルです(整形後)。
{ "trades": [ { "id": "84759", "instrument": "USD_JPY", "price": "109.550", "openTime": "2019-05-16T09:01:34.854881062Z", "initialUnits": "-50", "initialMarginRequired": "219.1080", "state": "OPEN", "currentUnits": "-50", "realizedPL": "0.0000", "financing": "-0.5945", "unrealizedPL": "-5.4000", "marginUsed": "219.3080" }, { "id": "84745", "instrument": "USD_JPY", "price": "109.550", "openTime": "2019-05-16T08:57:29.320024620Z", "initialUnits": "-50", "initialMarginRequired": "219.1080", "state": "OPEN", "currentUnits": "-50", "realizedPL": "0.0000", "financing": "-0.5945", "unrealizedPL": "-5.4000", "marginUsed": "219.3080" }, { "id": "84731", "instrument": "USD_JPY", "price": "109.560", "openTime": "2019-05-16T08:55:22.927094429Z", "initialUnits": "-50", "initialMarginRequired": "219.1280", "state": "OPEN", "currentUnits": "-50", "realizedPL": "0.0000", "financing": "-0.5945", "unrealizedPL": "-4.9000", "marginUsed": "219.3080" }, { "id": "84718", "instrument": "USD_JPY", "price": "109.565", "openTime": "2019-05-16T08:54:01.803837476Z", "initialUnits": "-4500", "initialMarginRequired": "19722.4200", "state": "OPEN", "currentUnits": "-4500", "realizedPL": "0.0000", "financing": "-53.5018", "unrealizedPL": "-418.5000", "marginUsed": "19737.7200", "takeProfitOrder": { "id": "85359", "createTime": "2019-05-17T06:44:59.094336053Z", "type": "TAKE_PROFIT", "tradeID": "84718", "price": "109.500", "timeInForce": "GTC", "triggerCondition": "DEFAULT", "state": "PENDING" } }, { "id": "84717", "instrument": "USD_JPY", "price": "109.544", "openTime": "2019-05-16T08:51:09.286253050Z", "initialUnits": "-50", "initialMarginRequired": "219.0960", "state": "OPEN", "currentUnits": "-50", "realizedPL": "0.0000", "financing": "-0.5945", "unrealizedPL": "-5.7000", "marginUsed": "219.3080" }, { "id": "84701", "instrument": "USD_JPY", "price": "109.552", "openTime": "2019-05-16T08:48:08.435779451Z", "initialUnits": "-50", "initialMarginRequired": "219.1120", "state": "OPEN", "currentUnits": "-50", "realizedPL": "0.0000", "financing": "-0.5945", "unrealizedPL": "-5.3000", "marginUsed": "219.3080" }, { "id": "84687", "instrument": "USD_JPY", "price": "109.558", "openTime": "2019-05-16T08:45:33.825151774Z", "initialUnits": "-50", "initialMarginRequired": "219.1240", "state": "OPEN", "currentUnits": "-50", "realizedPL": "0.0000", "financing": "-0.5945", "unrealizedPL": "-5.0000", "marginUsed": "219.3080" }, { "id": "84659", "instrument": "USD_JPY", "price": "109.566", "openTime": "2019-05-16T08:42:01.370387918Z", "initialUnits": "-4500", "initialMarginRequired": "19722.6000", "state": "OPEN", "currentUnits": "-4500", "realizedPL": "0.0000", "financing": "-53.5018", "unrealizedPL": "-414.0000", "marginUsed": "19737.7200", "takeProfitOrder": { "id": "85360", "createTime": "2019-05-17T06:45:22.130940617Z", "type": "TAKE_PROFIT", "tradeID": "84659", "price": "109.500", "timeInForce": "GTC", "triggerCondition": "DEFAULT", "state": "PENDING" } }, { "id": "84590", "instrument": "USD_JPY", "price": "109.516", "openTime": "2019-05-16T08:28:47.890976423Z", "initialUnits": "-1650", "initialMarginRequired": "7228.3200", "state": "OPEN", "currentUnits": "-900", "realizedPL": "-48.1500", "closingTransactionIDs": [ "84622", "84641", "84658", "84673", "84715", "84955", "84969", "84983", "84997", "85010", "85039", "85054", "85069", "85085", "85098" ], "financing": "-10.7004", "averageClosePrice": "109.580", "unrealizedPL": "-127.8000", "marginUsed": "3947.5440" } ], "lastTransactionID": "85360" }
サンプルコード
API_KEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' ACCOUNT_ID='123-456-7890123-456' # APIへ接続 con = oanda.APIv20(environment="live", access_token=API_KEY) response = con.trades.get_open_trades(ACCOUNT_ID) trades = response.raw.json() print(trades)
参照
OANDAのAPIの仕様は以下を参照してください。
http://developer.oanda.com/rest-live-v20/trade-ep/