# Trading Strategies

Please contact <support@aquanow.io> to enable additional strategies.

### RFQ

RFQ orders allow users to make a request for a quote, then decide if they wish to execute that quote.

## Get an RFQ quote

<mark style="color:blue;">`GET`</mark> `https://api.aquanow.io/trades/v2/getQuote`

`getQuote` endpoint allows users to get an RFQ quote from Aquanow, and\
receive `quoteId` and `price` that is valid during the lifetime of the RFQ.

This endpoint is not executable and can only be used as a means of pricing your order.

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#14662004-8a4d-4236-a22e-af3bde7f7ac6) documentation.

#### Query Parameters

| Name                                              | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ticker<mark style="color:red;">\*</mark>          | String | <p>e.g., <code>BTC-USD</code></p><p>Currency pair</p>                                                                                                                                                                                                                                                                                                                                                                                      |
| accountId<mark style="color:red;">\*</mark>       | String | Identifier for account of the quote.                                                                                                                                                                                                                                                                                                                                                                                                       |
| tradeSide<mark style="color:red;">\*</mark>       | String | `"buy"` or `"sell"`                                                                                                                                                                                                                                                                                                                                                                                                                        |
| deliverQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency delivered by user based on the ticker and tradeSide. </p><p>For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, the delivered currency is <strong>USD. I</strong>f tradeSide is <strong>sell</strong>, the delivered currency is <strong>BTC.</strong></p> |
| receiveQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency received by user based on the ticker and tradeSide. </p><p>For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, the received currency is <strong>BTC. I</strong>f tradeSide is <strong>sell</strong>, the received currency is <strong>USD.</strong></p>    |

#### Headers

| Name                                          | Type   | Description                                                                                                                                                        |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| x-api-key<mark style="color:red;">\*</mark>   | String | <p><code>{{x-api-key}}</code></p><p>API Auth Key</p>                                                                                                               |
| x-signature<mark style="color:red;">\*</mark> | String | <p><code>32c92460f65cbb78d0eaf9a4361fb6b0a2bb8bb4c40f531e9974a0afc12d9a328b5ff621a544d242ee9ba1dfa799c85a</code></p><p>Signature created using your API secret</p> |
| x-nonce<mark style="color:red;">\*</mark>     | Number | <p><code>1657731573930</code></p><p>Timestamp in millisecond</p>                                                                                                   |

{% tabs %}
{% tab title="200: OK Get RFQ quote for buying BTC worth $1000 USD, see example request below" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "rfqGetQuoteAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "7b776a4f-c39a-438c-89eb-79d043bf75e7",
    "symbol": "BTC-USD",
    "side": "buy",
    "receiveCurrency": "BTC",
    "deliverCurrency": "USD",
    "quoteTime": 1738112576978,
    "expireTime": 1738112606978,
    "deliverQuantity": "202.18",
    "receiveQuantity": "0.00200000",
    "price": "101087.97"
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Ticker" %}

```json
{
    "errors": [
        {
            "id": "b8958e2f-955b-4cf3-b67e-b4aabfae095e",
            "message": "Product Not Supported"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Create an RFQ quote

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/trades/v2/createQuote`

`createQuote` endpoint allows user to initiate an RFQ request to Aquanow and receive a  `quoteId` and `price` that is valid during the lifetime of the RFQ.

<mark style="color:orange;">NOTE:</mark> Either `deliverQuantity` or `receiveQuantity` must be specified, not both.

If order is not filled, request returns a 200 response with `receiveQuantity` and `deliverQuantity` set to 0.

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#7de56c81-8376-4d6b-a7e8-a18bc6529ac0) documentation.

#### Headers

| Name                                          | Type   | Description                                                                                                                                                        |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| x-api-key<mark style="color:red;">\*</mark>   | String | <p><code>{{x-api-key}}</code></p><p>API Auth Key</p>                                                                                                               |
| x-signature<mark style="color:red;">\*</mark> | String | <p><code>32c92460f65cbb78d0eaf9a4361fb6b0a2bb8bb4c40f531e9974a0afc12d9a328b5ff621a544d242ee9ba1dfa799c85a</code></p><p>Signature created using your API secret</p> |
| x-nonce<mark style="color:red;">\*</mark>     | Number | <p><code>1657731573930</code></p><p>Timestamp in millisecond</p>                                                                                                   |

#### Request Body

| Name                                              | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ticker<mark style="color:red;">\*</mark>          | String | <p>e.g., <code>BTC-USD</code></p><p>Currency pair</p>                                                                                                                                                                                                                                                                                                                                                                                      |
| accountId<mark style="color:red;">\*</mark>       | String | Identifier for account of the quote.                                                                                                                                                                                                                                                                                                                                                                                                       |
| tradeSide<mark style="color:red;">\*</mark>       | String | `"buy"` or `"sell"`                                                                                                                                                                                                                                                                                                                                                                                                                        |
| deliverQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency delivered by user based on the ticker and tradeSide. </p><p>For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, the delivered currency is <strong>USD. I</strong>f tradeSide is <strong>sell</strong>, the delivered currency is <strong>BTC.</strong></p> |
| receiveQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency received by user based on the ticker and tradeSide. </p><p>For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, the received currency is <strong>BTC. I</strong>f tradeSide is <strong>sell</strong>, the received currency is <strong>USD.</strong></p>    |
| usernameRef                                       | String | A new reference string for sub-accounts. Must be less than 64 characters, cannot contain special characters.                                                                                                                                                                                                                                                                                                                               |

{% tabs %}
{% tab title="200: OK Create a quote using receiveQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "rfqCreateQuoteAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "87105bf9-5800-4c13-89af-bcbaa50abd32",
    "symbol": "BTC-USDT",
    "side": "buy",
    "receiveCurrency": "BTC",
    "deliverCurrency": "USDT",
    "quoteTime": 1738112706492,
    "expireTime": 1738112736492,
    "price": "100690",
    "deliverQuantity": "302.07",
    "receiveQuantity": "0.00300000"
  }
}
```

{% endtab %}

{% tab title="200: OK Create a quote using deliverQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "rfqCreateQuoteAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "9c309072-c9dc-402f-bb82-0bb764d173d5",
    "symbol": "BTC-USDT",
    "side": "buy",
    "receiveCurrency": "BTC",
    "deliverCurrency": "USDT",
    "quoteTime": 1738112638726,
    "expireTime": 1738112668726,
    "price": "100690",
    "deliverQuantity": "0.30",
    "receiveQuantity": "0.00000298"
  }
}
```

{% endtab %}

{% tab title="200: OK Insufficient funds " %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "Insufficient Trade Credit"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid trade side" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "Invalid tradeSide: buying"
    }
  ]
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request Invalid ticker" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "Invalid ticker: ETH-CADD"
    }
  ]
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request Trade size below required minimum" %}

```json
{
  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "Trade size must be bigger than minimum size 1e-7. You submitted: 1e-8"
    }
  ]
}
```

{% endtab %}

{% tab title="403: Forbidden User doesn't have trade permission" %}

```json
{
  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "Access Denied"
    }
  ]
}
```

{% endtab %}

{% tab title="500: Internal Server Error Strategy not enabled" %}

```json
{
  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "You don't have permission to do this, contact info@aquanow.io if you have questions"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Execute an RFQ Quote

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/trades/v2/executeQuote`

`executeQuote` endpoint allows users to execute a trade with a specified quoteId with the symbol, trade side and size within the time to live (TTL) of the request associated with the `quoteId`.&#x20;

<mark style="color:orange;">NOTE:</mark> The quote must be executed **BEFORE** the time expired. The TTL of a quote is **8 seconds** by default. If you wish to increase the expiry time, please contact Aquanow for support.

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#db28f60c-ea01-4c01-8489-985adb79979b) documentation.

#### Headers

| Name                                          | Type   | Description                                                                                                                                                        |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| x-api-key<mark style="color:red;">\*</mark>   | String | <p><code>{{x-api-key}}</code></p><p>API Auth Key</p>                                                                                                               |
| x-signature<mark style="color:red;">\*</mark> | String | <p><code>49c6260c194f4d7ed5cb917dc70b9821673246b2abc1cf28f05df6a75fd24181e00f8e57b321d15ae45db58b3bffe27a</code></p><p>Signature created using your API secret</p> |
| x-nonce<mark style="color:red;">\*</mark>     | Number | <p><code>1618307861949</code></p><p>Timestamp in millisecond</p>                                                                                                   |

#### Request Body

| Name                                      | Type   | Description              |
| ----------------------------------------- | ------ | ------------------------ |
| quoteId<mark style="color:red;">\*</mark> | String | `quoteId` to be executed |

{% tabs %}
{% tab title="200: OK " %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "rfqExecuteQuoteAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "06722222-1f6a-4e74-90aa-93ed2512c09c",
    "tradeDate": "2025-01-28",
    "valueDate": "2025-01-29"
  }
}
```

{% endtab %}

{% tab title="200: OK Expired quote" %}

```json
{
  "errors": [
    {
      "id": "ed68d20c-cbe8-4c6e-99ba-a3c1ebaf571c",
      "message": "The quote has already expired"
    }
  ]
}
```

{% endtab %}

{% tab title="403: Forbidden User doesn't have trade permission" %}

```json
{
  "errors": [
    {
      "id": "ed68d20c-cbe8-4c6e-99ba-a3c1ebaf571c",
      "message": "Access Denied"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Expire an RFQ Quote

<mark style="color:orange;">`PUT`</mark> `https://api.aquanow.io/trades/v1/expireQuote`

`expireQuote` endpoint allows users to expire a quote with a specified `quoteId` within the time to live (TTL) of the request associated with the `quoteId`.

<mark style="color:orange;">NOTE:</mark> The quote must be executed **BEFORE** the time expired. The TTL of a quote is **8 seconds** by default. If you wish to increase the expiry time, please contact Aquanow for support.

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#554045bb-9084-49a4-8c50-367d25f86f96) documentation.

#### Headers

| Name                                           | Type   | Description                                                                                                                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| x-api-key<mark style="color:red;">\*</mark>    | String | <p><code>{{x-api-key}}</code></p><p>API Auth Key</p>                                                                                                               |
| x-signature<mark style="color:red;">\*</mark>  | String | <p><code>49c6260c194f4d7ed5cb917dc70b9821673246b2abc1cf28f05df6a75fd24181e00f8e57b321d15ae45db58b3bffe27a</code></p><p>Signature created using your API secret</p> |
| x-nonce<mark style="color:red;">\*</mark>      | Number | <p><code>1657731573930</code></p><p>Timestamp in millisecond</p>                                                                                                   |
| Content-Type<mark style="color:red;">\*</mark> | String | `application/json`                                                                                                                                                 |

#### Request Body

| Name                                      | Type   | Description             |
| ----------------------------------------- | ------ | ----------------------- |
| quoteId<mark style="color:red;">\*</mark> | String | `quoteId` to be expired |

{% tabs %}
{% tab title="200: OK " %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "rfqExpireQuoteAck",
  "payload": {
    "quoteId": "6d187635-27df-4175-8b23-f1f0ec84907e"
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Expired or completed RFQ quote" %}

```json
{
  "errors": [
    {
      "id": "f8833c9b-2702-4b74-b987-faf84deafb4d",
      "message": "quoteId: 83d05d2b-003b-4e67-9ce7-99a426686f70 has alreaady been processed"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

### Market

Aquanow's Market execution strategy is utilized to perform instant executions.

## Create a market order

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/trades/v2/market`

<mark style="color:orange;">Note:</mark> Either deliverQuantity or receiveQuantity **must** be specified, not both.

If order is not filled, the request will return a 200 response, with receiveQuantity and deliverQuantity set to 0.

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#f9b0f1cb-658f-441c-b222-504a37268b67) documentation.

#### Headers

| Name                                           | Type   | Description                                                                                                                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| x-api-key<mark style="color:red;">\*</mark>    | String | <p><code>{{x-api-key}}</code></p><p>API Auth Key</p>                                                                                                               |
| x-signature<mark style="color:red;">\*</mark>  | String | <p><code>49c6260c194f4d7ed5cb917dc70b9821673246b2abc1cf28f05df6a75fd24181e00f8e57b321d15ae45db58b3bffe27a</code></p><p>Signature created using your API secret</p> |
| x-nonce<mark style="color:red;">\*</mark>      | Number | <p><code>1618307861949</code></p><p>Timestamp in millisecond</p>                                                                                                   |
| Content-Type<mark style="color:red;">\*</mark> | String | `application/json`                                                                                                                                                 |

#### Request Body

| Name                                              | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ticker<mark style="color:red;">\*</mark>          | String | <p><code>e.g., BTC-USD</code></p><p>Pair to be traded </p>                                                                                                                                                                                                                                                                                                                                                                                      |
| tradeSide<mark style="color:red;">\*</mark>       | String | `"buy"` or `"sell"` order                                                                                                                                                                                                                                                                                                                                                                                                                       |
| accountId<mark style="color:red;">\*</mark>       | String | Identifier for account the order will be applied to.                                                                                                                                                                                                                                                                                                                                                                                            |
| deliverQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> Specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency delivered by user based on the ticker and tradeSide. </p><p>For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, then the delivered currency is <strong>USD</strong>. If tradeSide is <strong>sell</strong>, the delivered currency is <strong>BTC</strong>.</p> |
| receiveQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> Specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency received by user based on the ticker and tradeSide. For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, then the received currency is <strong>BTC.</strong> If tradeSide is <strong>sell</strong>, the received currency is <strong>USD.</strong></p>           |
| usernameRef                                       | String | <p>A new reference string for sub-accounts. </p><p>Must be less than 64 characters, cannot contain special characters.</p>                                                                                                                                                                                                                                                                                                                      |

{% tabs %}
{% tab title="200: OK Sell BTC with deliverQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "marketOrderSubmitAck",
  "data": {
    "accountId": "CA1264810R",
    "orderId": "bf0bbd7e-1d30-43df-86c9-1f34ad7547f2",
    "receiveCurrency": "USD",
    "receiveQuantity": "2013.00",
    "deliverCurrency": "BTC",
    "deliverQuantity": "0.02000000",
    "fee": "0.00",
    "tradeDate": "2025-01-29",
    "valueDate": "2025-01-30",
    "tradePriceAvg": "100649.98"
  }
}
```

{% endtab %}

{% tab title="200: OK Buy BTC with receiveQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "marketOrderSubmitAck",
  "data": {
    "accountId": "CA1264810R",
    "orderId": "6112ef9f-e4c4-4138-b3a5-0b8722d3179c",
    "receiveCurrency": "BTC",
    "receiveQuantity": "0.02000000",
    "deliverCurrency": "USD",
    "deliverQuantity": "2021.68",
    "fee": "0.00000000",
    "tradeDate": "2025-01-29",
    "valueDate": "2025-01-30",
    "tradePriceAvg": "101083.86"
  }
}
```

{% endtab %}

{% tab title="200: OK Order not filled" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "marketOrderSubmitAck",
  "data": {
    "accountId": "CA1000051R",
    "orderId": "5ecfc1b2-cb8b-4a9c-8f95-0cf3081dc704",
    "receiveCurrency": "USD",
    "receiveQuantity": 0,
    "deliverCurrency": "BTC",
    "deliverQuantity": 0,
    "fee": 0
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Insufficient balance" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "Insufficient Trade Credit"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Missing receiveQuantity or deliverQuantity" %}

```javascript
{
  "errors": [
    {
      "id": "587c8447-31be-4c67-8e5b-ec9c09551361",
      "message": "message": "Either deliverQuantity or receiveQuantity must be specified, or must be bigger than 0"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Trade size below required minimum" %}
Returns an [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

```json
{
  "errors": [
    {
      "id": "0b2bfd39-14fc-4e0a-b69a-a26f2e77231c",
      "message": "The requested quantity is smaller than the minimum order size 15"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid ticker" %}

```json
{
  "errors": [
    {
      "id": "79af2407-6733-4218-b0d5-d0b6b7ed6b56",
      "message": "data/ticker must be equal to one of the allowed values"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid trade side" %}

```json
{
  "errors": [
    {
      "id": "79af2407-6733-4218-b0d5-d0b6b7ed6b56",
      "message": "Invalid tradeSide: selling"
    }
  ]
}
```

{% endtab %}

{% tab title="403: Forbidden User doesn't have trade permission" %}

```json
{
  "errors": [
    {
      "id": "79af2407-6733-4218-b0d5-d0b6b7ed6b56",
      "message": "Access Denied"
    }
  ]
}
```

{% endtab %}

{% tab title="502: Bad Gateway Strategy not enabled" %}

```json
{
  "errors": [
    {
      "id": "79af2407-6733-4218-b0d5-d0b6b7ed6b56",
      "message": "User not authorized for MARKET"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

### FOK

Fill or Kill order strategy will execute the entire order immediately at the market or specified price, otherwise it will cancelled if not filled.

## Endpoint to initiate a FOK request to Aquanow.

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/trades/v2/order`

<mark style="color:orange;">NOTE:</mark> Either **deliverQuantity**, **receiveQuantity** must be specified, not both.

If order is not filled, the request will return a 200 response with a Cancelled message.

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#43eb9944-0974-4409-b2d6-b5da0057de30) documentation.

#### Headers

| Name                                           | Type   | Description                                                                                                                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| x-api-key<mark style="color:red;">\*</mark>    | String | <p><code>{{x-api-key}}</code></p><p>API Auth Key</p>                                                                                                               |
| x-signature<mark style="color:red;">\*</mark>  | String | <p><code>49c6260c194f4d7ed5cb917dc70b9821673246b2abc1cf28f05df6a75fd24181e00f8e57b321d15ae45db58b3bffe27a</code></p><p>Signature created using your API secret</p> |
| x-nonce<mark style="color:red;">\*</mark>      | Number | <p><code>1618307861949</code></p><p>Timestamp in millisecond</p>                                                                                                   |
| Content-Type<mark style="color:red;">\*</mark> | String | `application/json`                                                                                                                                                 |

#### Request Body

| Name                                              | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| strategy<mark style="color:red;">\*</mark>        | String | `"FOK"`                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| accountId<mark style="color:red;">\*</mark>       | String | Identifier for account the order will be applied to.                                                                                                                                                                                                                                                                                                                                                                                       |
| ticker<mark style="color:red;">\*</mark>          | String | <p>e.g., <code>BTC-CAD</code></p><p>Currency pair</p>                                                                                                                                                                                                                                                                                                                                                                                      |
| tradeSide<mark style="color:red;">\*</mark>       | String | `"buy"` or `"sell"`                                                                                                                                                                                                                                                                                                                                                                                                                        |
| receiveQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency received by user based on the ticker and tradeSide. </p><p>For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, the received currency is <strong>BTC. I</strong>f tradeSide is <strong>sell</strong>, the received currency is <strong>USD.</strong></p>    |
| deliverQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency delivered by user based on the ticker and tradeSide. </p><p>For example, if ticker is BTC-USD and tradeSide is <strong>buy</strong>, the delivered currency is <strong>USD. I</strong>f tradeSide is <strong>sell</strong>, the delivered currency is <strong>BTC.</strong></p> |
| tradePrice<mark style="color:red;">\*</mark>      | String | Trade price of ticker symbol                                                                                                                                                                                                                                                                                                                                                                                                               |
| usernameRef                                       | String | <p>A new reference string for sub-accounts. </p><p>Must be less than 64 characters, cannot contain special characters.</p>                                                                                                                                                                                                                                                                                                                 |

{% tabs %}
{% tab title="200: OK Order filled successfully" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "parentOrderSubmitAck",
  "data": {
    "accountId": "CA1264810R",
    "orderId": "0f7f11e8-1c49-4636-b325-713ba3f3a68f",
    "receiveCurrency": "USD",
    "receiveQuantity": "201304.04",
    "deliverCurrency": "BTC",
    "deliverQuantity": "2.00000000",
    "fee": "0",
    "tradeTime": 1738113778441,
    "symbol": "BTC-USD",
    "tradeStatus": "COMPLETE",
    "price": "100652.02",
    "tradeDate": "2025-01-29",
    "valueDate": "2025-01-30"
  }
}
```

{% endtab %}

{% tab title="200: OK Order not filled" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "parentOrderSubmitAck",
  "error": {
    "message": "Cancelled - Price not marketable"
  },
  "data": {
    "orderId": "ac211046-57e3-43c7-9030-a939bf451c44",
    "receiveCurrency": "BTC",
    "receiveQuantity": 0,
    "deliverCurrency": "USD",
    "deliverQuantity": 0,
    "fee": 0,
    "tradeTime": 1712856904480,
    "symbol": "BTC-USD",
    "tradeStatus": "CANCELLED",
    "price": 70228.01
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Insufficient balance" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
    "errors": [
        {
            "id": "11642d44-3031-4bc1-8b55-61a2bd08fa42",
            "message": "Error while calculating trade price and quantities: Quantity 20000 exceeds data limits. Please use a smaller amount."
        }
    ]
}
```

{% endtab %}

{% tab title="400: Bad Request Missing deliverQuantity and receiveQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
    "errors": [
        {
            "id": "11642d44-3031-4bc1-8b55-61a2bd08fa42",
            "message": "provide at least one baseQuantity and quoteQuantity to be non-zero"
        }
    ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid tradeSide" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
    "errors": [
        {
            "id": "11642d44-3031-4bc1-8b55-61a2bd08fa42",
            "message": "data/tradeSide must be equal to one of the allowed values"
        }
    ]
}
```

{% endtab %}

{% tab title="403: Forbidden User doesn't have trade permission" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
    "errors": [
        {
            "id": "11642d44-3031-4bc1-8b55-61a2bd08fa42",
            "message": "User is not authorized to access this resource with an explicit deny"
        }
    ]
}
```

{% endtab %}

{% tab title="502: Bad Gateway Strategy not enable" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
    "errors": [
        {
            "id": "11642d44-3031-4bc1-8b55-61a2bd08fa42",
            "message": "User not authorized for FOK"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### LIMIT/GTC/GTD

Aquanow's duration order algorithms with a price limit.

Orders can be completed immediately depending on the specified priceLimit, quantity and the market. Incomplete pre-existing orders expire depending on the strategy.

#### Duration Order Algorithms

#### **LIMIT**

LIMIT orders create a pre-existing order, available for up to 24 hours.

#### GTC

Good Till Cancel (GTC) orders create a pre-existing order, available for up to 90 days.

#### GTD

Good Till Date (GTD) orders create a pre-existing order, available until a specified `expirationTime` date (max. 90 days).

## Endpoint to initiate an LIMIT/GTC/GTD request to Aquanow.

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/trades/v2/order`

<mark style="color:orange;">NOTE:</mark> Either **deliverQuantity** or **receiveQuantity** must be specified, not both.

If order is not filled, the request will return a 200 response with receiveQuantity and deliverQuantity set to 0.

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#8bc626a6-97e7-4421-a62c-8bb19ab1ee15) documentation.

#### Headers

| Name                                           | Type   | Description                                                                                                                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| x-api-key<mark style="color:red;">\*</mark>    | String | <p><code>{{x-api-key}}</code></p><p>API Auth Key</p>                                                                                                               |
| x-signature<mark style="color:red;">\*</mark>  | String | <p><code>49c6260c194f4d7ed5cb917dc70b9821673246b2abc1cf28f05df6a75fd24181e00f8e57b321d15ae45db58b3bffe27a</code></p><p>Signature created using your API secret</p> |
| x-nonce<mark style="color:red;">\*</mark>      | Number | <p><code>1618307861949</code></p><p>Timestamp in millisecond</p>                                                                                                   |
| Content-Type<mark style="color:red;">\*</mark> | String | `application/json`                                                                                                                                                 |

#### Request Body

| Name                                              | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| strategy<mark style="color:red;">\*</mark>        | String | `"LIMIT"`, `"GTC"` or `"GTD"`                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| accountId<mark style="color:red;">\*</mark>       | String | Identifier for account the order will be applied to.                                                                                                                                                                                                                                                                                                                                                                                                             |
| ticker<mark style="color:red;">\*</mark>          | String | <p>e.g., <code>BTC-CAD</code></p><p>Currency pair</p>                                                                                                                                                                                                                                                                                                                                                                                                            |
| tradeSide<mark style="color:red;">\*</mark>       | String | `"buy"` or `"sell"`                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| priceLimit<mark style="color:red;">\*</mark>      | String | Limit price of a ticker symbol, determined by `tradeSide` and `deliverQuantity`/`receiveQuantity`                                                                                                                                                                                                                                                                                                                                                                |
| deliverQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency delivered by user based on the ticker and tradeSide. </p><p>For example, if ticker is <strong>BTC-USD</strong> and tradeSide is <strong>buy</strong>, then the delivered currency is <strong>USD.</strong> If tradeSide is <strong>sell,</strong> the delivered currency is <strong>BTC.</strong></p> |
| receiveQuantity<mark style="color:red;">\*</mark> | String | <p><mark style="color:orange;">NOTE:</mark> specify either <code>deliverQuantity</code> or <code>receiveQuantity</code>.</p><p></p><p>Quantity of currency received by user based on the ticker and tradeSide. </p><p>For example, if ticker is <strong>BTC-USD</strong> and tradeSide is <strong>buy</strong>, then the received currency is <strong>BTC.</strong> If tradeSide is <strong>sell,</strong> the received currency is <strong>USD.</strong></p>    |
| expirationTime<mark style="color:red;">\*</mark>  | Number | <p><mark style="color:orange;">NOTE:</mark> only required for <strong>GTD</strong> orders.</p><p></p><p>e.g., <code>1669972404350</code></p><p>Expiration time in milliseconds of when the pre-existing order will expire. Expiration time must be within 90 days of order creation.</p>                                                                                                                                                                         |
| usernameRef                                       | String | A new reference string for sub-accounts. Must be less than 64 characters, cannot contain special characters.                                                                                                                                                                                                                                                                                                                                                     |

{% tabs %}
{% tab title="200: OK LIMIT buy BTC with receiveQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "limitOrderAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "8a492aa4-46b2-41d3-a47e-1d366e4e7693",
    "quoteTime": 1738091135962,
    "expireTime": 1738177535962,
    "ticker": "BTC-USD",
    "tradeSide": "buy",
    "receiveCurrency": "BTC",
    "receiveQuantity": "0.02000000",
    "deliverCurrency": "USD",
    "deliverQuantity": "2044.27",
    "price": "102536.06"
  }
}
```

{% endtab %}

{% tab title="200: OK LIMIT sell BTC with deliverQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "limitOrderAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "34bb8cea-314c-4fc0-83c8-fb5063d66a8f",
    "quoteTime": 1738091795908,
    "expireTime": 1738178195908,
    "ticker": "BTC-USD",
    "tradeSide": "sell",
    "receiveCurrency": "USD",
    "receiveQuantity": "1526847.30",
    "deliverCurrency": "BTC",
    "deliverQuantity": "15.00000000",
    "price": "102536.06"
  }
}
```

{% endtab %}

{% tab title="200: OK GTC buy BTC with deliverQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "gtcOrderAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "52a5b418-9ab0-45b4-9ad5-24a376380066",
    "quoteTime": 1738091646944,
    "expireTime": 1745867646944,
    "ticker": "BTC-USD",
    "tradeSide": "buy",
    "receiveCurrency": "BTC",
    "receiveQuantity": "0.00979612",
    "deliverCurrency": "USD",
    "deliverQuantity": "1000.00",
    "price": "102028.52"
  }
}
```

{% endtab %}

{% tab title="200: OK GTC sell BTC with receiveQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "gtcOrderAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "0094190d-6ebb-455d-afb9-ede8b716ab73",
    "quoteTime": 1738091948484,
    "expireTime": 1745867948484,
    "ticker": "BTC-USD",
    "tradeSide": "sell",
    "receiveCurrency": "USD",
    "receiveQuantity": "1000.00",
    "deliverCurrency": "BTC",
    "deliverQuantity": "0.00981527",
    "price": "102028.52"
  }
}
```

{% endtab %}

{% tab title="200: OK GTD buy BTC with deliverQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "gtdOrderAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "0c317868-3207-4f94-ad5a-47635cf00a85",
    "quoteTime": 1738092098363,
    "expireTime": 1738351211363,
    "ticker": "BTC-USD",
    "tradeSide": "buy",
    "receiveCurrency": "BTC",
    "receiveQuantity": "0.01000000",
    "deliverCurrency": "USD",
    "deliverQuantity": "1023.15",
    "price": "102299.79"
  }
}
```

{% endtab %}

{% tab title="200: OK GTD sell BTC with receiveQuantity" %}
Returns an [OrdersV2Object](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects#ordersv2object).

```json
{
  "type": "gtdOrderAck",
  "data": {
    "accountId": "CA1264810R",
    "quoteId": "566b0333-c7d4-4086-8c04-5ab3a6a29280",
    "quoteTime": 1738092132480,
    "expireTime": 1738351211480,
    "ticker": "BTC-USD",
    "tradeSide": "sell",
    "receiveCurrency": "USD",
    "receiveQuantity": "100.00",
    "deliverCurrency": "BTC",
    "deliverQuantity": "0.00098161",
    "price": "102299.79"
  }
}
```

{% endtab %}

{% tab title="400: Bad Request GTD order error, invalid expirationTime" %}

```javascript
{
  "errors": [
    {
      "id": "ea640ecc-0b9f-4857-9535-a45c0a6753da",
      "message": "expirationTime should be within 90 days from now: 1869972405009"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request GTD order error, missing expirationTime" %}

```javascript
{
  "errors": [
    {
      "id": "60a6a307-d980-43f5-b2cb-9b7d6c6af935",
      "message": "data must have required property 'expirationTime'"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid ticker" %}

```json
{
  "errors": [
    {
      "id": "60a6a307-d980-43f5-b2cb-9b7d6c6af935",
      "message": "data/ticker must be equal to one of the allowed values"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid trade side" %}

```json
{
  "errors": [
    {
      "id": "60a6a307-d980-43f5-b2cb-9b7d6c6af935",
      "message": "data/tradeSide must be equal to one of the allowed values"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Insufficient funds" %}
Returns an [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects#executionsobject).

```json
{
  "errors": [
    {
      "id": "ea640ecc-0b9f-4857-9535-a45c0a6753da",
      "message": "Insufficient Trade Credit"
    }
  ]
}
```

{% endtab %}

{% tab title="400: Bad Request Trade size below minimum" %}

```json
{
  "errors": [
    {
      "id": "03b84aef-0c04-438b-a6a4-531a318c513b",
      "message": "The requested quantity is smaller than the minimum order size 15"
    }
  ]
}
```

{% endtab %}

{% tab title="403: Forbidden User doesn't have trade permission" %}

```json
{
  "errors": [
    {
      "id": "60a6a307-d980-43f5-b2cb-9b7d6c6af935",
      "message": "Access Denied"
    }
  ]
}
```

{% endtab %}

{% tab title="502: Bad Gateway Strategy not enabled" %}

```json
{
  "errors": [
    {
      "id": "60a6a307-d980-43f5-b2cb-9b7d6c6af935",
      "message": "User not authorized for LIMIT"
    }
  ]
}
```

{% endtab %}
{% endtabs %}
