# 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/v1/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>                                                                                                                                                                                                                                                                                                                                                                                      |
| tradeSide<mark style="color:red;">\*</mark>       | String | `"buy"` or `"sell"`                                                                                                                                                                                                                                                                                                                                                                                                                        |
| deliverQuantity<mark style="color:red;">\*</mark> | Number | <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> | Number | <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 [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

```json
{
  "type": "rfqGetQuoteAck",
  "payload": {
    "quoteId": "b9593fd0-db2d-4e22-8c6b-2e9d5a3226f7",
    "quoteTime": 1657595867140,
    "expireTime": 1657595917140,
    "symbol": "BTC-USD",
    "side": "buy",
    "receiveCurrency": "BTC",
    "receiveQuantity": 0.0495602273,
    "deliverCurrency": "USD",
    "deliverQuantity": 1000,
    "price": 20177.47
  }
}
```

{% endtab %}
{% endtabs %}

## Create an RFQ quote

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/trades/v1/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. If both are specified, `receiveQuantity` will be considered for **sell** orders, and `deliverQuantity` will be considered for **buy** orders.

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>                                                                                                                                                                                                                                                                                                                                                                                      |
| tradeSide<mark style="color:red;">\*</mark>       | String | `"buy"` or `"sell"`                                                                                                                                                                                                                                                                                                                                                                                                                        |
| deliverQuantity<mark style="color:red;">\*</mark> | Number | <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> | Number | <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 [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

```json
{
  "type": "rfqCreateQuoteAck",
  "payload": {
    "quoteId": "474a8cb0-0484-46d8-909e-1c1a65cd200d",
    "quoteTime": 1628112496153,
    "expireTime": 1628112508153,
    "symbol": "ETH-CAD",
    "side": "buy",
    "receiveCurrency": "ETH",
    "receiveQuantity": 0.1,
    "deliverCurrency": "CAD",
    "deliverQuantity": 340.45,
    "price": 3404.5
  }
}
```

{% endtab %}

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

```json
{
  "type": "rfqCreateQuoteAck",
  "payload": {
    "quoteId": "be267600-edd8-4b61-8b85-528223d61e17",
    "quoteTime": 1628114160054,
    "expireTime": 1628114172054,
    "symbol": "ETH-CAD",
    "side": "buy",
    "receiveCurrency": "ETH",
    "receiveQuantity": 0.0292817194,
    "deliverCurrency": "CAD",
    "deliverQuantity": 100,
    "price": 3415.1
  }
}
```

{% endtab %}

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

```json
{
  "type": "rfqCreateQuoteAck",
  "error": {
    "message": "Aqua: Insufficient funds"
  },
  "payload": {
    "quoteId": "33e0a6d6-f7be-4c6b-864e-a28510a3c474"
  }
}
```

{% endtab %}

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

```json
{
    "message": "Invalid tradeSide: buying"
}
```

{% endtab %}

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

```json
{
    "message": "Invalid ticker: ETH-CADD"
}
```

{% endtab %}

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

```json
{
    "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
{
    "message": "Access Denied"
}
```

{% endtab %}

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

```json
{
    "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/v1/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 [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

```json
{
  "type": "rfqExecuteQuoteAck",
  "payload": {
    "quoteId": "205feb16-0135-401b-84ce-a27e12d42453"
  }
}
```

{% endtab %}

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

```json
{
    "message": "The quote has already expired"
}
```

{% endtab %}

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

```json
{
    "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 [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

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

{% endtab %}

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

```javascript
{
  "message": "quoteId: 6d187635-27df-4175-8b23-f1f0ec84907e 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/v1/market`

<mark style="color:orange;">Note:</mark> Either deliverQuantity or receiveQuantity **must** be specified. If both are specified, receiveQuantity will be considered for sell orders, and deliverQuantity will be considered for buy orders.

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                                                                                                                                                                                                                                                                                                                                                                                                                       |
| deliverQuantity<mark style="color:red;">\*</mark> | Number | <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> | Number | <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 [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

```json
{
  "type": "marketOrderSubmitAck",
  "payload": {
    "orderId": "105bb0a7-fdb0-4bde-a367-d47787951349",
    "receiveCurrency": "USD",
    "receiveQuantity": 19.6206,
    "deliverCurrency": "BTC",
    "deliverQuantity": 0.002,
    "fee": 0.0392412
  }
}
```

{% endtab %}

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

```json
{
  "type": "marketOrderSubmitAck",
  "payload": {
    "orderId": "bd94982b-558a-4708-81fa-acbdae3073d0",
    "receiveCurrency": "BTC",
    "receiveQuantity": 0.048,
    "deliverCurrency": "USD",
    "deliverQuantity": 469.6272,
    "fee": 0.000096
  }
}
```

{% endtab %}

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

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

{% endtab %}

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

```javascript
{
    "message": "Either deliverQuantity or receiveQuantity must be specified, or must be bigger than 0"
}
```

{% endtab %}

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

```json
{
    "message": "Invalid ticker: BTC-USDD"
}
```

{% endtab %}

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

```json
{
    "message": "Invalid tradeSide: selling"
}
```

{% endtab %}

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

```json
{
    "message": "User not authorized for MARKET"
}
```

{% endtab %}

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

```json
{
    "message": "Access Denied"
}
```

{% endtab %}

{% tab title="200: OK Insufficient balance" %}
Returns an [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

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

{% endtab %}

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

```json
{
    "type": "marketOrderSubmitAck",
    "payload": {
        "orderId": "7c98627-488y-4ce7-acde-2de3f887q0d3",
        "receiveCurrency": "USD",
        "receiveQuantity": 1e-10,
        "deliverCurrency": "USDT",
        "deliverQuantity": 1e-10,
        "fee": 0
    }
}
```

{% endtab %}
{% endtabs %}

### TWAP

Aquanow's execution algorithm.

**TWAP**

Time-Weighted Average Price (TWAP) is used when buying or selling large amounts of digital assets over time, with the ability to choose the amount being sold and its time period.

## Create an order

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

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#320b507f-0898-4986-9424-762bb0298ab5) 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>      | String | <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 | <p>Trading strategy to be executed</p><p><mark style="color:orange;">NOTE:</mark> Currently, we only support <strong>TWAP</strong> strategies.</p>                           |
| ticker<mark style="color:red;">\*</mark>        | String | Strategy pair to be traded (e.g., `BTC-USD`)                                                                                                                                 |
| tradeSide<mark style="color:red;">\*</mark>     | String | `"buy"` or `"sell"` order                                                                                                                                                    |
| tradePrice<mark style="color:red;">\*</mark>    | Number | Price of the coin on purchase                                                                                                                                                |
| tradeSize<mark style="color:red;">\*</mark>     | Number | Size or quantity of order                                                                                                                                                    |
| tradeDuration<mark style="color:red;">\*</mark> | Number | <p><mark style="color:orange;">NOTE:</mark> only required if strategy is <strong>TWAP</strong>.</p><p>Duration is in number of seconds. Minimum duration is 300 seconds.</p> |
| usernameRef                                     | String | A new reference string for subaccounts. Must be less than 64 characters and cannot contain special characters.                                                               |

{% tabs %}
{% tab title="200: OK TWAP Strategy" %}
Returns an [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

```json
{
  "type": "parentOrderSubmitAck",
  "payload": {
    "orderId": "6215758c-38dc-4a9f-9647-023ef14f20bb"
  }
}
```

{% endtab %}

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

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "type": "parentOrderSubmitAck",
    "error": {
        "message": "Aqua: Insufficient funds"
    },
    "payload": {
        "orderId": "a731b28f-5bbc-4638-a6af-ec5bd556b379"
    }
}
</code></pre>

{% endtab %}

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

```json
{
    "message": "Invalid tradeSide: buying"
}
```

{% endtab %}

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

```json
{
    "message": "Invalid ticker: BTC-USDD"
}
```

{% endtab %}

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

```json
{
    "message": "Trade size is smaller than minimum size 0.002"
}
```

{% endtab %}

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

```json
{
    "message": "Access Denied"
}
```

{% endtab %}

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

```json
{
    "message": "User not authorized for TWAP"
}
```

{% endtab %}
{% endtabs %}

## Cancel a pre-existing TWAP order.

<mark style="color:red;">`DELETE`</mark> `https://api.aquanow.io/trades/v1/order`

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#65872ab2-4d8d-43bd-b3b0-8ad469bdcc6e) documentation.

#### Query Parameters

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

#### 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`                                                                                                                                                 |

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

```json
{
  "type": "parentOrderCancelAck",
  "payload": {
    "orderId": "7b323a75-5457-450f-9bf0-46fa6f20ff4e"
  }
}
```

{% endtab %}

{% tab title="502: Bad Gateway Order not found" %}

```javascript
{
    "message": "You request is invalid, contact info@aquanow.io if you have questions"
}
```

{% 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/v1/order`

<mark style="color:orange;">NOTE:</mark> Either **deliverQuantity**, **receiveQuantity** must be specified. If both are specified, receiveQuantity will be considered for sell orders, and deliverQuantity will be considered for buy orders.

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"`                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 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> | Number | <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> | Number | <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> |
| usernameRef                                       | String | <p>A new reference string for sub-accounts. </p><p>Must be less than 64 characters, cannot contain special characters.</p>                                                                                                                                                                                                                                                                                                                 |
| tradePrice<mark style="color:red;">\*</mark>      | Number | Trade price of ticker symbol                                                                                                                                                                                                                                                                                                                                                                                                               |

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

```json
{
  "type": "parentOrderSubmitAck",
  "payload": {
    "orderId": "0bea14b3-a510-437c-a805-73p15f654cad",
    "receiveCurrency": "BTC",
    "receiveQuantity": 0.02,
    "deliverCurrency": "USD",
    "deliverQuantity": 881.7,
    "fee": 0,
    "tradeTime": 1704389622301,
    "symbol": "BTC-USD",
    "tradeStatus": "COMPLETE",
    "price": 44085
  }
}
```

{% endtab %}

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

```json
{
    "type": "parentOrderSubmitAck",
    "error": {
        "message": "Aqua: Insufficient funds"
    },
    "payload": {
        "orderId": "275661f3-beb1-4464-bf21-af0789632438",
        "receiveCurrency": "BTC",
        "receiveQuantity": 0,
        "deliverCurrency": "USD",
        "deliverQuantity": 0,
        "fee": 0,
        "tradeTime": 1704391973378,
        "symbol": "BTC-USD",
        "tradeStatus": "COMPLETE",
        "price": 45065.18509321
    }
}
```

{% endtab %}

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

```json
{
    "type": "parentOrderSubmitAck",
    "error": {
        "message": "Cancelled - Price not marketable"
    },
    "payload": {
        "orderId": "50154c07-04d8-49ef-8a4c-392aa7014346",
        "receiveCurrency": "BTC",
        "receiveQuantity": 0,
        "deliverCurrency": "USD",
        "deliverQuantity": 0,
        "fee": 0,
        "tradeTime": 1704391943590,
        "symbol": "BTC-USD",
        "tradeStatus": "CANCELLED",
        "price": 44073.3
    }
}
```

{% endtab %}

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

```json
{
    "message": "data/tradeSide must be equal to one of the allowed values"
}
```

{% endtab %}

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

```json
{
    "message": "provide at least one baseQuantity and quoteQuantity to be non-zero"
}
```

{% endtab %}

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

```json
{
    "message": "User is not authorized to access this resource with an explicit deny"
}
```

{% endtab %}

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

```json
{
    "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/v1/order`

<mark style="color:orange;">NOTE:</mark> Either **deliverQuantity** or **receiveQuantity** must be specified. If both are specified, receiveQuantity will be considered for sell orders, and deliverQuantity will be considered for buy orders.

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"`                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 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>      | Number | Limit price of a ticker symbol, determined by `tradeSide` and `deliverQuantity`/`receiveQuantity`                                                                                                                                                                                                                                                                                                                                                                |
| deliverQuantity<mark style="color:red;">\*</mark> | Number | <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> | Number | <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 [ExecutionsObject](https://docs.aquanow.io/aquanow/legacy/data-objects-and-statuses/executions-objects/duration-order-objects).

```json
{
  "type": "limitOrderAck",
  "payload": {
    "quoteId": "5cecaa55-e91a-4c12-9af4-756c9f3630ea",
    "quoteTime": 1669072974783,
    "expireTime": 1669159374783,
    "ticker": "BTC-USD",
    "tradeSide": "buy",
    "receiveCurrency": "BTC",
    "receiveQuantity": 0.048,
    "deliverCurrency": "USD",
    "deliverQuantity": 758.208,
    "price": 15796
  }
}
```

{% endtab %}

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

```json
{
  "type": "limitOrderAck",
  "payload": {
    "quoteId": "7202456e-36c6-44a6-8579-a2e86808deb0",
    "quoteTime": 1669072984056,
    "expireTime": 1669159384056,
    "ticker": "BTC-USD",
    "tradeSide": "sell",
    "receiveCurrency": "USD",
    "receiveQuantity": 805.44,
    "deliverCurrency": "BTC",
    "deliverQuantity": 0.048,
    "price": 16780
  }
}
```

{% endtab %}

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

```json
{
  "type": "parentOrderSubmitAck",
  "payload": {
    "orderId": "051065f6-0ad6-4ea6-8f08-85263bca42bc"
  }
}
```

{% endtab %}

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

```json
{
  "type": "parentOrderSubmitAck",
  "payload": {
    "orderId": "d0386efb-a72f-4ee0-b40f-552008f41c98"
  }
}
```

{% endtab %}

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

```json
{
  "type": "parentOrderSubmitAck",
  "payload": {
    "orderId": "bd0a5ce3-4437-4492-9942-8b1dcffb9227"
  }
}
```

{% endtab %}

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

```json
{
  "type": "parentOrderSubmitAck",
  "payload": {
    "orderId": "b50caa7e-92b0-408c-b68a-fe25822bc4b2"
  }
}
```

{% endtab %}

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

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "type": "limitOrderAck",
    "error": {
        "message": "Aqua: Insufficient funds"
    },
    "payload": {
        "orderId": "a731b28f-5bbc-4638-a6af-ec5bd556b379"
    }
}
</code></pre>

{% endtab %}

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

```javascript
{
    "message": "expirationTime should be within 90 days from now: 1869972405009"
}
```

{% endtab %}

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

```javascript
{
    "message": "data must have required property 'expirationTime'"
}
```

{% endtab %}

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

```json
{
    "message": "data/ticker must be equal to one of the allowed values"
}
```

{% endtab %}

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

```json
{
    "message": "data/tradeSide must be equal to one of the allowed values"
}
```

{% endtab %}

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

```json
{
    "message": "User not authorized for LIMIT"
}
```

{% endtab %}

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

```json
{
    "message": "Trade size must be bigger than minimum size 1e-7. You submitted: 1e-9"
}
```

{% endtab %}

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

```json
{
    "message": "Access Denied"
}
```

{% endtab %}
{% endtabs %}

## Cancel a pre-existing LIMIT/GTC/GTD order.

<mark style="color:red;">`DELETE`</mark> `https://api.aquanow.io/trades/v1/order`

To view example requests for this endpoint, visit Aquanow's [Postman](https://developer.aquanow.io/#766e3e74-4b38-4b97-92cb-b8a497aca726) 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              |
| ----------------------------------------- | ------ | ------------------------ |
| orderId<mark style="color:red;">\*</mark> | String | `orderId` to be canceled |

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

```json
{
    "type": "parentOrderCancelAck",
    "payload": { 
        "orderId": "7b323a75-5457-450f-9bf0-46fa6f20ff4e"
    }
}
```

{% endtab %}

{% tab title="502: Bad Gateway Invalid orderId" %}

```javascript
{
    "message": "You request is invalid, contact info@aquanow.io if you have questions"
}
```

{% endtab %}
{% endtabs %}
