# 外国為替FXのAPIドキュメント| GMOコイン

<a id="outline"></a>
# 概要

GMOコインのAPIは、認証不要のPublic APIと、APIキーによる認証が必要なPrivate APIを提供しています。

* クライアントからAPIへの全てのリクエストは[HTTPS](https://ja.wikipedia.org/wiki/HTTPS)通信です。

```javascript

//Node.js v21.0.0 にて動作確認したサンプルコードをRequest exampleに記載しています。

```

<a id="end-point"></a>
## エンドポイント

* Public API: `https://forex-api.coin.z.com/public`
* Public WebSocket API: `wss://forex-api.coin.z.com/ws/public`
* Private API: `https://forex-api.coin.z.com/private`
* Private WebSocket API: `wss://forex-api.coin.z.com/ws/private`


<a id="version"></a>
## バージョン
現在バージョン: `v1`


<a id="restrictions"></a>
## 制限
APIは以下のように制限をかけております。

<a id="restrictions-public-ws-api"></a>
##### Public WebSocket APIの制限
* 同一IPからのリクエスト(subscribe, unsubscribe)は、1秒間1回を上限とします。

<a id="restrictions-private-api"></a>
##### Private APIの制限
* 制限はシステム負荷状況によって一時的に変更する場合があります。ご了承ください。
* 会員ページにてIP制限機能を有効にすると、API呼出ができるIPアドレスを制限することができます。
* APIキー発行時に指定した機能のみをAPIで呼び出すことができます。

|  説明  |
| ---- |
| 同一アカウントからGETのAPI呼出は、1秒間に6回が上限です。  同一アカウントからPOSTのAPI呼出は、1秒間に1回が上限です。 |

<a id="restrictions-private-ws-api"></a>
##### Private WebSocket APIの制限
* 同一IPからのリクエスト(subscribe, unsubscribe)は、1秒間1回を上限とします。
* 会員ページにてIP制限機能を有効にすると、API呼出ができるIPアドレスを制限することができます。
* APIキー発行時に指定した機能のみをsubscribeすることができます。

<a id="restrictions-other"></a>
##### その他
下記のいずれかの理由により、APIのご利用を制限させていただく場合があります。ご了承ください。

* 当社システム全体が高負荷となった場合に、自動で流量制限を実施させていただくため
* お客さまによるAPIのご利用方法が、当社システムへ負荷をかけている可能性があると当社が判断したため
* システムに負荷をかける目的での発注を繰り返していると当社が判断したため


<a id="open-account"></a>
# 口座開設
外国為替FX口座をお持ちでない場合　[無料口座開設](https://coin.z.com/jp/member/home/join/fx)


<a id="api-key"></a>
# APIキー作成
外国為替FX口座の開設完了後、会員ページから外国為替FXのAPIキーが作成できます。

APIキーを生成する際、機能ごとにパーミッションを設定することができます。

APIキー作成後はトライアル期間として30日間API手数料無料でご利用いただけます。

API経由の注文・注文変更の手数料は [こちら](https://coin.z.com/jp/corp/guide/fees/)をご確認ください。

<a id="authentication"></a>
# 認証

Public APIは認証が不要です。Public API機能は[こちら](#public-api)へ。


<a id="authentication-private"></a>
## Private API

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://END_POINT_URL';
const path      = '/v1/PATH';
const reqBody   = JSON.stringify({});

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

Private APIではAPIキーとAPIシークレットを使用してHTTPヘッダに下記の認証情報を含める必要があります。

* API-KEY: 会員ページで発行したアクセスキー
* API-TIMESTAMP: リクエスト時のUnix Timestamp
* API-SIGN: 後述する方法でリクエストごとに生成した署名

##### 署名の生成

署名は、リクエスト時のUnix Timestamp(ミリ秒)，HTTPメソッド，リクエストのパス，リクエストボディを文字列として連結したものを、APIシークレットキーを使ってHMAC-SHA256形式で署名することで作成できます。特に、下記の点にはご注意ください。

* GETリクエストの場合、リクエストボディは空文字列とすること
* リクエストのパスは`/v1`で始まり、`/private`で始まらないこと

<a id="authentication-private-ws"></a>
## Private WebSocket API
Private WebSocket APIではPrivate APIの[アクセストークンの取得](#ws-auth-post)を使用してアクセストークンを取得します。このPrivate APIの認証方法は他のPrivate APIと同様です。

<a id="public-api"></a>
# Public API


<a id="status"></a>
## 外国為替FXステータス

> Request example:

```javascript
const axios = require('axios');

const endPoint = 'https://forex-api.coin.z.com/public';
const path     = '/v1/status';

axios.get(endPoint + path)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });

```

> Response example:

```json
{
  "status": 0,
  "data": {
    "status": "OPEN"
  },
  "responsetime": "2019-03-19T02:15:06.001Z"
}
```

外国為替FXの稼動状態を取得します。


##### Request
`GET /public/v1/status`


##### Parameters
無し

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
status | string | 外国為替FXステータス: `MAINTENANCE`（外国為替FXステータス: メンテナンス中） `CLOSE`（クローズ） `OPEN`（オープン）


<a id="ticker"></a>
## 最新レート

> Request example:

```javascript
const axios = require('axios');

const endPoint = 'https://forex-api.coin.z.com/public';
const path     = '/v1/ticker';

axios.get(endPoint + path)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });

```

> Response example:

```json
{
  "status": 0,
  "data": [
    {
      "ask": "137.644",
      "bid": "137.632",
      "symbol": "USD_JPY",
      "timestamp": "2018-03-30T12:34:56.789671Z",
      "status": "OPEN"
    },
    {
      "symbol": "EUR_JPY",
      "ask": "149.221",
      "bid": "149.181",
      "timestamp": "2023-05-19T02:51:24.516493Z",
      "status": "OPEN"
    }
  ],
  "responsetime": "2019-03-19T02:15:06.014Z"
}
```

全銘柄分の最新レートを取得します。


##### Request
`GET /public/v1/ticker`

##### Parameters
無し

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
ask | string | 現在の買値
bid | string | 現在の売値
timestamp | string | 現在レートのタイムスタンプ
status | string | 外国為替FXステータス: `CLOSE`（外国為替FXステータス: クローズ） `OPEN`（オープン）


<a id="klines"></a>
## KLine情報の取得

> Request example:

```javascript
const axios = require('axios');

const endPoint = 'https://forex-api.coin.z.com/public';
const path     = '/v1/klines?symbol=USD_JPY&priceType=ASK&interval=1min&date=20231028';

axios.get(endPoint + path)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
    {
        "openTime":"1618588800000",
        "open":"141.365",
        "high":"141.368",
        "low":"141.360",
        "close":"141.362"
    },
    {
        "openTime":"1618588860000",
        "open":"141.362",
        "high":"141.369",
        "low":"141.361",
        "close":"141.365"
    }
  ],
  "responsetime": "2023-07-08T22:28:07.980Z"
}
```

指定した銘柄の四本値を取得します。


##### Request
`GET /public/v1/klines`


##### Parameters
* Parameter type: query

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)
`priceType`（BID/ASK） | string | Required | `BID` `ASK`を指定
`interval`（チャート足の種類） | string | Required |  `1min`（1分足） `5min`（5分足） `10min`（10分足） `15min`（15分足） `30min`（30分足） `1hour`（1時間足） `4hour`（4時間足） `8hour`（8時間足） `12hour`（12時間足） `1day`（1日足） `1week`（1週間足） `1month`（1ヶ月足）
`date`（検索日） | string | Required |   指定可能な日付フォーマット: `YYYYMMDD`（日付指定） `YYYY`（年指定）  `YYYYMMDD` で指定できるintervalの種類 : `1min`（チャート足の種類: 1分足） `5min`（5分足） `10min`（10分足） `15min`（15分足） `30min`（30分足） `1hour`（1時間足）  ※20231028以降を指定可能    日本時間朝6：00に新しい日付に切替  `YYYY` で指定できるintervalの種類 : `4hour`（4時間足） `8hour`（8時間足） `12hour`（12時間足） `1day`（1日足） `1week`（1週間足） `1month`（1ヶ月足）   ※当社取扱開始年以降を指定可能      取扱開始日は[こちら](#parameters-ref)

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
openTime | string | 開始時刻のunixタイムスタンプ(ミリ秒)
open | string | 始値
high | string | 高値
low | string | 安値
close | string | 終値

<a id="symbols"></a>
## 取引ルール

> Request example:

```javascript
const axios = require('axios');

const endPoint = 'https://forex-api.coin.z.com/public';
const path     = '/v1/symbols';

axios.get(endPoint + path)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
    {
      "symbol": "USD_JPY",
      "minOpenOrderSize": "10000",
      "maxOrderSize": "500000",
      "sizeStep": "1",
      "tickSize": "0.001"
    }
  ],
  "responsetime": "2022-12-15T19:22:23.792Z"
}
```

取引ルールを取得します。


##### Request
`GET /public/v1/symbols`


##### Parameters
無し

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
minOpenOrderSize | string | 新規最小注文数量/回 
maxOrderSize | string | 最大注文数量/回 
sizeStep | string | 最小注文単位/回
tickSize | string | 注文価格の呼値

<a id="public-ws-api"></a>
# Public WebSocket API

* サーバーから1分に1回クライアントへpingを送り、3回連続でクライアントからの応答(pong)が無かった場合は、自動的に切断されます。


<a id="ws-ticker"></a>
## 最新レート

> Request example:

```javascript
const WebSocket = require("ws");
const ws = new WebSocket("wss://forex-api.coin.z.com/ws/public/v1");

ws.on("open", () => {
    const message = JSON.stringify(
    {
        "command": "subscribe",
        "channel": "ticker",
        "symbol": "USD_JPY"
    });
    ws.send(message);
});

ws.on("message", (data) => {
    console.log("WebSocket message: ", data);
});
```

> Response example:

```json
{
  "symbol": "USD_JPY",
  "ask": "140.534",
  "bid": "140.502",
  "timestamp": "2018-03-30T12:34:56.789984Z",
  "status": "OPEN" 
}
```

指定した銘柄の最新レートを受信します。 
`subscribe`（コマンド: 対象の配信を開始する）後、最新レートが配信されます。


##### Parameters
* Parameter type: JSON

Property Name | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
command | string | Required | `subscribe`（コマンド: 対象の配信を開始する） `unsubscribe`（対象の配信を止める）
channel | string | Required | `ticker`（チャネル名: 最新レート）
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
ask | string | 現在の買値
bid | string | 現在の売値
timestamp | string | 現在レートのタイムスタンプ
status | string | 外国為替FXステータス: `CLOSE`（外国為替FXステータス: クローズ） `OPEN`（オープン）

* `unsubscribe`（コマンド: 対象の配信を止める）でリクエストした場合のResponseはありません。

<a id="private-api"></a>
# Private API

<a id="assets"></a>
## 資産残高を取得

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'GET';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/account/assets';

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.get(endPoint + path, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });

```

> Response example:

```json
{
  "status": 0,
  "data": [
    {
      "equity": "120947776",
      "availableAmount": "89717102",
      "balance": "116884885",
      "estimatedTradeFee": "766.5",
      "margin": "31227908",
      "marginRatio": "406.3",
      "positionLossGain": "3884065.046",
      "totalSwap": "178825.439",
      "transferableAmount": "85654212"
    }
  ],
  "responsetime": "2019-03-19T02:15:06.055Z"
}
```

資産残高を取得します。


##### Request
`GET /private/v1/account/assets`


##### Parameters
無し

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
equity | string | 時価評価総額
availableAmount | string | 取引余力
balance | string | 現金残高
estimatedTradeFee | string | 見込み手数料
margin | string | 拘束証拠金
marginRatio | string | 証拠金維持率
positionLossGain | string | 評価損益
totalSwap | string | 未決済スワップ
transferableAmount | string | 振替余力


<a id="orders"></a>
## 注文情報取得

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp  = Date.now().toString();
const method     = 'GET';
const endPoint   = 'https://forex-api.coin.z.com/private';
const path       = '/v1/orders';
const parameters = '?orderId=123456789,223456789';

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.get(endPoint + path + parameters, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
    "list": [
      {
        "rootOrderId": 223456789,
        "clientOrderId": "sygngz1234",
        "orderId": 223456789,
        "symbol": "USD_JPY",
        "side": "BUY",
        "orderType": "NORMAL",
        "executionType": "LIMIT",
        "settleType": "OPEN",
        "size": "10000",
        "price": "140",
        "status": "EXECUTED",
        "expiry" : "20201113",
        "timestamp": "2020-10-14T20:18:59.343Z"
      },
      {
        "rootOrderId": 123456789,
        "orderId": 123456789,
        "symbol": "CAD_JPY",
        "side": "SELL",
        "orderType": "NORMAL",
        "executionType": "LIMIT",
        "settleType": "CLOSE",
        "size": "10000",
        "price": "110",
        "status": "CANCELED",
        "cancelType": "USER",
        "expiry" : "20201113",
        "timestamp": "2020-10-14T20:18:59.343Z"
      }
    ]
  },
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

指定した注文IDの注文情報を取得します。 

* `rootOrderId` `orderId` いずれか1つが必須です。2つ同時には設定できません。


##### Request
`GET /private/v1/orders`


##### Parameters
* Parameter type: query

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`rootOrderId`（親注文ID） | number | * | `rootOrderId` `orderId`（注文ID） いずれか1つが必須 ※カンマ区切りで最大10件まで指定可能
`orderId`（約定ID） | number | * | `rootOrderId`（親注文ID） `orderId`（注文ID） いずれか1つが必須 ※カンマ区切りで最大10件まで指定可能

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） `OCO`（OCO注文） `IFD`（IFD注文） `IFDOCO`（IFDOCO注文） `LOSSCUT`（自動ロスカット注文） 
executionType | string | 注文タイプ: `MARKET`（注文タイプ: 成行） `LIMIT`（指値） `STOP`（逆指値）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 注文数量
price | string | 注文価格 ※`LIMIT`（注文タイプ: 指値） `STOP`（逆指値） の場合のみ返却
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `ORDERED`（有効） `MODIFYING`（変更中） `CANCELED`（取消済） `EXECUTED`（約定済） `EXPIRED`（失効） 
cancelType | string | 取消区分: `USER`（取消区分: お客さまによる注文の取消） `INSUFFICIENT_COLLATERAL`（ロスカットによる決済注文の取消） `INSUFFICIENT_MARGIN`（取引余力の不足による注文の取消） `SPEED`（スピード注文による注文の取消） `OCO`（OCO注文が約定されたことによる約定されていない側の注文の取消） `EXPIRATION`（注文有効期限切れによる注文の取消） `PRICE_BOUND`（成立上下限価格超えによる注文の取消） `OUT_OF_SLIPPAGE_RANGE`（スリッページ範囲外による注文の取消）  ※statusが`CANCELED`または`EXPIRED`の場合のみ返却 
expiry | string | 注文有効期限
timestamp | string | 注文日時

<a id="active-orders"></a>
## 有効注文一覧

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp  = Date.now().toString();
const method     = 'GET';
const endPoint   = 'https://forex-api.coin.z.com/private';
const path       = '/v1/activeOrders';
const parameters = '?symbol=USD_JPY&prevId=123456790&count=10';

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.get(endPoint + path + parameters, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
    "list": [
      {
        "rootOrderId": 123456789,
        "orderId": 123456789,
        "clientOrderId": "abc123",
        "symbol": "USD_JPY",
        "side": "BUY",
        "orderType": "NORMAL",
        "executionType": "LIMIT",
        "settleType": "OPEN",
        "size": "10000",
        "price": "135.5",
        "status": "ORDERED",
        "expiry": "20190418",
        "timestamp": "2019-03-19T01:07:24.217Z"
      }
    ]
  },
  "responsetime": "2019-03-19T01:07:24.217Z"
}
```

有効注文一覧を取得します。 


##### Request
`GET /private/v1/activeOrders`


##### Parameters
* Parameter type: query

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`symbol`（銘柄名） | string | Optional | 取扱銘柄は[こちら](#parameters-ref)
`prevId`（指定ID） | number | Optional | 注文IDを指定 ※ 指定しない場合は最新から取得     指定した場合は指定した値より小さい注文IDを持つデータを取得 
`count`（取得件数） | number | Optional | 取得件数: 指定しない場合は100(最大値)

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
orderId | number | 注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） `OCO`（OCO注文） `IFD`（IFD注文） `IFDOCO`（IFDOCO注文） 
executionType | string | 注文タイプ: `LIMIT`（注文タイプ: 指値） `STOP`（逆指値）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 注文数量
price | string | 注文価格
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `MODIFYING`（変更中） `ORDERED`（有効）　
expiry | string | 注文有効期限
timestamp | string | 注文日時


<a id="executions"></a>
## 約定情報取得

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp  = Date.now().toString();
const method     = 'GET';
const endPoint   = 'https://forex-api.coin.z.com/private';
const path       = '/v1/executions';
const parameters = '?executionId=72123911,92123912';

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.get(endPoint + path + parameters, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
    "list": [
      {
        "amount":"16215.999", 
        "executionId": 92123912,
        "clientOrderId": "aaaaa",
        "orderId": 223456789,
        "positionId": 2234567,
        "symbol": "USD_JPY",
        "side": "SELL",
        "settleType": "CLOSE",
        "size": "10000",
        "price": "141.251",
        "lossGain": "15730",
        "fee": "-30",
        "settledSwap":"515.999",
        "timestamp": "2020-11-24T21:27:04.764Z"
      },
      {
        "amount":"0",
        "executionId": 72123911,
        "clientOrderId": "bbbbb",
        "orderId": 123456789,
        "positionId": 1234567,
        "symbol": "USD_JPY",
        "side": "BUY",
        "settleType": "OPEN",
        "size": "10000",
        "price": "141.269",
        "lossGain": "0",
        "fee": "0",
        "settledSwap":"0",
        "timestamp": "2020-11-24T19:47:51.234Z"
      }
    ]
  },
  "responsetime": "2019-03-19T02:15:06.081Z"
}
```

約定情報を取得します。 

* `orderId`（注文ID） `executionId`（約定ID） いずれか1つが必須です。2つ同時には設定できません。


##### Request
`GET /private/v1/executions`


##### Parameters
* Parameter type: query

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`orderId`（注文ID） | number | * | `orderId` `executionId`（約定ID） いずれか1つが必須
`executionId`（約定ID） | string | * | `orderId`（注文ID） `executionId` いずれか1つが必須 ※`executionId`のみカンマ区切りで最大10件まで指定可能

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
amount | string | 受渡金額
executionId | number | 約定ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
positionId | number | 建玉ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 約定数量
price | string | 約定レート
lossGain | string | 決済損益
fee | string | 取引手数料
settledSwap | string | 決済スワップ
timestamp | string | 約定日時


<a id="latest-executions"></a>
## 最新の約定一覧

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp  = Date.now().toString();
const method     = 'GET';
const endPoint   = 'https://forex-api.coin.z.com/private';
const path       = '/v1/latestExecutions';
const parameters = '?symbol=USD_JPY&count=100';

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.get(endPoint + path + parameters,, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
    "list": [
      {
        "amount":"16215.999",
        "executionId": 92123912,
        "clientOrderId": "ccccc",
        "orderId": 223456789,
        "positionId": 2234567,
        "symbol": "USD_JPY",
        "side": "SELL",
        "settleType": "CLOSE",
        "size": "10000",
        "price": "141.251",
        "lossGain": "15730",
        "fee": "-30",
        "settledSwap":"515.999",
        "timestamp": "2020-11-24T21:27:04.764Z"
      }
    ]
  },
  "responsetime": "2019-03-19T02:15:06.086Z"
}
```

最新約定一覧を取得します。 

* 直近1日分から最新100件の約定情報を返します。


##### Request
`GET /private/v1/latestExecutions`


##### Parameters
* Parameter type: query

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)
`count`（取得件数） | number | Optional | 取得件数: 指定しない場合は100(最大値)

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
amount | string | 受渡金額
executionId | number | 約定ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
positionId | number | 建玉ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 約定数量
price | string | 約定レート
lossGain | string | 決済損益
fee | string | 取引手数料 
settledSwap | string | 決済スワップ
timestamp | string | 約定日時


<a id="open-positions"></a>
## 建玉一覧を取得

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp  = Date.now().toString();
const method     = 'GET';
const endPoint   = 'https://forex-api.coin.z.com/private';
const path       = '/v1/openPositions';
const parameters = '?symbol=USD_JPY&prevId=123456790&count=100';

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.get(endPoint + path + parameters, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
    "list": [
      {
        "positionId": 123456789,
        "symbol": "USD_JPY",
        "side": "BUY",
        "size": "10000",
        "orderedSize": "0",
        "price": "141.269",
        "lossGain": "-1980",
        "totalSwap":"0" ,
        "timestamp": "2019-03-21T05:18:09.011Z"
      }
    ]
  },
  "responsetime": "2019-03-19T02:15:06.095Z"
}
```

有効建玉一覧を取得します。 


##### Request
`GET /private/v1/openPositions`


##### Parameters
* Parameter type: query

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`symbol`（銘柄名） | string | Optional | 取扱銘柄は[こちら](#parameters-ref)
`prevId`（指定ID） | number | Optional | 建玉IDを指定 ※ 指定しない場合は最新から取得     指定した場合は指定した値より小さい建玉IDを持つデータを取得
`count`（取得件数） | number | Optional | 取得件数: 指定しない場合は100(最大値)

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
positionId | number | 建玉ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
size | string | 建玉数量
orderedSize | string | 注文中数量
price | string | 建玉レート
lossGain | string | 評価損益
totalSwap | string | 累計スワップ
timestamp | string | 約定日時


<a id="position-summary"></a>
## 建玉サマリーを取得

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp  = Date.now().toString();
const method     = 'GET';
const endPoint   = 'https://forex-api.coin.z.com/private';
const path       = '/v1/positionSummary';
const parameters = '?symbol=USD_JPY';

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.get(endPoint + path + parameters, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
    "list": [
      {
        "averagePositionRate": "140.043",
        "positionLossGain": "2322204.675",
        "side": "BUY",
        "sumOrderedSize": "0",
        "sumPositionSize": "1353339",
        "sumTotalSwap": "161600.404",
        "symbol": "USD_JPY"
      },
      {
        "averagePositionRate": "140.082",
        "positionLossGain": "-2588483.591",
        "side": "SELL",
        "sumOrderedSize": "20000",
        "sumPositionSize": "1481339",
        "sumTotalSwap": "-178353.217",
        "symbol": "USD_JPY"
      }
    ]
  },
  "responsetime": "2019-03-19T02:15:06.102Z"
}
```

建玉サマリーを取得します。 

* 指定した銘柄の建玉サマリーを売買区分(買/売)ごとに取得できます。
* symbolパラメータ指定無しの場合は、保有している全銘柄の建玉サマリーを売買区分(買/売)ごとに取得します。


##### Request
`GET /private/v1/positionSummary`


##### Parameters
* Parameter type: query

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`symbol`（銘柄名） | string | Optional | 指定しない場合は全銘柄分の建玉サマリーを返却  取扱銘柄は[こちら](#parameters-ref)

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
averagePositionRate | string | 平均建玉レート
positionLossGain | string | 評価損益
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
sumOrderedSize | string | 合計注文中数量
sumPositionSize | string | 合計建玉数量
sumTotalSwap | string | 累計スワップ
symbol | string | 取扱銘柄は[こちら](#parameters-ref)

## スピード注文

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/speedOrder';
const reqBody   = JSON.stringify({
        symbol: "USD_JPY",
        side: "BUY",
        clientOrderId: "abc123",
        size: "10000",
        upperBound: "138",
        isHedgeable: false
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json

{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789, 
        "clientOrderId": "sygngz1234",                
        "orderId": 123456789,                      
        "symbol": "USD_JPY",　　                   
        "side": "BUY",                             
        "orderType": "NORMAL",                     
        "executionType": "MARKET",                 
        "settleType": "OPEN",                     
        "size": "10000",
        "status": "EXECUTED",                       
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
    ],
  "responsetime": "2019-03-19T02:15:06.069Z"
}
```

スピード注文をします。 


##### Request
`POST /private/v1/speedOrder`

##### Parameters
* Parameter content type: `application/json`


Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)
`side`（売買区分） | string | Required | `BUY`（買） `SELL`（売）
`clientOrderId`（顧客注文ID） | string | Optional | 顧客注文ID ※36文字以内の半角英数字の組合わせのみ使用可能
`size`（注文数量） | string | Required | 注文数量
`lowerBound`（成立下限価格） | string | Optional  | 成立下限価格 ※side:`SELL`（売買区分: 売）の場合に指定可能
`upperBound`（成立上限価格） | string | Optional  | 成立上限価格 ※side:`BUY`（売買区分: 買）の場合に指定可能
`isHedgeable`（両建てなし: false(デフォルト)  両建てあり:true） | bool | Optional  | 両建てなし: false(デフォルト)  両建てあり:true


##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） 
executionType | string | 注文タイプ: `MARKET`（注文タイプ: 成行） 
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 注文数量
status | string | 注文ステータス: `EXECUTED`（注文ステータス: 約定済） `EXPIRED`（失効）　
cancelType | string | 取消区分: `PRICE_BOUND`（取消区分: 成立上下限価格超えによる注文の取消）  ※statusが`EXPIRED`の場合のみ返却 
timestamp | string | 注文日時


<a id="order"></a>
## 注文

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/order';
const reqBody   = JSON.stringify({
    symbol: "USD_JPY",
    side: "BUY",
    size: "10000",
    clientOrderId: "abc123",
    executionType: "LIMIT",
    limitPrice: "130"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789,                 
        "clientOrderId": "abc123",               
        "orderId": 123456789,                     
        "symbol": "USD_JPY",　　                  
        "side": "BUY",                            
        "orderType": "NORMAL",                    
        "executionType": "LIMIT",                  
        "settleType": "OPEN",                     
        "size": "10000",　　　　　　　                
        "price": "130",                        
        "status": "WAITING",                      
        "expiry" : "20190418",    
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
    ],
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

新規注文をします。 


##### Request
`POST /private/v1/order`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ---------- | -----------
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)
`side`（売買区分） | string | Required | `BUY`（買） `SELL`（売）
`size`（注文数量） | string | Required | 注文数量
`clientOrderId`（顧客注文ID） | string | Optional | 顧客注文ID ※36文字以内の半角英数字の組合わせのみ使用可能
`executionType`（注文タイプ） | string | Required | `MARKET`（成行） `LIMIT`（指値） `STOP`（逆指値） `OCO`（OCO注文）
`limitPrice`（指値注文レート） | string | *executionTypeによる | 指値注文レート ※`LIMIT`（注文タイプ: 指値）  `OCO`（OCO注文）  の場合は必須
`stopPrice`（逆指値注文レート） | string | *executionTypeによる | 逆指値注文レート ※`STOP`（注文タイプ: 逆指値） `OCO`（OCO注文） の場合は必須
`lowerBound`（成立下限価格） | string | Optional | 成立下限価格 ※executionType:`MARKET`（注文タイプ: 成行） side: `SELL`（売買区分: 売）の場合に指定可能
`upperBound`（成立上限価格） | string | Optional | 成立上限価格 ※executionType:`MARKET`（注文タイプ: 成行） side:`BUY`（売買区分: 買）の場合に指定可能


##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） `OCO`（OCO注文）
executionType | string | 注文タイプ: `MARKET`（注文タイプ: 成行） `LIMIT`（指値） `STOP`（逆指値） 
settleType | string | 決済区分: `OPEN`（決済区分: 新規） 
size | string | 注文数量
price | string | 注文価格 ※`LIMIT`（注文タイプ: 指値） `STOP`（逆指値）の場合のみ返却
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `EXECUTED`（約定済） `EXPIRED`（失効） 
cancelType | string | 取消区分: `PRICE_BOUND`（取消区分: 成立上下限価格超えによる注文の取消） `OCO`（OCO注文が約定されたことによる約定されていない側の注文の取消）  ※statusが`EXPIRED`の場合のみ返却 
expiry | string | 注文有効期限
timestamp | string | 注文日時

<a id="ifdOrder"></a>
## IFD注文

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/ifdOrder';
const reqBody   = JSON.stringify({
    symbol: "USD_JPY",
    clientOrderId: "abc123",
    firstSide: "BUY",
    firstExecutionType: "LIMIT",
    firstSize: "10000",
    firstPrice: "130",
    secondExecutionType: "LIMIT",
    secondSize: "10000",
    secondPrice: "145"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789,                 
        "clientOrderId": "abc123",               
        "orderId": 123456789,                     
        "symbol": "USD_JPY",　　                  
        "side": "BUY",                            
        "orderType": "IFD",                    
        "executionType": "LIMIT",                  
        "settleType": "OPEN",                     
        "size": "10000",　　　　　　　                
        "price": "130",                        
        "status": "WAITING",                      
        "expiry" : "20190418",    
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      },
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456790,
        "symbol": "USD_JPY",　　                  
        "side": "SELL",
        "orderType": "IFD",
        "executionType": "LIMIT",
        "settleType": "CLOSE",
        "size": "10000",　　　　　　　                
        "price": "145",
        "status": "WAITING",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
  ],
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

IFD注文をします。 


##### Request
`POST /private/v1/ifdOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ---------- | -----------
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)
`clientOrderId`（顧客注文ID） | string | Optional | 顧客注文ID ※36文字以内の半角英数字の組合わせのみ使用可能
`firstSide`（売買区分） | string | Required | `BUY`（買） `SELL`（売） ※firstSideで指定していない売買区分が2次注文の売買区分 
`firstExecutionType`（注文タイプ） | string | Required | `LIMIT`（指値） `STOP`（逆指値） 
`firstSize`（1次注文数量） | string | Required | 1次注文数量
`firstPrice`（1次注文レート） | string | Required | 1次注文レート
`secondExecutionType`（注文タイプ） | string | Required | `LIMIT`（指値） `STOP`（逆指値） 
`secondSize`（2次注文数量） | string | Required | 2次注文数量
`secondPrice`（2次注文レート） | string | Required | 2次注文レート


##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `IFD`（取引区分: IFD注文）
executionType | string | 注文タイプ: `LIMIT`（注文タイプ: 指値） `STOP`（逆指値） 
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済） 
size | string | 注文数量
price | string | 注文価格
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `ORDERED`（有効） `EXECUTED`（約定済） 
expiry | string | 注文有効期限
timestamp | string | 注文日時


<a id="ifoOrder"></a>
## IFDOCO注文

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/ifoOrder';
const reqBody   = JSON.stringify({
    symbol: "USD_JPY",
    clientOrderId: "abc123",
    firstSide: "BUY",
    firstExecutionType: "LIMIT",
    firstSize: "10000",
    firstPrice: "135",
    secondSize: "10000",
    secondLimitPrice: "140",
    secondStopPrice: "132"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789,                 
        "clientOrderId": "abc123",               
        "orderId": 123456789,                     
        "symbol": "USD_JPY",　　                  
        "side": "BUY",                            
        "orderType": "IFDOCO",                    
        "executionType": "LIMIT",                  
        "settleType": "OPEN",                     
        "size": "10000",　　　　　　　                
        "price": "135",                        
        "status": "WAITING",                      
        "expiry" : "20190418",    
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      },
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456790,
        "symbol": "USD_JPY",　　                  
        "side": "SELL",
        "orderType": "IFDOCO",
        "executionType": "LIMIT",
        "settleType": "CLOSE",
        "size": "10000",　　　　　　　                
        "price": "140",
        "status": "WAITING",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      },
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456791,
        "symbol": "USD_JPY",　　                  
        "side": "SELL",
        "orderType": "IFDOCO",
        "executionType": "STOP",
        "settleType": "CLOSE",
        "size": "10000",　　　　　　　                
        "price": "132",
        "status": "WAITING",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
  ],
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

IFDOCO注文をします。 


##### Request
`POST /private/v1/ifoOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ---------- | -----------
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)
`clientOrderId`（顧客注文ID） | string | Optional | 顧客注文ID ※36文字以内の半角英数字の組合わせのみ使用可能
`firstSide`（売買区分） | string | Required | `BUY`（買） `SELL`（売） ※firstSideで指定していない売買区分が2次注文の売買区分 
`firstExecutionType`（注文タイプ） | string | Required | `LIMIT`（指値） `STOP`（逆指値） 
`firstSize`（1次注文数量） | string | Required | 1次注文数量
`firstPrice`（1次注文レート） | string | Required | 1次注文レート
`secondSize`（2次注文数量） | string | Required | 2次注文数量
`secondLimitPrice`（2次指値注文レート） | string | Required | 2次指値注文レート
`secondStopPrice`（2次逆指値注文レート） | string | Required | 2次逆指値注文レート

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `IFDOCO`（取引区分: IFDOCO注文）
executionType | string | 注文タイプ: `LIMIT`（注文タイプ: 指値） `STOP`（逆指値） 
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済） 
size | string | 注文数量
price | string | 注文価格
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `ORDERED`（有効） `EXECUTED`（約定済） 
expiry | string | 注文有効期限
timestamp | string | 注文日時


<a id="change-order"></a>
## 注文変更

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/changeOrder';
const reqBody   = JSON.stringify({
    orderId: 123456789,
    price: "139"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456789,
        "symbol": "USD_JPY",　　                  
        "side": "BUY",
        "orderType": "NORMAL",
        "executionType": "LIMIT",
        "settleType": "OPEN",
        "size": "10000",　　　　　　　                
        "price": "139",
        "status": "ORDERED",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
    ],
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

注文変更をします。 

* `orderId`（注文ID） `clientOrderId`（顧客注文ID）いずれか1つが必須です。2つ同時には設定できません。

##### Request
`POST /private/v1/changeOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`orderId`（注文ID） | number | * | `orderId` `clientOrderId`（顧客注文ID） いずれか1つが必須
`clientOrderId`（顧客注文ID） | string | * | `orderId`（注文ID） `clientOrderId` いずれか1つが必須
`price`（注文レート） | string | Required | 注文レート


##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） 
executionType | string | 注文タイプ: `LIMIT`（注文タイプ: 指値） `STOP`（逆指値）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 注文数量
price | string | 注文価格 
status | string | 注文ステータス: `ORDERED`（注文ステータス: 有効） `MODIFYING`（変更中） `EXECUTED`（約定済） 
expiry | string | 注文有効期限
timestamp | string | 注文日時


<a id="change-oco-order"></a>
## OCO注文変更

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/changeOcoOrder';
const reqBody   = JSON.stringify({
  "clientOrderId": "abc123",
  "limitPrice": "140.525",
  "stopPrice": "145.607"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456789,
        "symbol": "USD_JPY",　　                  
        "side": "BUY",
        "orderType": "OCO",
        "executionType": "LIMIT",
        "settleType": "OPEN",
        "size": "10000",　　　　　　　                
        "price": "140.525",
        "status": "EXECUTED",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      },
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456790,
        "symbol": "USD_JPY",　　                  
        "side": "BUY",
        "orderType": "OCO",
        "executionType": "STOP",
        "settleType": "OPEN",
        "size": "10000",　　　　　　　                
        "price": "145.607",
        "status": "EXPIRED",
        "cancelType": "OCO",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
  ],
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

OCO注文変更をします。 

* `rootOrderId`（親注文ID） `clientOrderId`（顧客注文ID）いずれか1つが必須です。2つ同時には設定できません。
*  `limitPrice`（指値注文レート） `stopPrice`（逆指値注文レート） 両方もしくはどちらか1つが必須です。


##### Request
`POST /private/v1/changeOcoOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`rootOrderId`（親注文ID） | number | * | `rootOrderId` `clientOrderId`（顧客注文ID） いずれか1つが必須
`clientOrderId`（顧客注文ID） | string | * | `rootOrderId`（親注文ID） `clientOrderId` いずれか1つが必須
`limitPrice`（指値注文レート） | string | * | 指値注文レート ※  `limitPrice` `stopPrice`（逆指値注文レート）  両方もしくはどちらか1つ必須 
`stopPrice`（逆指値注文レート） | string | * | 逆指値注文レート ※  `limitPrice`（指値注文レート） `stopPrice`  両方もしくはどちらか1つ必須

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `OCO`（取引区分: OCO注文） 
executionType | string | 注文タイプ: `LIMIT`（注文タイプ: 指値） `STOP`（逆指値）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 注文数量
price | string | 注文価格 
status | string | 注文ステータス: `ORDERED`（注文ステータス: 有効） `MODIFYING`（変更中） `EXECUTED`（約定済） `EXPIRED`（失効）
cancelType | string | 取消区分: `OCO`（取消区分: OCO注文が約定されたことによる約定されていない側の注文の取消）   ※statusが`EXPIRED`の場合のみ返却
expiry | string | 注文有効期限
timestamp | string | 注文日時

<a id="change-ifd-order"></a>
## IFD注文変更

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/changeIfdOrder';
const reqBody   = JSON.stringify({
  "rootOrderId": 123456789,
  "firstPrice": "136.201",
  "secondPrice": "139.802"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456789,
        "symbol": "USD_JPY",　　                  
        "side": "BUY",
        "orderType": "IFD",
        "executionType": "LIMIT",
        "settleType": "OPEN",
        "size": "10000",　　　　　　　                
        "price": "136.201",
        "status": "ORDERED",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      },
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456790,
        "symbol": "USD_JPY",　　                  
        "side": "SELL",
        "orderType": "IFD",
        "executionType": "LIMIT",
        "settleType": "CLOSE",
        "size": "10000",　　　　　　　                
        "price": "139.802",
        "status": "WAITING",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
  ],
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

IFD注文変更をします。 

* `rootOrderId`（親注文ID） `clientOrderId`（顧客注文ID）いずれか1つが必須です。2つ同時には設定できません。
*  `firstPrice`（1次注文レート） `secondPrice`（2次注文レート） 両方もしくはどちらか1つが必須です。


##### Request
`POST /private/v1/changeIfdOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`rootOrderId`（親注文ID） | number | * | `rootOrderId` `clientOrderId`（顧客注文ID） いずれか1つが必須
`clientOrderId`（顧客注文ID） | string | * | `rootOrderId`（親注文ID） `clientOrderId` いずれか1つが必須
`firstPrice`（1次注文レート） | string | * | 1次注文レート ※  `firstPrice` `secondPrice`（2次注文レート）  両方もしくはどちらか1つ必須 
`secondPrice`（2次注文レート） | string | * | 2次注文レート ※  `firstPrice`（1次注文レート） `secondPrice`  両方もしくはどちらか1つ必須

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `IFD`（取引区分: IFD注文） 
executionType | string | 注文タイプ: `LIMIT`（注文タイプ: 指値） `STOP`（逆指値）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 注文数量
price | string | 注文価格 
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `ORDERED`（有効） `MODIFYING`（変更中） `EXECUTED`（約定済） 
expiry | string | 注文有効期限
timestamp | string | 注文日時


<a id="change-ifo-order"></a>
## IFDOCO注文変更

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/changeIfoOrder';
const reqBody   = JSON.stringify({
  "clientOrderId": "abc123",
  "firstPrice": "142.3",
  "secondLimitPrice": "136",
  "secondStopPrice": "143.1"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456789,
        "symbol": "USD_JPY",　　                  
        "side": "SELL",
        "orderType": "IFDOCO",
        "executionType": "LIMIT",
        "settleType": "OPEN",
        "size": "10000",　　　　　　　                
        "price": "142.3",
        "status": "ORDERED",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      },
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456790,
        "symbol": "USD_JPY",　　                  
        "side": "BUY",
        "orderType": "IFDOCO",
        "executionType": "LIMIT",
        "settleType": "CLOSE",
        "size": "10000",　　　　　　　                
        "price": "136",
        "status": "WAITING",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      },
      {
        "rootOrderId": 123456789,
        "clientOrderId": "abc123",
        "orderId": 123456791,
        "symbol": "USD_JPY",　　                  
        "side": "BUY",
        "orderType": "IFDOCO",
        "executionType": "STOP",
        "settleType": "CLOSE",
        "size": "10000",　　　　　　　                
        "price": "143.1",
        "status": "WAITING",
        "expiry" : "20190418",
        "timestamp": "2019-03-19T02:15:06.059Z"　 
      }
  ],
  "responsetime": "2019-03-19T02:15:06.059Z"
}
```

IFDOCO注文変更をします。 

* `rootOrderId`（親注文ID） `clientOrderId`（顧客注文ID）いずれか1つが必須です。2つ同時には設定できません。
*  `firstPrice`（1次注文レート） `secondLimitPrice`（2次指値注文レート）  `secondStopPrice`（2次逆指値注文レート） の内全てもしくはいずれか1つ以上が必須です。


##### Request
`POST /private/v1/changeIfoOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`rootOrderId`（親注文ID） | number | * | `rootOrderId` `clientOrderId`（顧客注文ID） いずれか1つが必須
`clientOrderId`（顧客注文ID） | string | * | `rootOrderId`（親注文ID） `clientOrderId` いずれか1つが必須
`firstPrice`（1次注文レート） | string | * | 1次注文レート ※  `firstPrice` `secondLimitPrice`（2次指値注文レート） `secondStopPrice`（2次逆指値注文レート）  の内全てもしくはいずれか1つ以上必須 
`secondLimitPrice`（2次指値注文レート） | string | * | 2次指値注文レート ※  `firstPrice`（1次注文レート） `secondLimitPrice`（2次指値注文レート） `secondStopPrice`（2次逆指値注文レート）  の内全てもしくはいずれか1つ以上必須
`secondStopPrice`（2次逆指値注文レート） | string | * | 2次逆指値注文レート ※  `firstPrice`（1次注文レート） `secondLimitPrice`（2次指値注文レート） `secondStopPrice`（2次逆指値注文レート）  の内全てもしくはいずれか1つ以上必須


##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `IFDOCO`（取引区分: IFDOCO注文） 
executionType | string | 注文タイプ: `LIMIT`（注文タイプ: 指値） `STOP`（逆指値）
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
size | string | 注文数量
price | string | 注文価格 
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `ORDERED`（有効） `MODIFYING`（変更中） `EXECUTED`（約定済） `EXPIRED`（失効）
cancelType | string | 取消区分: `OCO`（取消区分: OCO注文が約定されたことによる約定されていない側の注文の取消）   ※statusが`EXPIRED`の場合のみ返却
expiry | string | 注文有効期限
timestamp | string | 注文日時

<a id="cancel-orders"></a>
## 注文の複数キャンセル

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/cancelOrders';
const reqBody   = JSON.stringify({
    rootOrderIds: [123456789,223456789]
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
      "success": [
        {
          "clientOrderId": "abc123",
          "rootOrderId": 123456789
        },
        {
          "rootOrderId": 223456789
        }
      ]
  },
  "responsetime": "2019-03-19T01:07:24.557Z"
}
```

複数の注文を取消します。 

* `rootOrderIds`（複数親注文ID） `clientOrderIds`（複数顧客注文ID）いずれか1つが必須です。2つ同時には設定できません。
* 最大10件まで注文を取消することができます。

##### Request
`POST /private/v1/cancelOrders`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required                      | Available Values
--------- | ----------- |-------------------------------| -----------
`rootOrderIds`（複数親注文ID） | array | * | `rootOrderIds` `clientOrderIds`（複数顧客注文ID） いずれか1つが必須 ※親注文IDを最大10件まで指定可能
`clientOrderIds`（複数顧客注文ID） | array | * | `rootOrderIds`（複数親注文ID） `clientOrderIds` いずれか1つが必須 ※顧客注文IDを最大10件まで指定可能

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
success | array | 取消受付に成功した親注文IDと顧客注文ID ※顧客注文IDは設定した場合のみ返却

<a id="cancel-bulk-order"></a>
## 注文の一括キャンセル

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/cancelBulkOrder';
const reqBody   = JSON.stringify({
    symbols: ["USD_JPY","CAD_JPY"],
    side: "BUY",
    settleType: "OPEN"
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": {
    "success": [
      {
        "clientOrderId": "abc123",
        "rootOrderId": 123456789
      },
      {
        "rootOrderId": 223456789
      }
    ]
  },
  "responsetime": "2019-03-19T01:07:24.557Z"
}
```

一括で注文(通常注文、特殊注文いずれも)を取消します。 

* 取消対象検索後に、対象注文を全て取消します。
* 1次注文が約定していないIFD、IFDOCOケースでは1次注文もしくは2次注文にsideとsettleTypeの両方が一致するものが1つでもあれば注文全体を取消します。
* 1次注文が約定しているIFD、IFDOCOケースでは2次注文にsideとsettleTypeの両方が一致するものがあれば2次注文を取消します。

##### Request
`POST /private/v1/cancelBulkOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
`symbols`（銘柄名） | array | Required | 取扱銘柄は[こちら](#parameters-ref)
`side`（売買区分） | string | Optional | `BUY`（買） `SELL`（売） ※指定時のみ指定された売買区分の注文を取消条件に追加
`settleType`（決済区分） | string | Optional | `OPEN`（新規） `CLOSE`（決済） ※指定時のみ指定された決済区分の注文を取消条件に追加

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
success | array | 取消受付に成功した親注文IDと顧客注文ID ※顧客注文IDは設定した場合のみ返却

<a id="close-order"></a>
## 決済注文

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/closeOrder';
const reqBody   = JSON.stringify({
    "symbol": "USD_JPY",
    "side": "BUY",
    "clientOrderId": "abc123",
    "executionType": "LIMIT",
    "limitPrice": "135.5",
    "settlePosition": [
        {
            "positionId": 1000342,
            "size": "10000"
        }
    ]
})

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": [
    {
      "rootOrderId": 123456789,
      "clientOrderId": "abc123",
      "orderId": 123456789,
      "symbol": "USD_JPY",
      "side": "BUY",
      "orderType": "NORMAL",
      "executionType": "LIMIT",
      "settleType": "CLOSE",
      "size": "10000",
      "price": "135.5",
      "status": "WAITING",
      "expiry": "20230418",
      "timestamp": "2019-03-19T01:07:24.467Z"
    }
  ],
  "responsetime": "2019-03-19T01:07:24.557Z"
}
```

決済注文をします。 

* `size` `settlePosition`いずれか1つが必須です。2つ同時には設定できません。


##### Request
`POST /private/v1/closeOrder`

##### Parameters
* Parameter content type: `application/json`

Parameter | Type   | Required | Available Values
--------- |--------| ----------- | -----------
`symbol`（銘柄名） | string | Required | 取扱銘柄は[こちら](#parameters-ref)
`side`（売買区分） | string | Required | `BUY`（買） `SELL`（売）
`executionType`（注文タイプ） | string | Required | `MARKET`（成行） `LIMIT`（指値） `STOP`（逆指値） `OCO`（OCO注文）
`clientOrderId`（顧客注文ID） | string | Optional |  顧客注文ID ※36文字以内の半角英数字の組合わせのみ使用可能
`size`（注文数量） | string | * | 注文数量 建玉指定なし ※`size` `settlePosition`（複数建玉）いずれかのみ指定可能
`limitPrice`（注文レート） | string | *executionTypeによる | 注文レート ※`LIMIT`（注文タイプ: 指値） `OCO`（OCO注文）  の場合は必須
`stopPrice`（注文レート） | string | *executionTypeによる | 注文レート ※`STOP`（注文タイプ: 逆指値） `OCO`（OCO注文）  の場合は必須
`lowerBound`（成立下限価格） | string | Optional  | 成立下限価格 ※executionType:`MARKET`（注文タイプ: 成行） side: `SELL`（売買区分: 売）の場合に指定可能
`upperBound`（成立上限価格） | string | Optional  | 成立下限価格 ※executionType:`MARKET`（注文タイプ: 成行） side: `BUY`（売買区分: 買）の場合に指定可能
`settlePostion`（複数建玉） | array  | * | 複数建玉 複数指定可能 ※`size`（注文数量） `settlePosition`いずれかのみ指定可能 ※最大10件まで指定可能
`settlePosition.positionId`（建玉ID） | number | * | 建玉ID
`settlePosition.size`（注文数量） | string | * | 注文数量


##### Response

Property Name | Value | Description
--------- | ----------- | -----------
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） `OCO`（OCO注文）
executionType | string | 注文タイプ: `MARKET`（注文タイプ: 成行） `LIMIT`（指値） `STOP`（逆指値）
settleType | string | 決済区分: `CLOSE`（決済区分: 決済）
size | string | 注文数量
price | string | 注文価格 ※`LIMIT`（注文タイプ: 指値） `STOP`（逆指値）の場合のみ返却
status | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `EXECUTED`（約定済） `EXPIRED`（失効） 
cancelType | string | 取消区分: `PRICE_BOUND`（取消区分: 成立上下限価格超えによる注文の取消） `OCO`（OCO注文が約定されたことによる約定されていない側の注文の取消）  ※statusが`EXPIRED`の場合のみ返却
expiry | string | 注文有効期限
timestamp | string | 注文日時


<a id="private-ws-api"></a>
# Private WebSocket API

* サーバーから1分に1回クライアントへpingを送り、3回連続でクライアントからの応答(pong)が無かった場合は、自動的に切断されます。
* アクセストークンを取得・延長・削除するために[専用のPrivate API](#ws-auth-post)を使用します。
* Private WebSocket API接続時 `Private WebSocket APIのエンドポイント + アクセストークン` で接続してください。 例: `wss://forex-api.coin.z.com/ws/private/v1/xxxxxxxxxxxxxxxxxxxx`

<a id="ws-auth-post"></a>
## アクセストークンを取得

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'POST';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/ws-auth';
const reqBody   = JSON.stringify({});

const text = timestamp + method + path + reqBody;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.post(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "data": "xxxxxxxxxxxxxxxxxxxx",
  "responsetime": "2019-03-19T02:15:06.102Z"
}
```

Private WebSocket API用のアクセストークンを取得します。

* 有効期限は60分です。
* アクセストークンは最大5個まで発行できます。
* 発行上限を超えた場合、有効期限の近いトークンから順に削除されます。
* 発行済みのAPIキーを使ってアクセストークンを取得する場合、【会員ページ】-【API】-【編集】-【APIキーの編集】画面で「約定情報通知(WebSocket)」、「注文情報通知(WebSocket)」、「ポジション情報通知(WebSocket)」または「ポジションサマリー情報通知(WebSocket)」にチェックを入れてから、アクセストークンを取得します。

※APIキーの権限を編集する前に取得したアクセストークンには、編集後の権限設定は反映されませんので、ご注意ください。


##### Request
`POST /private/v1/ws-auth`


##### Parameters
無し

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
data | string | アクセストークン


<a id="ws-auth-put"></a>
## アクセストークンを延長

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'PUT';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/ws-auth';
const reqBody   = JSON.stringify({
    "token": "xxxxxxxxxxxxxxxxxxxx"
})

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    }
};

axios.put(endPoint + path, reqBody, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });

```

> Response example:

```json
{
  "status": 0,
  "responsetime": "2019-03-19T02:15:06.102Z"
}
```

Private WebSocket API用のアクセストークンを延長します。

* 延長前の残り有効期限に関わらず、新しい有効期限は60分となります。


##### Request
`PUT /private/v1/ws-auth`


##### Parameters
* Parameter type: JSON

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
token | string | Required | アクセストークン


<a id="ws-auth-delete"></a>
## アクセストークンを削除

> Request example:

```javascript
const axios  = require('axios');
const crypto = require('crypto');

const apiKey    = 'YOUR_API_KEY';
const secretKey = 'YOUR_SECRET_KEY';

const timestamp = Date.now().toString();
const method    = 'DELETE';
const endPoint  = 'https://forex-api.coin.z.com/private';
const path      = '/v1/ws-auth';
const reqBody   = JSON.stringify({
    "token": "xxxxxxxxxxxxxxxxxxxx"
})

const text = timestamp + method + path;
const sign = crypto.createHmac('sha256', secretKey).update(text).digest('hex');
const options = {
    "headers": {
        "API-KEY": apiKey,
        "API-TIMESTAMP": timestamp,
        "API-SIGN": sign
    },
    "data": reqBody,
};

axios.delete(endPoint + path, options)
  .then(function (response) {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(function (error) {
    console.log(error);
  });
```

> Response example:

```json
{
  "status": 0,
  "responsetime": "2019-03-19T02:15:06.102Z"
}
```

Private WebSocket API用のアクセストークンを削除します。


##### Request
`DELETE /private/v1/ws-auth`


##### Parameters
* Parameter type: JSON

Parameter | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
token | string | Required | アクセストークン


<a id="ws-execution-events"></a>
## 約定情報通知

> Request example:

```javascript
const WebSocket = require("ws");
const ws = new WebSocket("wss://forex-api.coin.z.com/ws/private/v1/xxxxxxxxxxxxxxxxxxxx");

ws.on("open", () => {
    const message = JSON.stringify(
    {
        "command": "subscribe",
        "channel": "executionEvents"
    });
    ws.send(message);
});

ws.on("message", (data) => {
    console.log("WebSocket message: ", data);
});
```

> Response example:

```json
{
  "channel": "executionEvents",
  "amount": "-30",
  "rootOrderId": 123456789,
  "orderId": 123456789,
  "clientOrderId": "abc123",
  "executionId": 72123911,
  "symbol": "USD_JPY",
  "settleType": "OPEN",
  "orderType":  "NORMAL",
  "executionType": "LIMIT",
  "side": "BUY",
  "executionPrice": "138.963",
  "executionSize": "10000",
  "positionId": 123456789,
  "lossGain": "0",
  "settledSwap": "0",
  "fee": "-30",
  "orderPrice": "140",
  "orderExecutedSize": "10000",
  "orderSize": "10000",
  "msgType": "ER",
  "orderTimestamp": "2019-03-19T02:15:06.081Z",
  "executionTimestamp": "2019-03-19T02:15:06.081Z"
}
```

最新の約定情報通知を受信します。 
`subscribe`（コマンド: 対象の配信を開始する）後、最新の約定情報通知が配信されます。


##### Parameters
* Parameter type: JSON

Property Name | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
command | string | Required | `subscribe`（コマンド: 対象の配信を開始する） `unsubscribe`（対象の配信を止める）
channel | string | Required | `executionEvents`（チャネル名: 約定情報通知）

##### Response

Property Name | Value  | Description
--------- |--------| -----------
channel | string | `executionEvents`（チャネル名: 約定情報通知）
amount | string | 受渡し金額
rootOrderId | number | 親注文ID
orderId | number | 注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
executionId | number | 約定ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） `OCO`（OCO注文） `IFD`（IFD注文） `IFDOCO`（IFDOCO注文） `LOSSCUT`（自動ロスカット注文） 
executionType | string | 注文タイプ: `MARKET`（注文タイプ: 成行） `LIMIT`（指値） `STOP`（逆指値）
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
executionPrice | string | 約定レート
executionSize | string | 約定数量
positionId | number | 建玉ID
lossGain | string | 決済損益
settledSwap | string | 決済スワップ
fee | string | 取引手数料 
orderPrice | string | 注文価格 ※`LIMIT`（注文タイプ: 指値） `STOP`（逆指値）の場合のみ返却
orderExecutedSize | string | 約定済み数量
orderSize | string | 注文数量
msgType | string | メッセージタイプ: `ER`（メッセージタイプ: 約定）
orderTimestamp | string | 注文日時
executionTimestamp | string | 約定日時

* `unsubscribe`（コマンド: 対象の配信を止める）でリクエストした場合のResponseはありません。


<a id="ws-order-events"></a>
## 注文情報通知

> Request example:

```javascript
const WebSocket = require("ws");
const ws = new WebSocket("wss://forex-api.coin.z.com/ws/private/v1/xxxxxxxxxxxxxxxxxxxx");

ws.on("open", () => {
    const message = JSON.stringify(
    {
        "command": "subscribe",
        "channel": "orderEvents"
    });
    ws.send(message);
});

ws.on("message", (data) => {
    console.log("WebSocket message: ", data);
});
```

> Response example:

```json
{
  "channel": "orderEvents",
  "rootOrderId": 123456789,
  "clientOrderId":"abc123",
  "orderId": 123456789,
  "symbol": "USD_JPY",
  "settleType": "OPEN",
  "orderType":  "NORMAL",
  "executionType": "LIMIT",
  "side": "BUY",
  "orderStatus": "ORDERED",
  "orderTimestamp": "2019-03-19T02:15:06.081Z",
  "orderPrice": "135",
  "orderSize": "10000",
  "expiry" : "20190418", 
  "msgType": "NOR"
}
```

最新の注文情報通知を受信します。 
`subscribe`（コマンド: 対象の配信を開始する）後、最新の注文情報通知が配信されます。


##### Parameters
* Parameter type: JSON

Property Name | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
command | string | Required | `subscribe`（コマンド: 対象の配信を開始する） `unsubscribe`（対象の配信を止める）
channel | string | Required | `orderEvents`（チャネル名: 注文情報通知）

##### Response

Property Name | Value | Description
--------- | ----------- | -----------
channel | string | `orderEvents`（チャネル名: 注文情報通知）
rootOrderId | number | 親注文ID
clientOrderId | string | 顧客注文ID ※設定した場合のみ返却
orderId | number | 注文ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
settleType | string | 決済区分: `OPEN`（決済区分: 新規） `CLOSE`（決済） `LOSS_CUT`（ロスカット）
orderType | string | 取引区分: `NORMAL`（取引区分: 通常注文） `OCO`（OCO注文） `IFD`（IFD注文） `IFDOCO`（IFDOCO注文） `LOSSCUT`（自動ロスカット注文） 
executionType | string | 注文タイプ: `MARKET`（注文タイプ: 成行） `LIMIT`（指値） `STOP`（逆指値）
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
orderStatus | string | 注文ステータス: `WAITING`（注文ステータス: 待機中） `ORDERED`（有効） `CANCELED`（取消済） `EXPIRED`（失効） 
cancelType | string | 取消区分: `USER`（取消区分: お客さまによる注文の取消） `INSUFFICIENT_COLLATERAL`（ロスカットによる決済注文の取消） `INSUFFICIENT_MARGIN`（取引余力の不足による注文の取消） `SPEED`（スピード注文による注文の取消） `OCO`（OCO注文が約定されたことによる約定されていない側の注文の取消） `EXPIRATION`（注文有効期限切れによる注文の取消） `PRICE_BOUND`（成立上下限価格超えによる注文の取消） `OUT_OF_SLIPPAGE_RANGE`（スリッページ範囲外による注文の取消）  ※statusが`CANCELED`または`EXPIRED`の場合のみ返却
orderTimestamp | string | 注文日時
orderPrice | string | 注文価格 ※`LIMIT`（注文タイプ: 指値） `STOP`（逆指値）の場合のみ返却
orderSize | string | 注文数量
expiry | string | 注文有効期限
msgType | string | メッセージタイプ: `NOR`（メッセージタイプ: 新規注文） `ROR`（注文変更） `COR`（注文取消） 

* `unsubscribe`（コマンド: 対象の配信を止める）でリクエストした場合のResponseはありません。

<a id="ws-position-events"></a>
## ポジション情報通知

> Request example:

```javascript
const WebSocket = require("ws");
const ws = new WebSocket("wss://forex-api.coin.z.com/ws/private/v1/xxxxxxxxxxxxxxxxxxxx");

ws.on("open", () => {
    const message = JSON.stringify(
    {
        "command": "subscribe",
        "channel": "positionEvents"
    });
    ws.send(message);
});

ws.on("message", (data) => {
    console.log("WebSocket message: ", data);
});
```

> Response example:

```json
{
  "channel": "positionEvents",
  "positionId": 1234567,
  "symbol": "USD_JPY",
  "side": "BUY",
  "size": "500",
  "orderdSize": "0",
  "price": "139.772",
  "lossGain": "-553.5",
  "timestamp": "2019-03-19T02:15:06.094Z",
  "totalSwap":"-34.4",
  "msgType": "UPR"
}
```

最新のポジション情報通知を受信します。 
`subscribe`（コマンド: 対象の配信を開始する）後、最新のポジション情報通知が配信されます。


##### Parameters
* Parameter type: JSON

Property Name | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
command | string | Required | `subscribe`（コマンド: 対象の配信を開始する） `unsubscribe`（対象の配信を止める）
channel | string | Required | `positionEvents`（チャネル名: ポジション情報通知）


##### Response

Property Name | Value | Description
--------- | ----------- | -----------
channel | string | `positionEvents`（チャネル名: ポジション情報通知）
positionId | number | 建玉ID
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
size | string | 建玉数量
orderdSize | string | 注文中数量
price | string | 建玉レート
lossGain | string | 評価損益
timestamp | string | 約定日時
totalSwap | string | 累計スワップ
msgType | string | メッセージタイプ: `OPR`（メッセージタイプ: ポジションオープン） `UPR`（ポジション部分決済） `CPR`（ポジションクローズ）

* `unsubscribe`（コマンド: 対象の配信を止める）でリクエストした場合のResponseはありません。

<a id="ws-position-summary-events"></a>
## ポジションサマリー情報通知

> Request example:

```javascript
const WebSocket = require("ws");
const ws = new WebSocket("wss://forex-api.coin.z.com/ws/private/v1/xxxxxxxxxxxxxxxxxxxx");

ws.on("open", () => {
    const message = JSON.stringify(
    {
        "command": "subscribe",
        "channel": "positionSummaryEvents",
        "option":"PERIODIC"
    });
    ws.send(message);
});

ws.on("message", (data) => {
    console.log("WebSocket message: ", data);
});
```

> Response example:

```json
{
  "channel":"positionSummaryEvents",
  "symbol":"USD_JPY",
  "side":"BUY",
  "averagePositionRate":"138.877",
  "positionLossGain":"3644808.1",
  "sumOrderedSize":"8000",
  "sumPositionSize":"1821000",
  "sumTotalSwap": "167407.6",
  "timestamp":"2020-06-24T09:53:19.702Z",
  "msgType":"PERIODIC"
}
```

最新のポジションサマリー情報通知を受信します。 
`subscribe`（コマンド: 対象の配信を開始する）後、最新のポジションサマリー情報通知が配信されます。


##### Parameters
* Parameter type: JSON

Property Name | Type | Required | Available Values
--------- | ----------- | ----------- | -----------
command | string | Required | `subscribe`（コマンド: 対象の配信を開始する） `unsubscribe`（対象の配信を止める）
channel | string | Required | `positionSummaryEvents`（チャネル名: ポジションサマリー情報通知）
option | string | Optional | `PERIODIC`（オプション: 定期的にデータを送信する） ※optionが指定された場合、5秒ごとにデータが送信されます。 ※複数回subscribeした場合は後にsubscribeしたものが有効となります。


#### Response

Property Name | Value | Description
--------- | ----------- | -----------
channel | string | `positionSummaryEvents`（チャネル名: ポジションサマリー情報通知）
symbol | string | 取扱銘柄は[こちら](#parameters-ref)
side | string | 売買区分: `BUY`（売買区分: 買） `SELL`（売）
averagePositionRate | string | 平均建玉レート
positionLossGain | string | 評価損益
sumOrderedSize | string | 注文中数量
sumPositionSize | string | 合計建玉数量
sumTotalSwap | string | 累計スワップ
timestamp | string | 配信日時
msgType | string | メッセージタイプ: `INIT`（メッセージタイプ: 初期配信） `UPDATE`（更新配信） `PERIODIC`（定期配信）

* `unsubscribe`（コマンド: 対象の配信を止める）でリクエストした場合のResponseはありません。


<a id="references"></a>
# リファレンス

APIのパラメータやレスポンスにより返ってくる各種コードについて説明します。

<a id="parameters-ref"></a>
## パラメータ

パラメータの値とその内容について説明します。

###  
symbol: 取扱銘柄名

Value | Description                   | Release date
----- |-------------------------------| -----
USD_JPY | 米ドル/日本円 | 2023/04/26
EUR_JPY | ユーロ/日本円 | 2023/04/26
GBP_JPY | 英ポンド/日本円 | 2023/04/26
AUD_JPY | 豪ドル/日本円 | 2023/04/26
NZD_JPY | NZドル/日本円 | 2023/04/26
CAD_JPY | カナダドル/日本円 | 2023/04/26
CHF_JPY | スイスフラン/日本円 | 2023/04/26
TRY_JPY | トルコリラ/日本円 | 2023/08/05
ZAR_JPY | 南アフリカランド/日本円 | 2023/08/05
MXN_JPY | メキシコペソ/日本円 | 2023/08/05
HUF_JPY | ハンガリーフォリント/日本円 | 2026/05/16
SEK_JPY | スウェーデンクローナ/日本円 | 2026/05/16
EUR_USD | ユーロ/米ドル | 2023/04/26
GBP_USD | 英ポンド/米ドル | 2023/04/26
AUD_USD | 豪ドル/米ドル | 2023/04/26
NZD_USD | NZドル/米ドル | 2023/04/26
EUR_GBP | ユーロ/英ポンド | 2026/05/16
AUD_NZD | 豪ドル/NZドル | 2026/05/16
AUD_CAD | 豪ドル/カナダドル | 2026/05/16
NZD_CAD | NZドル/カナダドル | 2026/05/16
NOK_SEK | ノルウェークローネ/スウェーデンクローナ | 2026/05/16

#### side: 売買区分

Value | Description
----- | -----
BUY | 買
SELL | 売

#### executionType: 注文タイプ

Value | Description
----- | -----
MARKET | 成行
LIMIT  | 指値
STOP  | 逆指値

<a id="http-status-code"></a>
## HTTPステータスコード
Status Code | Description
------------- | -----
200 | 処理が正常終了した場合に返ってくるコードです。
404 | `URLが不正な場合などに返ってくるコードです。`（例: https://forex-api.coin.z.com/publlic/v1/status などprivateやpublicの部分が不正な場合に発生します。）
503 | メンテナンス時にWebSocket APIを呼び出した場合に返ってくるコードです。

<a id="status-code"></a>
## ステータスコード

Status Code | Description
------------| -----------------------------
0           | 処理が正常終了した場合に返ってくるコードです。

<a id="error-code"></a>
## エラーコード

Error Code | Description
---------- | -----
ERR-143  | 規制中のため取引できない場合に返ってきます。
ERR-148  | IFD、IFDOCO注文において新規注文数量より決済注文数量が多い場合に返ってきます。
ERR-189  | 決済注文において、決済可能保有数量を超えての数量の注文の場合に返ってきます。
ERR-200  | すでに有効注文があり、注文数量が発注可能な数量を超えている場合に返ってきます。決済注文を行いたい場合は、注文数量を変更するか、有効注文を[取消](#cancel-orders)したうえで、再度[注文](#close-order)をしてください。
ERR-201  | 注文時に取引余力が不足している場合に返ってきます。
ERR-254  | 指定された建玉が存在しない場合に返ってきます。
ERR-414  | 決済注文において指定した銘柄と指定した建玉IDの銘柄が異なっている場合に返ってきます。
ERR-423  | 決済注文において注文数量が(指定した建玉、もしくは指定銘柄の建玉の)総建玉数量よりも大きい場合、もしくは総有効注文数量との合計が総建玉数量よりも大きい場合に返ってきます。
ERR-512  | 決済注文において同じ建玉IDを2つ以上指定した場合に返ってきます。
ERR-542  | OCO注文変更においてOCO注文以外の親注文IDや顧客注文IDを指定した場合に返ってきます。
ERR-595  | IFD、IFDOCO注文変更においてIFD、IFDOCO注文以外の親注文IDや顧客注文IDを指定した場合に返ってきます。
ERR-635  | 有効注文の件数が上限に達している場合に返ってきます。新規の注文をするためには、有効注文を[取消](#cancel-orders)したうえで、再度[注文](#order)をしてください。
ERR-759  | 建玉の件数が上限に達している場合に新規注文を行うと返ってきます。
ERR-760  | 注文変更において変更前と後で注文レートが同じ場合に返ってきます。
ERR-761  | 指定可能な注文レートの範囲を超えた場合に返ってきます。
ERR-769  | 注文変更において変更元となる注文の有効期限が切れている場合に返ってきます。
ERR-786  | 設定した顧客注文IDがご自身の他の有効注文に使用されている場合に返ってきます。
ERR-5003 | API呼出上限を越えた場合に返ってきます。
ERR-5008 | リクエストヘッダーに設定されているAPI-TIMESTAMPが公開APIのシステム時刻より遅い場合に返ってきます。その場合、システム時間の更新をお試しください。
ERR-5009 | リクエストヘッダーに設定されているAPI-TIMESTAMPが公開APIのシステム時刻より早い場合に返ってきます。その場合、システム時間の更新をお試しください。
ERR-5010 | リクエストヘッダーに指定されているAPI-SIGN（Signature）に不正がある場合に返ってきます。[認証](#authentication)情報についてご確認ください。
ERR-5011 | リクエストヘッダーにAPI-KEYが設定されていない場合に返ってきます。[認証](#authentication)情報についてご確認ください。
ERR-5012 | API-KEYが認証エラーの場合などに返ってきます。
ERR-5014 | お客様のご確認、ご同意が必要な処理を実行する際に、お客様に未確認・未同意事項がある場合に返ってきます。
ERR-5106 | パラメーターが不正な場合に返ってきます。
ERR-5114 | 注文レートが呼値の単位を超えている場合に返ってきます。取引ルールの呼値をご確認ください。取引ルールは[こちら](https://coin.z.com/jp/corp/product/info/fx/#rule)よりご確認いただけます。
ERR-5122 | 指定された注文がすでに変更中、取消中、取消済、全量約定、失効のいずれかの状態であるため、注文の変更や取消ができない場合に返ってきます。
ERR-5123 | 指定された注文番号が存在しない場合に返ってきます。
ERR-5125 | APIの取引規制がかかっている場合に返ってきます。
ERR-5126 | 1回あたりの最大注文数量を超えている場合または最小注文数量を下回っている場合、または最大建玉数量を超過する場合に返ってきます。[こちら](https://coin.z.com/jp/corp/product/info/fx/#rule)より取引ルールをご確認ください。（APIの最小注文数量は会員ページ・アプリとは異なるのでご注意ください）
ERR-5130 | 注文情報取得もしくは約定情報取得において指定した注文IDもしくは親注文IDが最大指定数量を超えている場合に返ってきます。
ERR-5132 | 約定情報取得において指定した約定IDが最大指定数量を超えている場合に返ってきます。
ERR-5201 | 定期メンテナンス時にPublic/Private APIを呼び出した場合に返ってきます。
ERR-5202 | 緊急メンテナンス時にPublic/Private APIを呼び出した場合に返ってきます。
ERR-5204 | `リクエスト時に各APIのURLが不正な場合に返ってきます。`（例: https://forex-api.coin.z.com/public/public/v1/status などprivateやpublicの部分以降のURLが不正な場合に発生します。）
ERR-5206 | 注文変更を実行時に注文毎の変更可能回数が上限に達している場合に返ってきます。上限に達して更に注文変更を行いたい場合は、1度[注文キャンセル](#cancel-orders)をしてから新規に[注文](#order)をしていただくようにお願い致します。
ERR-5207 | リクエストボディに指定されているsymbol、intervalまたはdateが不正な場合に返ってきます。
ERR-5208 | 約定情報取得において、orderId/executionIdが両方設定された場合に返ってきます。
ERR-5209 | 注文情報取得において、orderId/rootOrderIdが両方設定された場合に返ってきます。
ERR-5210 | 注文タイプと limitPrice/stopPriceが一致していない場合に返ってきます。
ERR-5211 | 売買区分と一致しない lowerBound/upperBound を指定した場合、もしくは指値や逆指値注文に lowerBound/upperBound を指定した場合に返ってきます。
ERR-5213 | 注文IDもしくは親注文IDと顧客注文IDどちらか一方を指定する箇所でどちらも指定している場合に返ってきます。
ERR-5214 | 決済注文において、建玉IDを指定している場合に注文数量を指定すると返ってきます。
ERR-5218 | 取引時間外のため注文が行えない場合に返ってきます。
ERR-5219 | 注文変更において通常注文以外の注文IDや顧客注文IDを指定した場合に返ってきます。
ERR-5220 | IFD注文において1次注文レートを2次注文レートより低く設定しなければならない場合に返ってきます。
ERR-5221 | IFD注文において1次注文レートを2次注文レートより高く設定しなければならない場合に返ってきます。
ERR-5222 | IFDOCO注文において1次注文レートを2次指値注文レートより低く設定しなければならない場合に返ってきます。
ERR-5223 | IFDOCO注文において1次注文レートを2次指値注文レートより高く設定しなければならない場合に返ってきます。
ERR-5224 | IFDOCO注文において1次注文レートを2次逆指値注文レートより高く設定しなければならない場合に返ってきます。
ERR-5225 | IFDOCO注文において1次注文レートを2次逆指値注文レートより低く設定しなければならない場合に返ってきます。
ERR-5226 | 逆指値の買い注文において、注文レートが現在レートより低い場合に返ってきます。
ERR-5227 | 逆指値の売り注文において、注文レートが現在レートより高い場合に返ってきます。
ERR-5228 | OCO売り注文において逆指値注文レートが指値注文レートを超えている場合に返ってきます。
ERR-5229 | OCO買い注文において逆指値注文レートが指値注文レートを下回っている場合に返ってきます。

<a id="feedback"></a>
# フィードバック
APIについてご要望をお聞かせください。いただいたご要望につきましては、開発チームにて精査のうえ、順次開発、リリースしております。 APIについてのご要望は、[こちら](https://support.coin.z.com/hc/ja/requests/new?ticket_form_id=360002450434)よりご連絡ください。

※APIに関するご質問などは、[こちら](https://support.coin.z.com/hc/ja/requests/new)よりお問い合わせください。内容によってはお時間をいただく場合がございます。あらかじめご了承ください。


<a id="changelogs"></a>
# 更新履歴

## 2026

###   2026-05-16 New
ハンガリーフォリント/円、スウェーデンクローナ/円、ユーロ/英ポンド、豪ドル/NZドル、豪ドル/カナダドル、NZドル/カナダドル、ノルウェークローネ/スウェーデンクローナを追加しました。
* **ParameterとResponseの `symbol`（銘柄名）に **`HUF_JPY`（ハンガリーフォリント/日本円） `SEK_JPY`（スウェーデンクローナ/日本円） `EUR_GBP`（ユーロ/英ポンド） `AUD_NZD`（豪ドル/NZドル） `AUD_CAD`（豪ドル/カナダドル） `NZD_CAD`（NZドル/カナダドル） `NOK_SEK`（ノルウェークローネ/スウェーデンクローナ）** を追加しました。**

## 2023

###   2023-12-16
2023年12月16日時点の各言語の最新バージョンに対応するよう、サンプルを更新しました。

###   2023-10-28
バージョン v1 をリリースしました。

