# Sub Account Trading

## Action Quote

`POST /v2/accounts/{accountId}/action-quote`

Action a previously received quote.

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `accountId` | path | Yes | string | The account you want to call to be actioned for |

**Request Body** _(required)_

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | This is your client reference id that you supplied when requesting the specific quote that you wish to action. (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |

**Responses**

- **204**: Ok
- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |

- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


**Example**

```bash
curl -X POST "https://api.demo.omniaexchange.com/api/v2/accounts/{accountId}/action-quote" \
  -H "Content-Type: application/json" \
  -d '{"instructionId": "375b23de-febf-4a6e-a517-e7b5dfa9357c"}'
```

---

## Order Status

`GET /v2/accounts/{accountId}/order/{source}/{instructionId}`

Check the status of an order made by the sub account

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `accountId` | path | Yes | string | The account you want to call to be actioned for |
| `source` | path | Yes | string | If trading via API use OFFCHAIN, else specify the blockchain you want to check your order status on (e.g. `OFFCHAIN`) |
| `instructionId` | path | Yes | string | Instruction Id - If order placed via api this is the client specified id. If placed on chain this is the transaction id (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | Instruction Id (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `orderSource` | string | Order Source |
  | `sellingAsset` | string | Selling Asset (e.g. `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) |
  | `buyingAsset` | string | Buying Asset (e.g. `0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE`) |
  | `amountToSell` | string | Amount To Sell (e.g. `5.67`) |
  | `limitAmountToReceive` | string | Limit Amount To Receive (e.g. `10433.1`) |
  | `status` | string | Status (e.g. `COMPLETED`) |
  | `rejectionReason` | string | Rejection reason |
  | `amountReceived` | string | Amount Received (e.g. `12932.1`) |
  | `feePaid` | string | Fee Paid (e.g. `0.042`) |
  | `transactionId` | string | Transaction Id (e.g. `0x99687859ddbe6050ca9615b7a5ae7b202f856ff289255758216b16887cd072f6`) |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v2/accounts/{accountId}/order/{source}/{instructionId}"
```

---

## Submit Order

`POST /v2/accounts/{accountId}/orders`

Swap assets using a market or limit order. Specify how much of a given asset you want to sell.

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `accountId` | path | Yes | string | The account you want to call to be actioned for |

**Request Body** _(required)_

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | This is your client reference id for the order. This can be any string less than 64 in length and needs to be unique per order (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `sellingAsset` | string | Asset you wish to sell (e.g. `USD`) |
  | `buyingAsset` | string | Asset you wish to buy (e.g. `EUR`) |
  | `amountToSell` | string | Amount to sell of the selling asset (e.g. `5.67`) |
  | `limitAmountToReceive` | string | The minimum amount of the buying asset you want to receive (e.g. `5.5`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | Instruction Id (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `sellingAsset` | string | Selling Asset (e.g. `btc`) |
  | `buyingAsset` | string | Buying Asset (e.g. `usd`) |
  | `amountToSell` | string | Amount To Sell (e.g. `5.1`) |
  | `limitAmountToReceive` | string | Limit Amount To Receive (e.g. `10433.1`) |
  | `status` | string | Status (e.g. `COMPLETED`) |
  | `rejectionReason` | string | Rejection reason |
  | `amountReceived` | string | Amount Received (e.g. `12932.1`) |
  | `feePaid` | string | Fee Paid (e.g. `0.042`) |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |

- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


**Example**

```bash
curl -X POST "https://api.demo.omniaexchange.com/api/v2/accounts/{accountId}/orders" \
  -H "Content-Type: application/json" \
  -d '{"instructionId": "375b23de-febf-4a6e-a517-e7b5dfa9357c", "sellingAsset": "USD", "buyingAsset": "EUR", "amountToSell": "5.67", "limitAmountToReceive": "5.5"}'
```

---

## Get Order Status

`GET /v3/accounts/{accountId}/order-status/{source}/{orderId}`

Returns the status of a given order id for a given source (chain).

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `accountId` | path | Yes | string | The account you want to call to be actioned for |
| `source` | path | Yes | string | If trading via API use OFFCHAIN, else specify the blockchain you want to check your order status (e.g. `ETHEREUM`) |
| `orderId` | path | Yes | integer | OrderId of the on chain order (e.g. `42`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | Instruction Id - If order placed via api this is the client specified id. If placed on chain this is the transaction id (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `returnTxId` | string | Return Transaction Id - If OFFCHAIN order this is null. If on chain this is the transaction id of the return transaction (Settle/Cancel) (e.g. `0x99687859ddbe6050ca9615b7a5ae7b202f856ff289255758216b16887cd072f6`) |
  | `orderSource` | string | Source (e.g. `OFFCHAIN`) |
  | `sellingAsset` | string | Selling Asset (e.g. `btc`) |
  | `buyingAsset` | string | Buying Asset (e.g. `usd`) |
  | `quantitySold` | string | Amount Sold (e.g. `5.67`) |
  | `quantityBought` | string | Amount Received (e.g. `12932.1`) |
  | `limitAmount` | string | Limit Amount To Specified (e.g. `12932.1`) |
  | `status` | string | Status (e.g. `SETTLED`) |
  | `timestampMillis` | string | Timestamp (e.g. `1653480000000`) |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |

- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v3/accounts/{accountId}/order-status/{source}/{orderId}"
```

---

## Request Quote

`POST /v2/accounts/{accountId}/request-quote`

Request a firm quote to swap some assets. Specify how much of an asset you want to receive.

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `accountId` | path | Yes | string | The account you want to call to be actioned for |

**Request Body** _(required)_

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | This is your client reference id for the quote. This can be any string less than 64 in length and needs to be unique. (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `sellingAsset` | string | Selling Asset (e.g. `USD`) |
  | `buyingAsset` | string | Buying Asset (e.g. `EUR`) |
  | `amountToBuy` | string | Amount of buying asset you want (e.g. `5.67`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `instructionId` | string | Instruction Id - the id you specified on the request (e.g. `375b23de-febf-4a6e-a517-e7b5dfa9357c`) |
  | `sellingAsset` | string | Selling Asset (e.g. `USD`) |
  | `buyingAsset` | string | Buying Asset (e.g. `EUR`) |
  | `amountToBuy` | string | Amount To Buy (e.g. `5.67`) |
  | `amountToSell` | string | Amount To Sell (e.g. `12932.1`) |
  | `expiryTimestampMillis` | string | Time the quote expires - Epoch milliseconds (e.g. `1653480000000`) |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |

- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


**Example**

```bash
curl -X POST "https://api.demo.omniaexchange.com/api/v2/accounts/{accountId}/request-quote" \
  -H "Content-Type: application/json" \
  -d '{"instructionId": "375b23de-febf-4a6e-a517-e7b5dfa9357c", "sellingAsset": "USD", "buyingAsset": "EUR", "amountToBuy": "5.67"}'
```

---

