> For the complete documentation index, see [llms.txt](https://www.notbank.com/learn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.notbank.com/learn/api-reference/websocket-api/trading.md).

# Trading

### SendOrderList

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Creates a list of orders. This method takes a list where each element represents a single order with the same format used in the API method **SendOrder**.

The orders can be assorted, means that it can be for different instruments and different accounts.

Anyone submitting an order should also subscribe to the various market data and event feeds, or call **GetOpenOrders** or **GetOrderStatus** to monitor the status of the order. If the order is not in a state to be executed, **GetOpenOrders** will not return it.

A user with NotbankTrading permission can only create an order for accounts with which he/she is associated to.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().sendOrderList([
  {
    "InstrumentId": 2,
    "AccountId": 185,
    "TimeInForce": 1,
    "ClientOrderId": 0,
    "OrderIdOCO": 0,
    "UseDisplayQuantity": false,
    "Side": 0,
    "Quantity": 0.02,
    "OrderType": 2,
    "PegPriceType": "3",
    "LimitPrice": 23436
  },
  {
    "InstrumentId": 2,
    "AccountId": 185,
    "TimeInForce": 1,
    "ClientOrderId": 0,
    "OrderIdOCO": 0,
    "UseDisplayQuantity": false,
    "Side": 0,
    "Quantity": 0.02,
    "OrderType": 2,
    "PegPriceType": "3",
    "LimitPrice": 23436
  }
]);

// request
[
  {
    InstrumentId: number;
    AccountId: number;
    TimeInForce: TimeInForce;
    ClientOrderId?: number;
    OrderIdOCO?: number;
    UseDisplayQuantity?: boolean;
    Side: OrderSide;
    Quantity?: number;
    OrderType: OrderTypeInt;
    PegPriceType?: PegPriceType;
    LimitPrice?: number;
    StopPrice?: number;
    TrailingAmount?: number;
    LimitOffset?: number;
    DisplayQuantity?: number;
    Value?: number;
    PostOnly?: boolean;
  },
]
```

{% endtab %}

{% tab title="Java" %}

```java
import java.math.BigDecimal;
import java.util.List;
import exchange.notbank.trading.constants.OrderSide;
import exchange.notbank.trading.constants.OrderType;
import exchange.notbank.trading.constants.TimeInForce;
import exchange.notbank.trading.paramBuilders.SendOrderListParamBuilder;
import exchange.notbank.trading.paramBuilders.SendOrderParamBuilder;

var anInstrument = notbankClient.getInstrumentService().getInstrument("BTCUSDT").get();
var accountId = 7;
var order1 = new SendOrderParamBuilder(
    anInstrument, 
    accountId, 
    TimeInForce.FOK, 
    OrderSide.BUY,
    OrderType.MARKET)
    .quantity(new BigDecimal("10"));
var order2 = new SendOrderParamBuilder(
    anInstrument, 
    accountId, 
    TimeInForce.FOK, 
    OrderSide.SELL,
    OrderType.MARKET)
    .quantity(new BigDecimal("15"))
client.getTradingService().sendOrderList(new SendOrderListParamBuilder(List.of(order1, order2))).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetInstrumentRequest

from notbank_python_sdk.requests_models import OrderType, PegPriceType, SendOrderRequest, Side, TimeInForce

instrument = client.get_instrument(GetInstrumentRequest(2))
client.send_order_list([
    SendOrderRequest(
        instrument=instrument,
        account_id=185,
        time_in_force=TimeInForce.GTC,
        side=Side.SELL,
        quantity=Decimal("0.02"),
        order_type=OrderType.LIMIT,
        peg_price_type=PegPriceType.ASK,
        limit_price=Decimal(23436),
        use_display_quantity=False,
    ),
    SendOrderRequest(
        instrument=instrument,
        account_id=185,
        time_in_force=TimeInForce.GTC,
        side=Side.SELL,
        quantity=Decimal("0.05"),
        order_type=OrderType.LIMIT,
        peg_price_type=PegPriceType.ASK,
        limit_price=Decimal(23436),
        use_display_quantity=False,
    )
])
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "SendOrderList",
  "o": "[
    {
      \"InstrumentId\": 2,
      \"OMSId\": 1,
      \"AccountId\": 185,
      \"TimeInForce\": 1,
      \"ClientOrderId\": 0,
      \"OrderIdOCO\": 0,
      \"UseDisplayQuantity\": false,
      \"Side\": 0,
      \"Quantity\": 0.02,
      \"OrderType\": 2,
      \"PegPriceType\": \"3\",
      \"LimitPrice\": 23436
    },
    {
      \"InstrumentId\": 2,
      \"OMSId\": 1,
      \"AccountId\": 185,
      \"TimeInForce\": 1,
      \"ClientOrderId\": 0,
      \"OrderIdOCO\": 0,
      \"UseDisplayQuantity\": false,
      \"Side\": 0,
      \"Quantity\": 0.02,
      \"OrderType\": 2,
      \"PegPriceType\": \"3\",
      \"LimitPrice\": 23436
    }
  ]"
}
```

{% endtab %}
{% endtabs %}

If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified

| Key                | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| InstrumentId       | **integer**. The ID of the instrument being traded. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| OMSId              | **integer**. The ID of the OMS on which the instrument is being traded. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| AccountId          | **integer**. The ID of the account the order will be placed for. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| TimeInForce        | <p><strong>integer</strong>. An integer that represents the period during which the new order is executable. One of:<br>- <strong>0</strong> Unknown (an error condition)<br>- <strong>1</strong> GTC (good 'til canceled, the default)<br>- <strong>2</strong> OPG (execute as close to opening price as possible: not yet used, for future provision)<br>- <strong>3</strong> IOC (immediate or canceled)<br>- <strong>4</strong> FOK (fill-or-kill — fill immediately or kill immediately)<br>- <strong>5</strong> GTX (good 'til executed: not yet used, for future provision)<br>- <strong>6</strong> GTD (good 'til date: not yet used, for future provision)<br><strong>required</strong>.</p>                                                                                                                                                       |
| ClientOrderId      | **long integer**. A user-assigned ID for the order (like a purchase-order number assigned by a company). This ID is useful for recognizing future states related to this order. Duplicate client orderid of two open orders of the same account is not allowed, the incoming order with the same ClientOrderId will get rejected. Default is 0. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderIdOCO         | **long integer**. The order ID if One Cancels the Other — If this order is order A, *OrderIdOCO* refers to the order ID of an order B (which is *not* the order being created by this call). If order B executes, then order A created by this call is canceled. You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. See **CancelReplaceOrder** and **ModifyOrder**. **optional**.                                                                                                                                                                                                                                                                                                                             |
| UseDisplayQuantity | **boolean**. If you enter a Limit order with a reserve (reserve order), you must set *UseDisplayQuantity* to *true* else, the quantity of your order will be 0, defaults to **false**. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Side               | <p><strong>integer</strong>. A number representing the side of a trade. One of:<br>- <strong>0</strong> Buy<br>- <strong>1</strong> Sell<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Quantity           | **decimal**. The quantity of the instrument being ordered. Not required if **OrderType** is Market (1) and as long as **Value** is defined. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| OrderType          | <p><strong>integer</strong>. The type of the order. One of:<br>- <strong>0</strong> Unknown<br>- <strong>1</strong> Market<br>- <strong>2</strong> Limit<br>- <strong>3</strong> StopMarket<br>- <strong>4</strong> StopLimit<br>- <strong>5</strong> TrailingStopMarket<br>- <strong>6</strong> TrailingStopLimit<br>- <strong>7</strong> BlockTrade<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| PegPriceType       | <p><strong>integer or string</strong>. Only applicable to TrailingStop and Stop orders. The type of price that pegs the stop. One of:<br>- 1 Last<br>- 2 Bid<br>- 3 Ask<br>- 4 Midpoint (Currently unsupported; for future provision)<br>Default is 1 Last. <strong>optional</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| LimitPrice         | **decimal**. The price at which the order will be placed. Required if OrderType is **2 Limit** or **4 StopLimit** or **7 TrailingStopLimit**. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| StopPrice          | **decimal**. Applicable to TrailingStop (Limit and Market) and Stop (Limit and Market) orders only; the price at which the order will get activated. Is not required to be defined for TrailingStop order as this price will be determined automatically based on the **TrailingAmount**, **PegPriceType** and most importantly the movement of the price where the order is pegged (**PegPriceType**). Default is 0. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                           |
| TrailingAmount     | **decimal**. Applicable to TrailingStopLimit and TrailingStopMarket orders only; a number that will be either added to (buy side) or subtracted from (sell side) the price where the order is pegged(depends on the **PegPriceType**); the sum or the difference will be the **StopPrice** of the **TrailingStop** order. On the buy side, if the price where the order is pegged increases and never goes down below the value when the order was placed, the resulting StopPrice will be the sum of the price where the order is pegged during submission and the TrailingAmount; however, if the price where the order is pegged decreases, the StopPrice will change, it will be the sum of the whatever is the lowest value the pegged price will have and the TrailingAmount: the logic on the sell side is the opposite. **conditionally required**. |
| LimitOffset        | **decimal**. Applicable to TrailingStopLimit only; a number that will be either added (buy side) or subtracted (sell side) to the **StopPrice**, the sum or the difference will be the LimitPrice of the order when it gets activated. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| DisplayQuantity    | **integer**. If *UseDisplayQuantity* is set to *true*, you must set a value of this field greater than 0, else, order will not appear in the orderbook. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Value              | **decimal** The total value of the trade. Only applicable in a market order type: a user can opt to input a value instead of defining the quantity which will then be automatically calculated: value/marketprice. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PostOlny           | **boolean** If the order is post only. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "SendOrderList",
  "o": "{
    \"result\": false, //It returns false but the request were successfully placed.
    \"errormsg\": \"Operation In Process\",
    \"errorcode\": 107,
    \"detail\": null
  }"
}

```

| Key       | Value                                                                                                                                                                                                                                                                                                                             |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| result    | **boolean**. Specifically for this API method only, it returns false even if the request went through.                                                                                                                                                                                                                            |
| errormsg  | **string**. A successful request returns **Operation In Process**; the *errormsg* parameter for an unsuccessful request returns one of the following messages: Not Authorized (errorcode 20), Invalid Request (errorcode 100), Operation Failed (errorcode 101), Server Error (errorcode 102), Resource Not Found (errorcode 104) |
| errorcode | **integer**. A successful request returns 107. An unsuccessful request returns one of the *errorcodes* shown in the *errormsg* list.                                                                                                                                                                                              |
| detail    | **string**. Message text that the system may send. Usually *null*.                                                                                                                                                                                                                                                                |

### SendCancelList

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Cancels a list of orders. This method takes a list of element each representing an order to be canceled.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().sendCancelList([
  {
      "OrderId": 6714,
      "AccountId": 7
  },
  {
      "OrderId": 6507,
      "AccountId": 7
  }
]);

// request payload
[
  {
    OrderId: number; // Required: ID de la orden a cancelar
    AccountId: number; // Required: ID de la cuenta asociada a la orden
  },
]
```

{% endtab %}

{% tab title="Java" %}

```java
import java.util.List;
import exchange.notbank.trading.paramBuilders.SendCancelListParamBuilder;
import exchange.notbank.trading.paramBuilders.SendCancelParamBuilder;

var accountId = 7;
client.getTradingService().sendCancelList(new SendCancelListParamBuilder(List.of(
    new SendCancelParamBuilder(6714, accountId),
    new SendCancelParamBuilder(6507, accountId)))).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models.cancel_order import CancelOrder

client.send_cancel_list([
    CancelOrder(
        order_id=6714,
        account_id=7,
    ),
    CancelOrder(
        order_id=6507,
        account_id=7,
    ),
])
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "SendCancelList",
  "o": "[
    {
        \"OMSId\": 1,
        \"OrderId\": 6714,
        \"AccountId\": 9
    },
    {
        \"OMSId\": 1,
        \"OrderId\": 6507,
        \"AccountId\": 9
    }
  ]"
}
```

{% endtab %}
{% endtabs %}

| Key       | Value                                                                                                                                           |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId     | **integer**. The ID of the OMS on which the original order was placed. **required**.                                                            |
| OrderId   | **integer**. The ID of the order/s to be canceled. To get orderid/s of open orders, you can use the **GetOpenOrders** API method. **required**. |
| AccountId | **integer**. Account for which order/s will be canceled. If not specified, order/s will not be cancelled. **required**.                         |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "SendCancelList",
  "o": "{
    \"result\": true,
    \"errormsg\": null,
    \"errorcode\": 0,
    \"detail\": null
  }"
}
```

| Key       | Value                                                                                                                                                                                                                                                                                                         |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| result    | **boolean**. A successful request returns true; and unsuccessful request (an error condition) returns false.                                                                                                                                                                                                  |
| errormsg  | **string**. A successful request returns null; the *errormsg* parameter for an unsuccessful request returns one of the following messages: Not Authorized (errorcode 20), Invalid Request (errorcode 100), Operation Failed (errorcode 101), Server Error (errorcode 102), Resource Not Found (errorcode 104) |
| errorcode | **integer**. A successful request returns 0. An unsuccessful request returns one of the *errorcodes* shown in the *errormsg* list.                                                                                                                                                                            |
| detail    | **string**. Message text that the system may send. Usually *null*.                                                                                                                                                                                                                                            |

### SendCancelReplaceList

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Cancels or Replaces orders. Only working orders can be replaced.

This method will reset order book priority of the order.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().sendCancelReplaceList([
  {
    "OrderIdToReplace":6696,
    "ClientOrdId":0,
    "OrderType":"Limit",
    "Side":"Buy",
    "AccountId":7,
    "InstrumentId":1,
    "LimitPrice":29500,
    "TimeInForce":1,
    "Quantity":0.003
  },
  {
    "OrderIdToReplace":6698,
    "ClientOrdId":0,
    "OrderType":"Limit",
    "Side":"Buy",
    "AccountId":7,
    "InstrumentId":1,
    "LimitPrice":29900,
    "TimeInForce":1,
    "Quantity":0.004
  }
]);

// request payload
[
  {
    ReplaceOrderId: number;
    ReplaceClientOrderId?: number;
    ClientOrderId?: number;
    OrderType: OrderTypeInt;
    Side: OrderSide;
    AccountId: number;
    InstrumentId: number;
    UseDisplayQuantity?: boolean;
    DisplayQuantity?: number;
    LimitPrice?: number;
    StopPrice?: number;
    ReferencePrice?: number;
    PegPriceType?: PegPriceType;
    TimeInForce: TimeInForce;
    OrderIdOCO?: number;
    Quantity: number;
  },
]
```

{% endtab %}

{% tab title="Java" %}

```java
import java.math.BigDecimal;
import java.util.List;
import exchange.notbank.trading.constants.OrderSide;
import exchange.notbank.trading.constants.OrderType;
import exchange.notbank.trading.constants.TimeInForce;
import exchange.notbank.trading.paramBuilders.SendCancelReplaceParamBuilder;

var response = client.getTradingService().sendCancelReplaceList(new SendCancelReplaceListParamBuilder(List.of(
    new SendCancelReplaceParamBuilder(Long.parseLong("6696"), OrderType.LIMIT,
        OrderSide.BUY, 7, 1, TimeInForce.GTC, new BigDecimal("0.004"))
        .clientOrderId(Long.parseLong("0"))
        .limitPrice(new BigDecimal("29500")),
    new SendCancelReplaceParamBuilder(Long.parseLong("6698"), OrderType.LIMIT,
        OrderSide.BUY, 7, 1, TimeInForce.GTC, new BigDecimal("0.004"))
        .clientOrderId(Long.parseLong("0"))
        .limitPrice(new BigDecimal("29900"))))).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import CancelReplaceOrderRequest
from notbank_python_sdk.constants import OrderType, Side, TimeInForce

client.send_cancel_replace_list([
    CancelReplaceOrderRequest(
        order_id_to_replace=6696,
        order_type=OrderType.LIMIT,
        side=Side.BUY,
        account_id=7,
        instrument_id=1,
        quantity=Decimal("0.003"),
        time_in_force=TimeInForce.GTC,
    ),
    CancelReplaceOrderRequest(
        order_id_to_replace=6698,
        order_type=OrderType.LIMIT,
        side=Side.BUY,
        account_id=7,
        instrument_id=1,
        quantity=Decimal("0.004"),
        time_in_force=TimeInForce.GTC,
    ),
])
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "SendCancelReplaceList",
  "o": "[
    {
        \"OMSId\":1,
        \"OrderIdToReplace\":6696,
        \"ClientOrdId\":0,
        \"OrderType\":\"Limit\",
        \"Side\":\"Buy\",
        \"AccountId\":7,
        \"InstrumentId\":1,
        \"LimitPrice\":29500,
        \"TimeInForce\":1,
        \"Quantity\":0.003
    },
    {
        \"OMSId\":1,
        \"OrderIdToReplace\":6698,
        \"ClientOrdId\":0,
        \"OrderType\":\"Limit\",
        \"Side\":\"Buy\",
        \"AccountId\":7,
        \"InstrumentId\":1,
        \"LimitPrice\":29900,
        \"TimeInForce\":1,
        \"Quantity\":0.004
    }
  ]"
}
```

{% endtab %}
{% endtabs %}

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OmsId                | **integer**. The ID of the OMS on which the order is being canceled and replaced by another order. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ReplaceOrderId       | **long integer**. The ID of the order to be replaced. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ReplaceClientOrderId | **long integer**. The ClientOrderId of the existing order to be replaced. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ClientOrderId        | **long integer**. A custom ID that can identify the replacement order later on. It is required for this field to be unique for every working order. Default is 0. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                          |
| OrderType            | <p><strong>integer or string</strong>. The type of the replacement order. Either the integer or string value is accepted. One of:<br>- 0 Unknown<br>- 1 Market<br>- 2 Limit<br>- 3 StopMarket<br>- 4 StopLimit<br>- 5 TrailingStopMarket<br>- 6 TrailingStopLimit<br>- 7 BlockTrade<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                    |
| Side                 | <p><strong>integer</strong>. An integer representing the side of the replacement order. One of:<br>- 0 Buy<br>- 1 Sell<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| AccountId            | **integer**. The ID of the account who owns the order and is replacing the order, AccountId of the replacement order must match the AccountId of the existing order. **required**.                                                                                                                                                                                                                                                                                                                                                                                                       |
| InstrumentId         | **integer**. The ID of the instrument being traded. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| UseDisplayQuantity   | **boolean**. The display quantity is the quantity of a product shown to the market to buy or sell. A larger quantity may be wanted or available, but it may disadvantageous to display it when buying or selling. The display quantity is set when placing an order (using **SendOrder** or **CancelReplaceOrder** for instance). If you enter a Limit order with reserve, you must set *useDisplayQuantity* to *true*. **optional**.                                                                                                                                                    |
| DisplayQuantity      | **decimal**. The quantity of a product that is available to buy or sell that is publicly displayed to the market or simply in the orderbook. Will be used when **UseDisplayQuantity** is set to true, and in that case it needs to be defined else order will not appear in the order book as it defaults to 0. **optional**.                                                                                                                                                                                                                                                            |
| LimitPrice           | **decimal**. The price at which to execute the new order, if the new order is a limit order. If the replacement order is a market order, there is no need to define this field. Expressed in ticks for trailing stops. **conditionally required**.                                                                                                                                                                                                                                                                                                                                       |
| StopPrice            | **decimal**. The price at which to execute the new order if the replacement order is a stop order. If the replacement order is a not a stop order, there is no need to define this field. Expressed in ticks for trailing stops. **conditionally required**.                                                                                                                                                                                                                                                                                                                             |
| ReferencePrice       | **decimal**. Used if the replacement order is trailing order. If the replacement order is not a trailing order, there is no need to define this field. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                       |
| PegPriceType         | <p><strong>integer or string</strong>. The type of price you set in a stop/trailing order to "peg the stop". One of:<br>- 0 Unknown<br>- 1 Last<br>- 2 Bid<br>- 3 Ask<br>- 4 Midpoint<br>If the replacement order is not a trailing/stop order, there is no need to define this field. <strong>conditionally required</strong>.</p>                                                                                                                                                                                                                                                      |
| TimeInForce          | <p><strong>integer or string</strong>. Represents the period during which the new order is executable. One of:<br>- 0 Unknown (an error condition)<br>- 1 GTC (good 'til canceled, the default)<br>- 2 OPG (execute as close to opening price as possible: not yet used, for future provision)<br>- 3 IOC (immediate or canceled)<br>- 4 FOK (fill or kill — fill the order immediately, or cancel it immediately)<br>- 5 GTX (good 'til executed: not yet used, for future provision)<br>- 6 GTD (good 'til date: not yet used, for future provision)<br><strong>required</strong>.</p> |
| OrderIdOCO           | **integer**. If the order being canceled in this call is order A, and the order replacing order A in this call is order B, then *OrderIdOCO* refers to an order C that is currently open. If order C executes, then order B is canceled. You can also set up order C to watch order B in this way, but that will require an update to order C. Orderid to link this order to for OCO, negative values represent ordinal offset to current orderid, i.e., -1 = previous order. **optional**.                                                                                              |
| Quantity             | **decimal**. The quantity of the replacement order. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "SendCancelReplaceList",
  "o": "{
    \"result\": true,
    \"errormsg\": null,
    \"errorcode\": 0,
    \"detail\": null
  }"
}
```

| Key       | Value                                                                                                                                                                                                                                                                                                                                          |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| result    | **boolean**. A successful request returns true; and unsuccessful request (an error condition) returns false.                                                                                                                                                                                                                                   |
| errormsg  | **string**. A successful request returns null; the *errormsg* parameter for an unsuccessful request returns one of the following messages: Not Authorized (errorcode 20), Invalid Request (errorcode 100), Operation Failed (errorcode 101), Server Error (errorcode 102), Resource Not Found (errorcode 104), Order Not Found (errorcode 104) |
| errorcode | **integer**. A successful request returns 0. An unsuccessful request returns one of the *errorcodes* shown in the *errormsg* list.                                                                                                                                                                                                             |
| detail    | **string**. Message text that the system may send. Usually *null*.                                                                                                                                                                                                                                                                             |

### ModifyOrder

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Modifies an order's quantity. With this method, an order’s quantity can only be reduced.

Reduces an order’s quantity without losing priority in the order book. The other API method that can modify an order is **CancelReplaceOrder**, it resets order book priority, but you can use it to increase an order quantity and also change the limitprice.

**Note:** **ModifyOrder** does not surrender or reset order book priority.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().modifyOrder({
  "OrderId": 6507,
  "InstrumentId": 9,
  "Quantity": 0.1,
  "AccountId": 9
});

// request payload
{
  OrderId: number;
  InstrumentId: number;
  Quantity: number;
  AccountId: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.math.BigDecimal;
import exchange.notbank.trading.paramBuilders.ModifyOrderParamBuilder;

var accountId = 7;
var response = client.getTradingService().modifyOrder(new ModifyOrderParamBuilder(
    Long.parseLong("6507"), 
    9, 
    new BigDecimal("0.1"), 
    accountId)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from decimal import Decimal
from notbank_python_sdk.requests_models import ModifyOrderRequest

client.modify_order(ModifyOrderRequest(
    order_id=6507,
    instrument_id=9,
    quantity=Decimal("0.1"),
    account_id=9,
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "ModifyOrder",
  "o": "{
    \"OMSId\": 1,
    \"OrderId\": 6507,
    \"InstrumentId\": 9,
    \"Quantity\": 0.1,
    \"AccountId\": 9
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                                                                                             |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| OMSId        | **integer**. The ID of the OMS on which the original order was placed. **required**.                                              |
| OrderId      | **long integer**. The ID of the order to be modified. The ID was supplied by the server when the order was created. **required**. |
| InstrumentId | **integer**. The ID of the instrument traded in the order. **required**.                                                          |
| Quantity     | **decimal**. The new quantity of the order. This value can only be reduced from a previous quantity. **required**.                |
| AccountId    | **integer**. Account for which order will be modified. **required**.                                                              |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "ModifyOrder",
  "o": "{
    \"result\": true,
    \"errormsg\": null,
    \"errorcode\": 0,
    \"detail\": null
  }"
}


//Possible error/s
//Quantity defined is greater than the existing quantity of the order being modified. This API can only reduce the quantity of the existing order.
{
  "m": 1,
  "i": 0,
  "n": "ModifyOrder",
  "o": "{
    \"result\": false,
    \"errormsg\": \"Invalid Quantity\",
    \"errorcode\": 100,
    \"detail\": null
  }"
}


//One or more required fields are not defined
{
  "m": 1,
  "i": 0,
  "n": "ModifyOrder",
  "o": "{
    \"result\": false,
    \"errormsg\": \"Invalid Request\",
    \"errorcode\": 100,
    \"detail\": \"Not all required fields are provided\"
  }"
}

```

The response acknowledges the successful receipt of your request to modify an order; it does not indicate that the order has been modified. To find if an order has been modified, check using **GetOpenOrders** or **GetOrderHistory**.

| Key       | Value                                                                                                                                                                                                                                                                                                                                                                                                                |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| result    | **boolean**. The successful receipt of a modify order request returns *true*; otherwise, returns *false*. This is the acknowledgment of receipt of the request to modify, not a confirmation that the modification has taken place.                                                                                                                                                                                  |
| errormsg  | <p><strong>string</strong>. A successful receipt of a modify request returns <em>null</em>; the <em>errormsg</em> parameter for an unsuccessful request returns one of the following messages:<br>Not Authorized (errorcode 20)<br>Invalid Request (errorcode 100)<br>Invalid Quantity (errorcode 100)<br>Operation Failed (errorcode 101)<br>Server Error (errorcode 102)<br>Resource Not Found (errorcode 104)</p> |
| errorcode | **integer**. The receipt of a successful request to modify returns 0. An unsuccessful request returns one of the *errorcodes* shown in the *errormsg* list.                                                                                                                                                                                                                                                          |
| detail    | **string**. Message text that the system may send. Usually *null*.                                                                                                                                                                                                                                                                                                                                                   |

### CancelAllOrders

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Cancels all open matching orders for the specified account on an OMS.

A user with NotbankTrading permission can only cancel orders for accounts with which he/she is associated to.

**Note:** Multiple users may have access to the same account.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

//Cancel all orders of all accounts for a specific instrument
await client.getTradingService().cancelAllOrders({
  "AccountId": 9,
  "InstrumentId": 1
});

//Cancel all orders of all accounts for a specific instrument
await client.getTradingService().cancelAllOrders({
  "AccountId": 0,
  "InstrumentId": 1
});

//Cancel all orders of all accounts for all instruments
await client.getTradingService().cancelAllOrders({
  "AccountId": 0,
  "InstrumentId": 0
});

// request payload
{
  AccountId?: number;
  InstrumentId?: number;
}

```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.CancelAllOrdersParamBuilder;

//Cancel all orders of all accounts for a specific instrument
var response = client.getTradingService().cancelAllOrders(new CancelAllOrdersParamBuilder(
    1, 
    7)).get();

//Cancel all orders of all accounts for a specific instrument
var response = client.getTradingService().cancelAllOrders(new CancelAllOrdersParamBuilder(
    1, 
    0)).get();

//Cancel all orders of all accounts for all instruments
var response = client.getTradingService().cancelAllOrders(new CancelAllOrdersParamBuilder(
    0, 
    0)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models.cancel_all_orders import CancelAllOrdersRequest

# Cancel all orders of all accounts for a specific instrument
client.cancel_all_orders(CancelAllOrdersRequest(
    account_id=7,
    instrument_id=1,
))
# Cancel all orders of all accounts for a specific instrument
client.cancel_all_orders(CancelAllOrdersRequest(
    account_id=0,
    instrument_id=1,
))
# Cancel all orders of all accounts for all instruments
client.cancel_all_orders(CancelAllOrdersRequest(
    account_id=0,
    instrument_id=0,
))
```

{% endtab %}

{% tab title="Json" %}

```json

//Cancel all orders of a specific account for a specific instrument
{
  "m": 0,
  "i": 0,
  "n": "CancelAllOrders",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 9,
    \"InstrumentId\": 1
  }"
}


//Cancel all orders of all accounts for a specific instrument
{
  "m": 0,
  "i": 0,
  "n": "CancelAllOrders",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 0,
    \"InstrumentId\": 1
  }"
}


//Cancel all orders of all accounts for all instruments
{
  "m": 0,
  "i": 0,
  "n": "CancelAllOrders",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 0,
    \"InstrumentId\": 0
  }"
}
```

{% endtab %}
{% endtabs %}

| Key         | Value                                                                                                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId       | **integer**. The ID of the OMS on which the account operates. **required**.                                                                                               |
| AccountId   | **integer**. The account for which all orders are being canceled. If no AccountId is defined, orders for all accounts will be cancelled. **optional**.                    |
| IntrumentId | **integer**. The instrument for which all orders are being canceled. If there is no instrumentid defined, all orders for all instruments will be cancelled. **optional**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "CancelAllOrders",
  "o": "{
    \"result\": true,
    \"errormsg\": null,
    \"errorcode\": 0,
    \"detail\": null
  }"
}

```

The Response is a standard response object.

| Key       | Value                                                                                                                                                                                                                                                                                                                                                                                                       |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| result    | **boolean**. If the call has been successfully received by the OMS, *result* is *true;* otherwise it is *false.*                                                                                                                                                                                                                                                                                            |
| errormsg  | <p><strong>string</strong>. A successful receipt of the call returns <em>null.</em> The <em>errormsg</em> key for an unsuccessful call returns one of the following messages:<br>Not Authorized (errorcode 20)<br>Invalid Response (errorcode 100)<br>Operation Failed (errorcode 101)<br>Server Error (errorcode 102)<br>Resource Not Found (errorcode 104)<br>Operation Not Supported (errorcode 106)</p> |
| errorcode | **integer**. A successful receipt of the call returns 0. An unsuccessful receipt of the call returns one of the *errorcodes* shown in the *errormsg* list.                                                                                                                                                                                                                                                  |
| detail    | **string**. Message text that the system may send.                                                                                                                                                                                                                                                                                                                                                          |

### GetOrderStatus

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Gets the status information for a single order.

A user with NotbankTrading permission can only retrieve status information of orders for accounts with which he/she is associated to.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOrderStatus({
    "AccountId": 7,
    "OrderId": 6562
});

// request payload
{
  AccountId?: number;
  OrderId?: number;
}

```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOrderStatusParamBuilder;

var response = client.getTradingService().getOrderStatus(new GetOrderStatusParamBuilder()
    .accountId(7)
    .orderId(50443359L)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models.get_order_status import GetOrderStatusRequest

response = client.get_order_status(GetOrderStatusRequest(
    account_id=7,
    order_id=6562,
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetOrderStatus",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 7,
    \"OrderId\": 6562
  }"
}
```

{% endtab %}
{% endtabs %}

| Key       | Value                                                                              |
| --------- | ---------------------------------------------------------------------------------- |
| OMSId     | **integer**. The ID of the OMS on which the order was placed. **optional**.        |
| AccountId | **integer**. The ID of the account under which the order was placed. **required**. |
| OrderId   | **integer**. The ID of the order whose status will be returned. **required**.      |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetOrderStatus",
  "o": "{
    \"Side\": \"Buy\",
    \"OrderId\": 6562,
    \"Price\": 23436.0,
    \"Quantity\": 0.02,
    \"DisplayQuantity\": 0.0,
    \"Instrument\": 1,
    \"Account\": 7,
    \"AccountName\": \"sample\",
    \"OrderType\": \"Limit\",
    \"ClientOrderId\": 0,
    \"OrderState\": \"Working\",
    \"ReceiveTime\": 1680020672485,
    \"ReceiveTimeTicks\": 638156174724846502,
    \"LastUpdatedTime\": 1680020672485,
    \"LastUpdatedTimeTicks\": 638156174724852936,
    \"OrigQuantity\": 0.02,
    \"QuantityExecuted\": 0.0,
    \"GrossValueExecuted\": 0.0,
    \"ExecutableValue\": 0.0,
    \"AvgPrice\": 0.0,
    \"CounterPartyId\": 0,
    \"ChangeReason\": \"NewInputAccepted\",
    \"OrigOrderId\": 6562,
    \"OrigClOrdId\": 0,
    \"EnteredBy\": 0,
    \"UserName\": \"\",
    \"IsQuote\": false,
    \"InsideAsk\": 29000.0,
    \"InsideAskSize\": 0.52,
    \"InsideBid\": 23436.0,
    \"InsideBidSize\": 0.0,
    \"LastTradePrice\": 29000.0,
    \"RejectReason\": \"\",
    \"IsLockedIn\": false,
    \"CancelReason\": \"\",
    \"OrderFlag\": \"AddedToBook\",
    \"UseMargin\": false,
    \"StopPrice\": 0.0,
    \"PegPriceType\": \"Ask\",
    \"PegOffset\": 0.0,
    \"PegLimitOffset\": 0.0,
    \"IpAddress\": null,
    \"IPv6a\": 0,
    \"IPv6b\": 0,
    \"ClientOrderIdUuid\": null,
    \"OMSId\": 1
  }"
}

```

| Key                | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Side               | <p><strong>string</strong>. The side of a trade. One of:<br>- <strong>0</strong> Buy<br>- <strong>1</strong> Sell.</p>                                                                                                                                                                                                                                                                                                                                                                                |
| OrderId            | **long integer**. The ID of the open order. The *OrderID* is unique in each OMS.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Price              | **decimal**. The price at which the buy or sell has been ordered.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Quantity           | **decimal**. The quantity of the product to be bought or sold.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| DisplayQuantity    | **decimal**. The quantity available to buy or sell that is publicly displayed to the market. To display a *displayQuantity* value, an order must be a Limit order with a reserve.                                                                                                                                                                                                                                                                                                                     |
| Instrument         | **integer**. The ID of the instrument being traded. The call **GetInstruments** can supply the instrument IDs that are available.                                                                                                                                                                                                                                                                                                                                                                     |
| Account            | **integer**. The ID of the of the account which submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| AccountName        | **string**. Name of the of the account which submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| OrderType          | **string**. Will always be **BlockTrade** as this GetOpenTradeReports API will only return open blocktrades.                                                                                                                                                                                                                                                                                                                                                                                          |
| ClientOrderId      | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                                                                                                                                                                                                                                                                                                    |
| OrderState         | <p><strong>string</strong>. The state of the order. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 FullyExecuted.</p>                                                                                                                                                                                                                                                                                                                                    |
| ReceiveTime        | **long integer**. Time stamp of the order in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                                      |
| ReceiveTimeTicks   | **long integer**. Time stamp of the order Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                                          |
| OrigQuantity       | **decimal**. If the open order has been changed or partially filled, this value shows the original quantity of the order.                                                                                                                                                                                                                                                                                                                                                                             |
| QuantityExecuted   | **decimal**. If the open order has been at least partially executed, this value shows the amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                              |
| GrossValueExecuted | **decimal**. If the open order has been at least partially executed, this value shows the gross amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                        |
| AvgPrice           | **decimal**. The average executed price of the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| CounterPartyId     | **integer**. The ID of the account who is the counterparty for the trade if order is already executed, either partial or fully executed.                                                                                                                                                                                                                                                                                                                                                              |
| ChangeReason       | <p><strong>string</strong>. If the order has been changed, this string value holds the reason. One of:<br>- 0 Unknown<br>- 1 NewInputAccepted<br>- 2 NewInputRejected<br>- 3 OtherRejected<br>- 4 Expired<br>- 5 Trade<br>- 6 SystemCanceled\_NoMoreMarket<br>- 7 SystemCanceled\_BelowMinimum<br>- 8 SystemCanceled\_PriceCollar<br>- 9 SystemCanceled\_MarginFailed<br>- 100 UserModified<br>An order that is newly added to book will have <strong>NewInputAccepted</strong> value by default.</p> |
| OrigOrderId        | **integer**. If the order is a replacement order, this is the ID of the original order.                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrigClOrdId        | **integer**. If the order is a replacement order, this is the client order ID or the original order.                                                                                                                                                                                                                                                                                                                                                                                                  |
| EnteredBy          | **integer**. The ID of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Username           | **string**. The username of the user who submitted the order. Usually returns as an empty string.                                                                                                                                                                                                                                                                                                                                                                                                     |
| IsQuote            | **boolean**. If this order is a quote, the value for *IsQuote* is *true*, otherwise it is *false.*                                                                                                                                                                                                                                                                                                                                                                                                    |
| InsideAsk          | **decimal**. If this order is a quote, this value is the Inside Ask price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideAskSize      | **decimal**. If this order is a quote, this value is the quantity of the Inside Ask quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBid          | **decimal**. If this order is a quote, this value is the Inside Bid price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBidSize      | **decimal**. If this order is a quote, this value is the quantity of the Inside Bid quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| LastTradePrice     | **decimal**. The last price that this instrument traded at.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| RejectReason       | **string**. If this open order has been rejected, this string holds the reason for the rejection.                                                                                                                                                                                                                                                                                                                                                                                                     |
| IsLockedIn         | **boolean**. For a block trade, if both parties to the block trade agree that one of the parties will report the trade for both sides, this value is *true.* Othersise, *false.*                                                                                                                                                                                                                                                                                                                      |
| CancelReason       | **string**. If this order has been canceled, this string holds the cancellation reason.                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderFlag          | **string**. One or more of: **NoAccountRiskCheck**, **AddedToBook**, **RemovedFromBook**, **PostOnly**, **Liquidation**, **ReverseMarginPosition**, **Synthetic**.                                                                                                                                                                                                                                                                                                                                    |
| UseMargin          | **boolean**. Margin is not yet supported so this always defaults to false.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| StopPrice          | **decimal**. The price at which the order executes, if the order is a stop order. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                             |
| PegPriceType       | **string**. The type of price to peg the Stop to for Stop/Trailing orders.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PegOffset          | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| PegLimitOffset     | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| IpAddress          | **string**. The IP address from where the order was submitted.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| OMSId              | **integer**. The ID of the OMS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

### GetOrdersHistory

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Gets a list of orders for the specified search parameters.

For example, if *depth* = 200 and *startIndex* = 0, the history returns 200 unique orders into the past starting with the most recent (0) order. If *depth* = 200 and *startIndex* = 100, the history returns 200 unique orders into the past starting at 101st order in the past.

The owner of the trading venue determines how long to retain order history before archiving.

A user with NotbankTrading permission can only retrieve orders history for accounts with which he/she is associated to.

**Note:** In this call, "Depth" refers to the maximum number/count of orders that can be retrieved.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOrdersHistory({
    "AccountId": 7
});

// request payload
{
  AccountId: number;
  OrderState?: OrderState;
  OrderId?: number;
  ClientOrderId?: number;
  OriginalOrderId?: number;
  OriginalClientOrderId?: number;
  UserId?: number;
  InstrumentId?: number;
  StartTimestamp?: number;
  EndTimestamp?: number;
  Depth?: number;
  Limit?: number;
  StartIndex?: number;
}

```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOrderHistoryParamBuilder;

var response = client.getTradingService()
        .getOrderHistory(new GetOrderHistoryParamBuilder(7)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetOrderHistoryRequest

response = client.get_order_history(GetOrderHistoryRequest(
    account_id=7,
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetOrdersHistory",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 7
  }"
}
```

{% endtab %}
{% endtabs %}

| Key                   | Value                                                                                                                                                                                                                                                                                                                                                                                        |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId                 | **integer**. The ID of the OMS on which the orders took place. **required**.                                                                                                                                                                                                                                                                                                                 |
| AccountId             | **integer**. The account ID that made the trades. A user with NotbankTrading permission must be associated with this account, although other users also can be associated with the account. Not explicitly required if the authenticated user has elevated permission/s. **conditionally required**.                                                                                         |
| OrderState            | <p><strong>string</strong>. The current state of the order. Can be used to filter results. If not specified all orders regardless of the order state will be returned. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 FullyExecuted<br><strong>optional</strong>.</p>                                                                           |
| OrderId               | **long integer**. The ID of the order. Can be used to filter results. Can be used to filter for a specific orderid. There is a specific API call **GetOrderHistoryByOrderId** for filtering orders by **OrderId**. **optional**.                                                                                                                                                             |
| ClientOrderId         | **long integer**. A user-assigned ID for the order (like a purchase-order number assigned by a company). Can be used to filter results. Default is 0. **optional**.                                                                                                                                                                                                                          |
| OriginalOrderId       | **long integer**. The original ID of the order. If specified, the call returns changed orders associated with this order ID. Can be used to filter results. **optional**.                                                                                                                                                                                                                    |
| OriginalClientOrderId | **long integer**. If the order has been changed, shows the original client order ID, a value that the client can create (much like a purchase order). Can be used to filter results. **optional**.                                                                                                                                                                                           |
| UserId                | **integer**. The ID of the user whose account orders will be returned. If not specified, the call returns the orders of the logged-in user. Can be used to filter results. **optional**.                                                                                                                                                                                                     |
| InstrumentId          | **long integer**. The ID of the instrument named in the order. If not specified, the call returns orders for all instruments traded by this account. Can be used to filter results. **optional**.                                                                                                                                                                                            |
| StartTimestamp        | **long integer**. Date and time at which to begin the orders history, in POSIX format. Can be used to filter results. **optional**.                                                                                                                                                                                                                                                          |
| EndTimestamp          | **long integer**. Date and time at which to end the orders report, in POSIX format. Can be used to filter results. **optional**.                                                                                                                                                                                                                                                             |
| Depth                 | **integer**. In this case, the maximum number/count of unique orders to return, counting from the *StartIndex* if it is also specified. If not specified, returns the 100 most recent to orders; results can vary depending if other optional fields are defined such as *StartIndex*, *StartTimestamp*, and *EndTimestamp*. Can be used to filter results and for pagination. **optional**. |
| Limit                 | **integer**. Functions exactly the same as the **Depth** field. **optional**.                                                                                                                                                                                                                                                                                                                |
| StartIndex            | **integer**. A value of 0 means the first object in the result will be the the most recent order, a value of 2 means that the first object in the result set will be the third most recent order. Can be used to filter results or for pagination. Default is 0. **optional**.                                                                                                               |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetOrdersHistory",
  "o": "[
    {
      \"Side\": \"Sell\",
      \"OrderId\": 6713,
      \"Price\": 0.0,
      \"Quantity\": 0.0,
      \"DisplayQuantity\": 0.0,
      \"Instrument\": 11,
      \"Account\": 7,
      \"AccountName\": \"sample\",
      \"OrderType\": \"Market\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"FullyExecuted\",
      \"ReceiveTime\": 1682663431785,
      \"ReceiveTimeTicks\": 638182602317851821,
      \"LastUpdatedTime\": 1682663431791,
      \"LastUpdatedTimeTicks\": 638182602317910891,
      \"OrigQuantity\": 0.01,
      \"QuantityExecuted\": 0.01,
      \"GrossValueExecuted\": 60.0,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 6000.0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6713,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"LastTradePrice\": 6000.0,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Bid\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Sell\",
      \"OrderId\": 6709,
      \"Price\": 0.0,
      \"Quantity\": 0.0,
      \"DisplayQuantity\": 0.0,
      \"Instrument\": 11,
      \"Account\": 7,
      \"AccountName\": \"sample\",
      \"OrderType\": \"Market\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"FullyExecuted\",
      \"ReceiveTime\": 1682663089848,
      \"ReceiveTimeTicks\": 638182598898484597,
      \"LastUpdatedTime\": 1682663089923,
      \"LastUpdatedTimeTicks\": 638182598899230197,
      \"OrigQuantity\": 0.01,
      \"QuantityExecuted\": 0.01,
      \"GrossValueExecuted\": 60.0,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 6000.0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6709,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"LastTradePrice\": 0.0,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Bid\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    }
  ]"
}
```

The **GetOrdersHistory** API method returns an array or objects, each object represents an order at its latest status; an order will only occupy 1 index or just 1 instance in the result. The **GetOrdersHistory** API method does not return the full history of a specific order, there is another API that will give you just that: **GetOrderHistoryByOrderId**.

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Side                 | <p><strong>string</strong>. The side of a trade. One of:<br>- <strong>0</strong> Buy<br>- <strong>1</strong> Sell.</p>                                                                                                                                                                                                                                                                                                                                                                                |
| OrderId              | **long integer**. The ID of the open order. The *OrderID* is unique in each OMS.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Price                | **decimal**. The price at which the buy or sell has been ordered.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Quantity             | **decimal**. The quantity of the product to be bought or sold.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| DisplayQuantity      | **decimal**. The quantity available to buy or sell that is publicly displayed to the market. To display a *displayQuantity* value, an order must be a Limit order with a reserve.                                                                                                                                                                                                                                                                                                                     |
| Instrument           | **integer**. The ID of the instrument being traded. The API method **GetInstruments** can supply the instrument IDs that are available.                                                                                                                                                                                                                                                                                                                                                               |
| Account              | **integer**. The ID of the of the account which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| AccountName          | **string**. Name of the of the account which which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| OrderType            | <p><strong>string</strong>. Describes the type of order this is. One of:<br>- 0 Unknown (an error condition)<br>- 1 Market order<br>- 2 Limit<br>- 3 StopMarket<br>- 4 StopLimit<br>- 5 TrailingStopMarket<br>- 6 TrailingStopLimit<br>- 7 BlockTrade.</p>                                                                                                                                                                                                                                            |
| ClientOrderId        | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                                                                                                                                                                                                                                                                                                    |
| OrderState           | <p><strong>string</strong>. The current or the latest state of the order. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 Fully Executed.</p>                                                                                                                                                                                                                                                                                                             |
| ReceiveTime          | **long integer**. Time stamp of the order in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                                      |
| ReceiveTimeTicks     | **long integer**. Time stamp of the order Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                                          |
| LastUpdatedTime      | **long integer**. Time stamp when the order was last updated, in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                  |
| LastUpdatedTimeTicks | **long integer**. Time stamp when the order was last updated, in Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                   |
| OrigQuantity         | **decimal**. If the open order has been changed or partially filled, this value shows the original quantity of the order.                                                                                                                                                                                                                                                                                                                                                                             |
| QuantityExecuted     | **decimal**. If the open order has been at least partially executed, this value shows the amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                              |
| GrossValueExecuted   | **decimal**. If the open order has been at least partially executed, this value shows the gross amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                        |
| ExecutableValue      | **decimal**. Defaults to 0. For future provision                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| AvgPrice             | **decimal**. The average executed price of the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| CounterPartyId       | **integer**. The ID of the account who is the counterparty for the trade if order is already executed, either partial or fully executed.                                                                                                                                                                                                                                                                                                                                                              |
| ChangeReason         | <p><strong>string</strong>. If the order has been changed, this string value holds the reason. One of:<br>- 0 Unknown<br>- 1 NewInputAccepted<br>- 2 NewInputRejected<br>- 3 OtherRejected<br>- 4 Expired<br>- 5 Trade<br>- 6 SystemCanceled\_NoMoreMarket<br>- 7 SystemCanceled\_BelowMinimum<br>- 8 SystemCanceled\_PriceCollar<br>- 9 SystemCanceled\_MarginFailed<br>- 100 UserModified<br>An order that is newly added to book will have <strong>NewInputAccepted</strong> value by default.</p> |
| OrigOrderId          | **long integer**. If the order is a replacement order, this is the ID of the original order.                                                                                                                                                                                                                                                                                                                                                                                                          |
| OrigClOrdId          | **long integer**. If the order is a replacement order, this is the client order ID or the original order.                                                                                                                                                                                                                                                                                                                                                                                             |
| EnteredBy            | **integer**. The ID of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Username             | **string**. The username of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| IsQuote              | **boolean**. If this order is a quote, the value for *IsQuote* is *true*, otherwise it is *false.*                                                                                                                                                                                                                                                                                                                                                                                                    |
| InsideAsk            | **decimal**. If this order is a quote, this value is the Inside Ask price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideAskSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Ask quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBid            | **decimal**. If this order is a quote, this value is the Inside Bid price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBidSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Bid quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| LastTradePrice       | **decimal**. The last price that this instrument traded at.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| RejectReason         | **string**. If this open order has been rejected, this string holds the reason for the rejection.                                                                                                                                                                                                                                                                                                                                                                                                     |
| IsLockedIn           | **boolean**. For a block trade, if both parties to the block trade agree that one of the parties will report the trade for both sides, this value is *true.* Othersise, *false.*                                                                                                                                                                                                                                                                                                                      |
| CancelReason         | **string**. If this order has been canceled, this string holds the cancellation reason.                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderFlag            | <p><strong>integer or string</strong>. One or more of:<br>1 NoAccountRiskCheck<br>2 AddedToBook<br>4 RemovedFromBook<br>8 PostOnly<br>16 Liquidation<br>32 ReverseMarginPosition.</p>                                                                                                                                                                                                                                                                                                                 |
| UseMargin            | **boolean**. Margin is not yet supported so this always defaults to false.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| StopPrice            | **decimal**. The price at which the order executes, if the order is a stop order. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                             |
| PegPriceType         | **string**. The type of price to peg the Stop to for Stop/Trailing orders.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PegOffset            | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| PegLimitOffset       | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| IpAddress            | **string**. The IP address from where the order was submitted.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| OMSId                | **integer**. The ID of the OMS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

### GetTradesHistory

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Gets a list of trades for a specified account, order ID, user, instrument, or starting and ending time stamp. The returned list begins at start index *i*, where *i* is an integer identifying a specific trade in reverse order; that is, the most recent trade has an index of 0. “Depth” is the count of trades to report backwards from *StartIndex*.

Users with NotbankTrading permission can only retrieve trade history for accounts with which he/she is associated to.

**Caution**: You must coordinate \*StartIndex\*, \*Depth\*, \*StartTimeStamp\*, and \*EndTimeStamp\* to retrieve the historical information you need.**Note**: In this API method, “Depth” refers not to the depth of the order book, but to the count of trades to report. The owner of the trading venue determines how long to retain order history before archiving.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getTradesHistory({
    "AccountId": 7
});

// request payload
{
  AccountId?: number;
  InstrumentId?: number;
  TradeId?: number;
  OrderId?: number;
  UserId?: number;
  StartTimeStamp?: number;
  EndTimeStamp?: number;
  Depth?: number;
  StartIndex?: number;
  ExecutionId?: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetTradesHistoryParamBuilder;

var response = client.getTradingService().getTradesHistory(new GetTradesHistoryParamBuilder().accountId(7)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetTradesHistoryRequest

response = client.get_trades_history(GetTradesHistoryRequest(account_id=7))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetTradesHistory",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 7,
    \"Depth\": 2,
  }"
}
```

{% endtab %}
{% endtabs %}

| Key            | Value                                                                                                                                                                                                                                                                                                                                                                           |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId          | **integer**. The ID of the OMS on which the trades took place. **required**.                                                                                                                                                                                                                                                                                                    |
| AccountId      | **integer**. The account ID that made the trades. If no account ID is supplied, the system assumes the default account for the logged-in user making the call. **optional**.                                                                                                                                                                                                    |
| InstrumentId   | **integer**. the ID of the instrument whose trade history is reported. If not specified, defaults to 0 which means results won't be filtered according to it. **optional**.                                                                                                                                                                                                     |
| TradeId        | **long integer**. The ID of a specific trade. **optional**.                                                                                                                                                                                                                                                                                                                     |
| OrderId        | **long integer**. The ID of the order resulting in the trade. If specified, the call returns all trades associated with the order. If not specified, defaults to 0 which means results won't be filtered according to it. **optional**.                                                                                                                                         |
| UserId         | **integer**. If not specified, the call returns trades associated with the users belonging to the default account for the logged-in user. **optional**.                                                                                                                                                                                                                         |
| StartTimeStamp | **long integer**. The historical date and time at which to begin the trade report, in POSIX format. If not specified, defaults to 0 which means results won't be filtered according to it. Value must be in **milliseconds** if to be used. **optional**.                                                                                                                       |
| EndTimeStamp   | **long integer**. Date and time at which to end the trade report, in POSIX format. If not specified, defaults to 0 which means results won't be filtered according to it. Value must be in **milliseconds** if to be used. **optional**.                                                                                                                                        |
| Depth          | **integer**. In this case, the count of trades to return, counting from the *StartIndex*. If *Depth* is not specified, returns all trades between *BeginTimeStamp* and *EndTimeStamp*, beginning at *StartIndex*. If no other filter parameter is defined, the maximum will result set will be according to the **MaxApiResponseResultSet** Gateway config value. **optional**. |
| StartIndex     | **integer**. The starting index into the history of trades, from 0 (the most recent trade) and moving backwards in time. If not specified, defaults to 0 which means results won't be filtered according to it. **optional**.                                                                                                                                                   |
| ExecutionId    | **integer**. The ID of the individual buy or sell execution. If not specified, defaults to 0 which means results won't be filtered according to it. **optional**.                                                                                                                                                                                                               |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetTradesHistory",
  "o": "[
    {
      \"OMSId\": 1,
      \"ExecutionId\": 1928,
      \"TradeId\": 964,
      \"OrderId\": 6713,
      \"AccountId\": 7,
      \"AccountName\": \"sample\",
      \"SubAccountId\": 0,
      \"ClientOrderId\": 0,
      \"InstrumentId\": 11,
      \"Side\": \"Sell\",
      \"OrderType\": \"Market\",
      \"Quantity\": 0.01,
      \"RemainingQuantity\": 0.0,
      \"Price\": 6000.0,
      \"Value\": 60.0,
      \"CounterParty\": \"185\",
      \"OrderTradeRevision\": 1,
      \"Direction\": \"NoChange\",
      \"IsBlockTrade\": false,
      \"Fee\": 0.0,
      \"FeeProductId\": 0,
      \"OrderOriginator\": 6,
      \"UserName\": \"sample_user\",
      \"TradeTimeMS\": 1682663431787,
      \"MakerTaker\": \"Taker\",
      \"AdapterTradeId\": 0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"IsQuote\": false,
      \"CounterPartyClientUserId\": 1,
      \"NotionalProductId\": 1,
      \"NotionalRate\": 1.0,
      \"NotionalValue\": 60.0,
      \"NotionalHoldAmount\": 0,
      \"TradeTime\": 638182602317874025
    },
    {
      \"OMSId\": 1,
      \"ExecutionId\": 1924,
      \"TradeId\": 962,
      \"OrderId\": 6709,
      \"AccountId\": 7,
      \"AccountName\": \"sample\",
      \"SubAccountId\": 0,
      \"ClientOrderId\": 0,
      \"InstrumentId\": 11,
      \"Side\": \"Sell\",
      \"OrderType\": \"Market\",
      \"Quantity\": 0.01,
      \"RemainingQuantity\": 0.0,
      \"Price\": 6000.0,
      \"Value\": 60.0,
      \"CounterParty\": \"9\",
      \"OrderTradeRevision\": 1,
      \"Direction\": \"NoChange\",
      \"IsBlockTrade\": false,
      \"Fee\": 0.0,
      \"FeeProductId\": 0,
      \"OrderOriginator\": 6,
      \"UserName\": \"sample_user\",
      \"TradeTimeMS\": 1682663089862,
      \"MakerTaker\": \"Taker\",
      \"AdapterTradeId\": 0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"IsQuote\": false,
      \"CounterPartyClientUserId\": 1,
      \"NotionalProductId\": 1,
      \"NotionalRate\": 1.0,
      \"NotionalValue\": 60.0,
      \"NotionalHoldAmount\": 0,
      \"TradeTime\": 638182598898615128
    }
  ]"
}
```

The response is an array of objects, each element represents a single trade.

| Key                      | Value                                                                                                                                                                                                                 |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId                    | **integer**. The ID of the OMS on which the account resides.                                                                                                                                                          |
| ExecutionId              | **integer**. The ID of this account's side of the trade. Every trade has two sides.                                                                                                                                   |
| TradeId                  | **long integer**. The ID of the overall trade.                                                                                                                                                                        |
| OrderId                  | **long integer**. The ID of the order causing the trade (buy or sell).                                                                                                                                                |
| AccountId                | **integer**. The ID of the account that made the trade (buy or sell).                                                                                                                                                 |
| AccountName              | **string**. The Name of the account that made the trade (buy or sell).                                                                                                                                                |
| SubAccountId             | **integer**. Not currently used; reserved for future use. Defaults to 0.                                                                                                                                              |
| ClientOrderId            | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                    |
| InstrumentId             | **integer**. The ID of the instrument being traded. An instrument comprises two products, for example Dollars and Bitcoin.                                                                                            |
| Side                     | <p><strong>string</strong>. One of:<br>- <strong>0</strong> Buy<br>- <strong>1</strong> Sell.</p>                                                                                                                     |
| OrderType                | <p><strong>string</strong>. One of:<br>- Market<br>- Limit<br>- BlockTrade<br>- StopMarket<br>- StopLimit<br>- TrailingStopLimit<br>- StopMarket<br>- TrailingStopMarket.</p>                                         |
| Quantity                 | **decimal**. The unit quantity of this side of the trade.                                                                                                                                                             |
| RemainingQuantity        | **decimal**. The number of units remaining to be traded by the order after this execution. This number is not revealed to the other party in the trade. This value is also known as "leave size" or "leave quantity." |
| Price                    | **decimal**. The unit price at which the instrument traded.                                                                                                                                                           |
| Value                    | <p><strong>decimal</strong>. The total value of the deal. The system calculates this as:<br>unit price X quantity executed.</p>                                                                                       |
| CounterParty             | **string**. The ID of the other party in a block trade. Usually, IDs are stated as integers; this value is an integer written as a string.                                                                            |
| OrderTradeRevision       | **integer**. The revision number of this trade; usually 1.                                                                                                                                                            |
| Direction                | <p><strong>integer</strong>. The effect of the trade on the instrument's market price. One of:<br>- <strong>0</strong> No change<br>- <strong>1</strong> Uptick<br>- <strong>2</strong> DownTick.</p>                 |
| IsBlockTrade             | **boolean**. A value of *true* means that this trade was a block trade; a value of *false* that it was not a block trade.                                                                                             |
| Fee                      | **decimal**. Any fee levied against the trade by the Exchange.                                                                                                                                                        |
| FeeProductId             | **integer**. The ID of the product in which the fee was levied.                                                                                                                                                       |
| OrderOriginator          | **integer**. The ID of the user who initiated the trade.                                                                                                                                                              |
| UserName                 | **string**. The UserName of the user who initiated the trade.                                                                                                                                                         |
| TradeTimeMS              | **long integer**. The date and time that the trade took place, in milliseconds and POSIX format. All dates and times are UTC.                                                                                         |
| MakerTaker               | <p><strong>string</strong>. One of:<br>- Maker<br>- Taker.</p>                                                                                                                                                        |
| AdapterTradeId           | **integer**. The ID of the adapter of the overall trade.                                                                                                                                                              |
| InsideBid                | **decimal**. The best (highest) price level of the buy side of the book at the time of the trade.                                                                                                                     |
| InsideBidSize            | **decimal**. The quantity of the best (highest) price level of the buy side of the book at the time of the trade.                                                                                                     |
| InsideAsk                | **decimal**. The best (lowest) price level of the sell side of the book at the time of the trade.                                                                                                                     |
| InsideAskSize            | **decimal**. The quantity of the best (lowest) price level of the sell side of the book at the time of the trade.                                                                                                     |
| CounterPartyClientUserId | **integer**. Indicates counterparty source of trade (OMS, Remarketer, FIX)                                                                                                                                            |
| NotionalProductId        | **integer**. The id of the notional product the notional value was captured in                                                                                                                                        |
| NotionalRate             | **decimal**. Notional rate from base currency at time of trade                                                                                                                                                        |
| NotionalValue            | **decimal**. Notional value in base currency of venue at time of trade                                                                                                                                                |
| TradeTime                | **long integer**. The date and time that the trade took place, in C# Ticks. All dates and times are UTC.                                                                                                              |

### GetOrderHistoryByOrderId

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Gets a list of orders, being the history of a single order, from being added to the book up to the full execution or rejection, or cancellation. ReceiveTime in POSIX format X 1000 (milliseconds since 1 January 1970)

A user with NotbankTrading permission can only retrieve an order history for accounts with which he/she is associated to.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOrderHistoryByOrderId({
  "OrderId": 6459
});

// request payload
{
  OrderId: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOrdersHistoryByOrderIdParamBuilder;

var response = client.getTradingService()
        .getOrderHistoryByOrderId(new GetOrdersHistoryByOrderIdParamBuilder(6459L)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetOrderHistoryByOrderIdRequest

response = client.get_order_history_by_order_id(GetOrderHistoryByOrderIdRequest(
    order_id=6459,
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetOrderHistoryByOrderId",
  "o": "{
    \"OMSId\": 1,
    \"OrderId\": 6459
  }"
}
```

{% endtab %}
{% endtabs %}

| Key     | Value                                                                                                    |
| ------- | -------------------------------------------------------------------------------------------------------- |
| OMSId   | **integer**. The ID of the OMS. **required**.                                                            |
| OrderId | **long integer**. The ID of the of the order which you want to get details and history of. **required**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetOrderHistoryByOrderId",
  "o": "[
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6459,
      \"Price\": 1.3638,
      \"Quantity\": 0.0,
      \"DisplayQuantity\": 0.0,
      \"Instrument\": 9,
      \"Account\": 7,
      \"AccountName\": \"sample_user\",
      \"OrderType\": \"Limit\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"FullyExecuted\",
      \"ReceiveTime\": 1678263954878,
      \"ReceiveTimeTicks\": 638138607548778980,
      \"LastUpdatedTime\": 1678263960020,
      \"LastUpdatedTimeTicks\": 638138607600197010,
      \"OrigQuantity\": 18307.63,
      \"QuantityExecuted\": 18307.63,
      \"GrossValueExecuted\": 24966.439664,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 1.3637177321149706433874837977,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6455,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_superuser\",
      \"IsQuote\": false,
      \"InsideAsk\": 1.3646,
      \"InsideAskSize\": 8959.3,
      \"InsideBid\": 1.3638,
      \"InsideBidSize\": 10776.98,
      \"LastTradePrice\": 1.3636,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"AddedToBook, RemovedFromBook\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Last\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6459,
      \"Price\": 1.3638,
      \"Quantity\": 10776.98,
      \"DisplayQuantity\": 10776.98,
      \"Instrument\": 9,
      \"Account\": 7,
      \"AccountName\": \"sample_user\",
      \"OrderType\": \"Limit\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"Working\",
      \"ReceiveTime\": 1678263954878,
      \"ReceiveTimeTicks\": 638138607548778980,
      \"LastUpdatedTime\": 1678263954881,
      \"LastUpdatedTimeTicks\": 638138607548809830,
      \"OrigQuantity\": 18307.63,
      \"QuantityExecuted\": 7530.65,
      \"GrossValueExecuted\": 10268.79434,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 1.3636,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6455,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_superuser\",
      \"IsQuote\": false,
      \"InsideAsk\": 1.3646,
      \"InsideAskSize\": 8959.3,
      \"InsideBid\": 1.3638,
      \"InsideBidSize\": 10776.98,
      \"LastTradePrice\": 1.3636,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"AddedToBook\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Last\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6459,
      \"Price\": 1.3638,
      \"Quantity\": 10776.98,
      \"DisplayQuantity\": 10776.98,
      \"Instrument\": 9,
      \"Account\": 7,
      \"AccountName\": \"sample_user\",
      \"OrderType\": \"Limit\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"Working\",
      \"ReceiveTime\": 1678263954878,
      \"ReceiveTimeTicks\": 638138607548778980,
      \"LastUpdatedTime\": 1678263954881,
      \"LastUpdatedTimeTicks\": 638138607548807642,
      \"OrigQuantity\": 18307.63,
      \"QuantityExecuted\": 7530.65,
      \"GrossValueExecuted\": 10268.79434,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 1.3636,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6455,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_superuser\",
      \"IsQuote\": false,
      \"InsideAsk\": 1.3636,
      \"InsideAskSize\": 7530.65,
      \"InsideBid\": 0.0,
      \"InsideBidSize\": 0.0,
      \"LastTradePrice\": 1.3636,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Last\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6459,
      \"Price\": 1.3638,
      \"Quantity\": 18307.63,
      \"DisplayQuantity\": 18307.63,
      \"Instrument\": 9,
      \"Account\": 7,
      \"AccountName\": \"sample_user\",
      \"OrderType\": \"Limit\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"Working\",
      \"ReceiveTime\": 1678263954878,
      \"ReceiveTimeTicks\": 638138607548778980,
      \"LastUpdatedTime\": 1678263954880,
      \"LastUpdatedTimeTicks\": 638138607548795384,
      \"OrigQuantity\": 18307.63,
      \"QuantityExecuted\": 0.0,
      \"GrossValueExecuted\": 0.0,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 0.0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"NewInputAccepted\",
      \"OrigOrderId\": 6455,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_superuser\",
      \"IsQuote\": false,
      \"InsideAsk\": 1.3636,
      \"InsideAskSize\": 7530.65,
      \"InsideBid\": 0.0,
      \"InsideBidSize\": 0.0,
      \"LastTradePrice\": 1.3636,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Last\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    }
  ]"
}
```

Returns the full history of a specific order or simply all the order states that the order went through. Response is an array of objects, each object represents the order itself in a specific orderstate.

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Side                 | <p><strong>string</strong>. The side of a trade. One of:<br>- <strong>0</strong> Buy<br>- <strong>1</strong> Sell.</p>                                                                                                                                                                                                                                                                                                                                                                                |
| OrderId              | **long integer**. The ID of the open order. The *OrderID* is unique in each OMS.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Price                | **decimal**. The price at which the buy or sell has been ordered.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Quantity             | **decimal**. The quantity of the product to be bought or sold.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| DisplayQuantity      | **decimal**. The quantity available to buy or sell that is publicly displayed to the market. To display a *displayQuantity* value, an order must be a Limit order with a reserve.                                                                                                                                                                                                                                                                                                                     |
| Instrument           | **integer**. The ID of the instrument being traded. The call **GetInstruments** can supply the instrument IDs that are available.                                                                                                                                                                                                                                                                                                                                                                     |
| Account              | **integer**. The ID of the of the account which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| AccountName          | **string**. Name of the of the account which which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| OrderType            | <p><strong>string</strong>. Describes the type of order this is. One of:<br>- 0 Unknown (an error condition)<br>- 1 Market order<br>- 2 Limit<br>- 3 StopMarket<br>- 4 StopLimit<br>- 5 TrailingStopMarket<br>- 6 TrailingStopLimit<br>- 7 BlockTrade.</p>                                                                                                                                                                                                                                            |
| ClientOrderId        | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                                                                                                                                                                                                                                                                                                    |
| OrderState           | <p><strong>string</strong>. The current or the latest state of the order. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 Fully Executed.</p>                                                                                                                                                                                                                                                                                                             |
| ReceiveTime          | **long integer**. Time stamp of the order in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                                      |
| ReceiveTimeTicks     | **long integer**. Time stamp of the order Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                                          |
| LastUpdatedTime      | **long integer**. Time stamp when the order was last updated, UNIX timestamp format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                            |
| LastUpdatedTimeTicks | **long integer**. Time stamp when the order was last updated, in Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                   |
| OrigQuantity         | **decimal**. If the open order has been changed or partially filled, this value shows the original quantity of the order.                                                                                                                                                                                                                                                                                                                                                                             |
| QuantityExecuted     | **decimal**. If the open order has been at least partially executed, this value shows the amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                              |
| GrossValueExecuted   | **decimal**. If the open order has been at least partially executed, this value shows the gross amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                        |
| ExecutableValue      | **decimal**. Defaults to 0. For future provision                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| AvgPrice             | **decimal**. The average executed price of the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| CounterPartyId       | **integer**. The ID of the account who is the counterparty for the trade if order is already executed, either partial or fully executed.                                                                                                                                                                                                                                                                                                                                                              |
| ChangeReason         | <p><strong>string</strong>. If the order has been changed, this string value holds the reason. One of:<br>- 0 Unknown<br>- 1 NewInputAccepted<br>- 2 NewInputRejected<br>- 3 OtherRejected<br>- 4 Expired<br>- 5 Trade<br>- 6 SystemCanceled\_NoMoreMarket<br>- 7 SystemCanceled\_BelowMinimum<br>- 8 SystemCanceled\_PriceCollar<br>- 9 SystemCanceled\_MarginFailed<br>- 100 UserModified<br>An order that is newly added to book will have <strong>NewInputAccepted</strong> value by default.</p> |
| OrigOrderId          | **long integer**. If the order is a replacement order, this is the ID of the original order.                                                                                                                                                                                                                                                                                                                                                                                                          |
| OrigClOrdId          | **long integer**. If the order is a replacement order, this is the client order ID or the original order.                                                                                                                                                                                                                                                                                                                                                                                             |
| EnteredBy            | **integer**. The ID of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Username             | **string**. The username of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| IsQuote              | **boolean**. If this order is a quote, the value for *IsQuote* is *true*, otherwise it is *false.*                                                                                                                                                                                                                                                                                                                                                                                                    |
| InsideAsk            | **decimal**. If this order is a quote, this value is the Inside Ask price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideAskSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Ask quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBid            | **decimal**. If this order is a quote, this value is the Inside Bid price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBidSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Bid quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| LastTradePrice       | **decimal**. The last price that this instrument traded at.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| RejectReason         | **string**. If this open order has been rejected, this string holds the reason for the rejection.                                                                                                                                                                                                                                                                                                                                                                                                     |
| IsLockedIn           | **boolean**. For a block trade, if both parties to the block trade agree that one of the parties will report the trade for both sides, this value is *true.* Othersise, *false.*                                                                                                                                                                                                                                                                                                                      |
| CancelReason         | **string**. If this order has been canceled, this string holds the cancellation reason.                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderFlag            | <p><strong>integer or string</strong>. One or more of:<br>1 NoAccountRiskCheck<br>2 AddedToBook<br>4 RemovedFromBook<br>8 PostOnly<br>16 Liquidation<br>32 ReverseMarginPosition.</p>                                                                                                                                                                                                                                                                                                                 |
| UseMargin            | **boolean**. Margin is not yet supported so this always defaults to false.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| StopPrice            | **decimal**. The price at which the order executes, if the order is a stop order. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                             |
| PegPriceType         | **string**. The type of price to peg the Stop to for Stop/Trailing orders.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PegOffset            | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| PegLimitOffset       | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| IpAddress            | **string**. The IP address from where the order was submitted.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| OMSId                | **integer**. The ID of the OMS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

### GetTickerHistory

**Permissions:** Public\
**Call Type:** Synchronous

Gets a list of tickers, being the ticker history (high, low, open, close, volume, bid, ask, ID) of a specific instrument from the given **FromDate** up to the **ToDate** in the request payload. You will need to format the returned data per your requirements.

Because permission is Public, any user can retrieve the ticker history for any instrument on the OMS.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getTickerHistory({
  "InstrumentId": 1,
  "Interval": 60,
  "FromDate": "2023-01-18 01:02:03",
  "ToDate": "2023-08-31 23:59:59"
});

// request payload
{
  InstrumentId: number;
  Interval: number;
  FromDate: string;
  ToDate: string;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetTickerHistoryParamBuilder;

var response = client.getTradingService().getTickerHistory(new GetTickerHistoryParamBuilder(
    154,
    60,
    "2023-01-18 01:02:03",
    "2023-08-31 23:59:59")).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetTickerHistoryRequest

response = client.get_ticker_history(GetTickerHistoryRequest(
    instrument_id=1,
    interval=60,
    from_date="2023-01-18 01:02:03",
    to_date="2023-08-31 23:59:59",
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetTickerHistory",
  "o": "{
    \"InstrumentId\": 1,
    \"Interval\": 60,
    \"FromDate\": \"2023-01-18 01:02:03\",
    \"ToDate\": \"2023-08-31 23:59:59\",
    \"OMSId\": 1
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                                                                                                                                           |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId        | **integer**. The ID of the OMS. **required**.                                                                                                                                   |
| InstrumentId | **integer**. The ID of a specific instrument. **required**.                                                                                                                     |
| Interval     | **integer**. The time between ticks, in seconds. For example, a value of 60 returns ticker array elements between *FromDate* to *ToDate* in 60-second increments. **required**. |
| FromDate     | **string**. Oldest date from which the ticker history will start; in DateTime format (hour:minutes:seconds). Default is 00:00:00. **required**.                                 |
| ToDate       | **string**. Most recent date, at which the ticker history will end; in DateTime format (hour:minutes:seconds). Default is 00:00:00. **required**.                               |

#### Response

> The response is an array of arrays of comma-separated, but unlabeled, numbers. This sample shows comments applied to identify the data being returned (comments are not part of the response):

```json
{
  "m": 1,
  "i": 0,
  "n": "GetTickerHistory",
  "o": "[
    [
      1692926460000, //EndDateTime
      28432.44, //High
      28432.44, //Low
      28432.44, //Open
      28432.44, //Close
      0, //Volume
      0, //Best Bid
      0, //Best Ask
      1, //InstrumentId
      1692926400000 //BeginDateTime
      ]
  ]"
}
```

Returns an array of arrays dating from the *FromDate* value of the request to the *ToDate*. The data are returned oldest-date first. The data returned in the arrays are not labeled.

| Key           | Value                                                                                     |
| ------------- | ----------------------------------------------------------------------------------------- |
| EndDateTime   | **long integer**. The end/closing date and time of the ticker, in UTC and POSIX format.   |
| High          | **decimal**. The Highest Trade Price for the Time-Period ( 0 if no trades ).              |
| Low           | **decimal**. The Lowest Trade Price for the Time-Period ( 0 if no trades ).               |
| Open          | **decimal**. The Opening Trade Price for the Time-Period ( 0 if no trades ).              |
| Close         | **decimal**. The Last Trade Price for the Time-Period ( 0 if no trades ).                 |
| Volume        | **decimal**. The Total Trade Volume since the last Tick.                                  |
| Bid           | **decimal**. The best bid price at the time of the Tick.                                  |
| Ask           | **decimal**. The best ask price at the time of the Tick.                                  |
| InstrumentId  | **integer**. The ID of the instrument.                                                    |
| BeginDateTime | **long integer**. The start/opening date and time of the ticker, in UTC and POSIX format. |

### GetLastTrades

**Permissions:** Public, NotbankTrading\
**Call Type:** Synchronous

Gets the list of last trades that happened for a specific instrument.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

//Get all trades for instrument id 1
await client.getTradingService().getLastTrades({
  "InstrumentId": 1
});

//Get the 10 most recent trades for instrumentid 1
await client.getTradingService().getLastTrades({
  "InstrumentId": 1,
  "Count": 10
});

// request payload
{
  InstrumentId: number;
  Count?: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetLastTradesParamBuilder;

var response = client.getTradingService()
    .getLastTrades(new GetLastTradesParamBuilder(1).count(10)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models.get_last_trades import GetLastTradesRequest

response = client.get_last_trades(GetLastTradesRequest(
    instrument_id=1,
    count=10,
))
```

{% endtab %}

{% tab title="Json" %}

```json
//Get all trades for instrument id 1
{
  "m": 0,
  "i": 0,
  "n": "GetLastTrades",
  "o": "{
    \"OMSId\": 1,
    \"InstrumentId\": 1
  }"
}


//Get the 10 most recent trades for instrumentid 1
{
  "m": 0,
  "i": 0,
  "n": "GetLastTrades",
  "o": "{
    \"OMSId\": 1,
    \"InstrumentId\": 1,
    \"Count\": 10
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                                                                                               |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| OMSId        | The ID of the OMS on which the instrument is being traded. **required**.                                                            |
| InstrumentId | The ID of the instrument. **required**.                                                                                             |
| Count        | Value represents the number of trades you want to get, value of 10 will return 10 most recent trades. Default is 100. **optional**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetLastTrades",
  "o": "[
    [14, 2, 0.02, 1970, 5922, 5923, 1675332676849, 1, 0, 0, 0],
    [15, 2, 0.98, 1970, 5922, 6012, 1676397856371, 0, 0, 0, 0],
  ]"
}
```

Returns an object with multiple arrays as a response, each array represents 1 trade.

| Key                                   | Value                                                                                                                                                                                                                                                                                                              |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 0 (TradeId)                           | **integer**. The ID of this trade.                                                                                                                                                                                                                                                                                 |
| 1 (InstrumentId)                      | **integer**. The ID of the instrument.                                                                                                                                                                                                                                                                             |
| 2 (Quantity)                          | **decimal**. The quantity of the instrument traded.                                                                                                                                                                                                                                                                |
| 3 (Price)                             | **decimal**. The price at which the instrument was traded.                                                                                                                                                                                                                                                         |
| 4 (Order1)                            | **integer**. The ID of the first order that resulted in the trade, either Buy or Sell.                                                                                                                                                                                                                             |
| 5 (Order2)                            | **integer**. The ID of the second order that resulted in the trade, either Buy or Sell.                                                                                                                                                                                                                            |
| 6 (Tradetime)                         | **long integer**. UTC trade time in Total Milliseconds. POSIX format.                                                                                                                                                                                                                                              |
| 7 (Direction)                         | <p><strong>integer</strong>. Effect of the trade on the instrument’s market price. One of:<br>- 0 NoChange<br>- 1 UpTick<br>- 2 DownTick</p>                                                                                                                                                                       |
| 8 (TakerSide)                         | <p><strong>integer</strong>. Which side of the trade took liquidity? One of:<br>- 0 Buy<br>- 1 Sell<br>The maker side of the trade provides liquidity by placing the order on the book (this can be a buy or a sell order). The other, taker, side takes the liquidity. It, too, can be buy-side or sell-side.</p> |
| 9 (BlockTrade)                        | **boolean**. True if it was a privately negotiated trade. Private trade returns 1 (*true*); otherwise 0 (*false*). Default is *false*.                                                                                                                                                                             |
| 10 (order1ClientId or order2ClientId) | **integer**. The client-supplied order ID for the trade. Internal logic determines whether the program reports the *order1ClientId* or the *order2ClientId*.                                                                                                                                                       |

### GetLevel1Summary

**Permissions:** NotbankTrading, Public\
**Call Type:** Synchronous

Gets the current Level 1 snapshot (best bid, best offer and other data such lasttradedprice) of all instruments trading on an OMS.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getLevel1Summary();
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetLevel1SummaryParamBuilder;

var response = client.getTradingService().getLevel1Summary(new GetLevel1SummaryParamBuilder()).get();
```

{% endtab %}

{% tab title="Python" %}

```python
response = client.get_level1_summary()
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetLevel1Summary",
  "o": "{
    \"OMSId\": 1
  }"
}
```

{% endtab %}
{% endtabs %}

| Key   | Value                                         |
| ----- | --------------------------------------------- |
| OMSId | **integer**. The ID of the OMS. **required**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetLevel1Summary",
  "o": "[
    \"{ \\\"OMSId\\\":1, \\\"InstrumentId\\\":1, \\\"BestBid\\\":30000, \\\"BestOffer\\\":32000, \\\"LastTradedPx\\\":29354.89, \\\"LastTradedQty\\\":0.2563, \\\"LastTradeTime\\\":1690773094972, \\\"SessionOpen\\\":0, \\\"SessionHigh\\\":0, \\\"SessionLow\\\":0, \\\"SessionClose\\\":29354.89, \\\"Volume\\\":0.2563, \\\"CurrentDayVolume\\\":0, \\\"CurrentDayNotional\\\":0, \\\"CurrentDayNumTrades\\\":0, \\\"CurrentDayPxChange\\\":0, \\\"Rolling24HrVolume\\\":0.0000000000000000000000000000, \\\"Rolling24HrNotional\\\":0.000000000000000000000000, \\\"Rolling24NumTrades\\\":0, \\\"Rolling24HrPxChange\\\":0, \\\"TimeStamp\\\":\\\"1690782922150\\\", \\\"BidQty\\\":1, \\\"AskQty\\\":1, \\\"BidOrderCt\\\":0, \\\"AskOrderCt\\\":0, \\\"Rolling24HrPxChangePercent\\\":0 }\",
    \"{ \\\"OMSId\\\":1, \\\"InstrumentId\\\":2, \\\"BestBid\\\":0, \\\"BestOffer\\\":0, \\\"LastTradedPx\\\":2500, \\\"LastTradedQty\\\":1, \\\"LastTradeTime\\\":1689087260408, \\\"SessionOpen\\\":0, \\\"SessionHigh\\\":0, \\\"SessionLow\\\":0, \\\"SessionClose\\\":2500, \\\"Volume\\\":1, \\\"CurrentDayVolume\\\":0, \\\"CurrentDayNotional\\\":0, \\\"CurrentDayNumTrades\\\":0, \\\"CurrentDayPxChange\\\":0, \\\"Rolling24HrVolume\\\":0.0000, \\\"Rolling24HrNotional\\\":0.0000, \\\"Rolling24NumTrades\\\":0, \\\"Rolling24HrPxChange\\\":0, \\\"TimeStamp\\\":\\\"1690782922150\\\", \\\"BidQty\\\":0, \\\"AskQty\\\":0, \\\"BidOrderCt\\\":0, \\\"AskOrderCt\\\":0, \\\"Rolling24HrPxChangePercent\\\":0 }\",
    \"{ \\\"OMSId\\\":1, \\\"InstrumentId\\\":3, \\\"BestBid\\\":0, \\\"BestOffer\\\":0, \\\"LastTradedPx\\\":9.66, \\\"LastTradedQty\\\":0.001, \\\"LastTradeTime\\\":1656645761755, \\\"SessionOpen\\\":0, \\\"SessionHigh\\\":0, \\\"SessionLow\\\":0, \\\"SessionClose\\\":9.66, \\\"Volume\\\":0.001, \\\"CurrentDayVolume\\\":0, \\\"CurrentDayNotional\\\":0, \\\"CurrentDayNumTrades\\\":0, \\\"CurrentDayPxChange\\\":0, \\\"Rolling24HrVolume\\\":0.000, \\\"Rolling24HrNotional\\\":0.00000, \\\"Rolling24NumTrades\\\":0, \\\"Rolling24HrPxChange\\\":0, \\\"TimeStamp\\\":\\\"1690782921869\\\", \\\"BidQty\\\":0, \\\"AskQty\\\":0, \\\"BidOrderCt\\\":0, \\\"AskOrderCt\\\":0, \\\"Rolling24HrPxChangePercent\\\":0 }\"
  ]"
}
```

Returns an array with multiple objects as string, each object represents the Level1 data of a specific instrument.

| Key                        | Value                                                                                                                                                                                             |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId                      | **integer**. The ID of the OMS.                                                                                                                                                                   |
| InstrumentId               | **integer**. The ID of the instrument being tracked.                                                                                                                                              |
| BestBid                    | **decimal**. The current best bid for the instrument.                                                                                                                                             |
| BestOffer                  | **decimal**. The current best offer for the instrument.                                                                                                                                           |
| LastTradedPx               | **decimal**. The last-traded price for the instrument.                                                                                                                                            |
| LastTradedQty              | **decimal**. The last-traded quantity for the instrument.                                                                                                                                         |
| LastTradeTime              | **long integer**. The time of the last trade, in POSIX format.                                                                                                                                    |
| SessionOpen                | **decimal**. Opening price. In markets with openings and closings, this is the opening price for the current session; in 24-hour markets, it is the price as of UTC Midnight.                     |
| SessionHigh                | **decimal**. Highest price during the trading day, either during a session with opening and closing prices or UTC midnight to UTC midnight.                                                       |
| SessionLow                 | **decimal**. Lowest price during the trading day, either during a session with opening and closing prices or UTC midnight to UTC midnight.                                                        |
| SessionClose               | **decimal**. The closing price. In markets with openings and closings, this is the closing price for the current session; in 24-hour markets, it is the price as of UTC Midnight.                 |
| Volume                     | **decimal**. The last-traded quantity for the instrument, same value as LastTradedQty.                                                                                                            |
| CurrentDayVolume           | **decimal**. The unit volume of the instrument traded either during a session with openings and closings or in 24-hour markets, the period from UTC Midnight to UTC Midnight.                     |
| CurrentDayNumTrades        | **integer**. The number of trades during the current day, either during a session with openings and closings or in 24-hour markets, the period from UTC Midnight to UTC Midnight.                 |
| CurrentDayPxChange         | **decimal**. Current day price change, either during a trading session or UTC Midnight to UTC midnight.                                                                                           |
| CurrentNotional            | **decimal**. Current day quote volume - resets at UTC Midnight.                                                                                                                                   |
| Rolling24HrNotional        | **decimal**. Rolling 24 hours quote volume.                                                                                                                                                       |
| Rolling24HrVolume          | **decimal**. Unit volume (quantity traded, in the product 1 or in the base currency denomination) of the instrument during the past 24 hours, regardless of time zone. Recalculates continuously. |
| Rolling24HrNumTrades       | **integer**. Number of trades during the past 24 hours, regardless of time zone. Recalculates continuously.                                                                                       |
| Rolling24HrPxChange        | **decimal**. Price change during the past 24 hours, regardless of time zone. Recalculates continuously.                                                                                           |
| TimeStamp                  | **string**. The time this information was provided, in POSIX format.                                                                                                                              |
| BidQty                     | **decimal**. The quantity currently being bid.                                                                                                                                                    |
| AskQty                     | **decimal**. The quantity currently being asked.                                                                                                                                                  |
| BidOrderCt                 | **integer**. The count of bid orders.                                                                                                                                                             |
| AskOrderCt                 | **integer**. The count of ask orders.                                                                                                                                                             |
| Rolling24HrPxChangePercent | **decimal**. Percent change in price during the past 24hours regardless of the timezone. Recalculates continuously.                                                                               |

### GetLevel1SummaryMin

**Permissions:** NotbankTrading, Public\
**Call Type:** Synchronous

Gets a list of the latest Level 1 Snapshot of all markets/instruments. Snapshot includes **LastTradedPx**, **Rolling24HrPxChange**, **Rolling24HrPxChangePercent**, **Rolling24HrVolume**. Can also be filtered according to instrument ids.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getLevel1SummaryMin({
  "InstrumentIds":"[1]"
});


// request payload
{
  InstrumentIds?: string;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetLevelSummaryParamBuilder;

var response = client.getTradingService()
        .getLevel1SummaryMin(new GetLevelSummaryParamBuilder().instrumentIds(List.of("1", "2", "3"))).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetLevel1SummaryMinRequest

response = client.get_level1_summary_min(GetLevel1SummaryMinRequest(
    instrument_ids=[1],
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetLevel1SummaryMin",
  "o": "{
    \"OMSId\": 1,
    \"InstrumentIds\":\"[1]\"
  }"
}
```

{% endtab %}
{% endtabs %}

| Key           | Value                                                                                                                                                                                                     |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId         | **integer**. The ID of the OMS. **required**.                                                                                                                                                             |
| InstrumentIds | **string**. An array but will be passed as a string. List of instrument ids to get level1 summaries of. If this field is not specified, level1 summary of all instruments will be returned. **optional**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetLevel1SummaryMin",
  "o": "[
    [
      1, //InstrumentId
      \"BTCUSD\", //Instrument symbol
      29900, //LastTradedPx
      -1100, //Rolling24HrPxChange
      -3.5483870967741935483870967700, //Rolling24HrPxChangePercent
      0.0021000000000000000000000000 //Rolling24HrVolume
    ],
    [
      2,
      \"ETHUSD\",
      20030,
      0,
      0,
      0.0000
    ]
  ]"
}
```

| Key                        | Value                                                                                                                                                                                             |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| InstrumentId               | **integer**. The ID of the instrument.                                                                                                                                                            |
| InstrumentSymbol           | **string**. The symbol of the instrument.                                                                                                                                                         |
| LastTradedPX               | **decimal**. The last-traded price for the instrument.                                                                                                                                            |
| Rolling24HrVolume          | **decimal**. Unit volume (quantity traded, in the product 1 or in the base currency denomination) of the instrument during the past 24 hours, regardless of time zone. Recalculates continuously. |
| Rolling24HrPxChange        | **decimal**. Change in price during the past 24 hours regardless of the timezone. Recalculates continuously.                                                                                      |
| Rolling24HrPxChangePercent | **decimal**. Percent change in price during the past 24 hours regardless of the timezone. Recalculates continuously.                                                                              |

### GetOpenTradeReports

**Permissions:** NotbankTrading, NotbankReadOnly\
**Call Type:** Synchronous

Gets the list of Open Trade Reports (block trades), for the given accountId. ReceiveTime is in POSIX format X 1000 (milliseconds since 1 January 1970).

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOpenTradeReports({
  "AccountId": 9
});


// request payload
{
  AccountId: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOpenTradeReportParamBuilder;

var response = client.getTradingService().getOpenTradeReports(new GetOpenTradeReportParamBuilder(9)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetOpenTradeReportsRequest

response = client.get_open_trade_reports(GetOpenTradeReportsRequest(
    account_id=9,
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetOpenTradeReports",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 9
  }"
}
```

{% endtab %}
{% endtabs %}

| Key       | Value                                                                                       |
| --------- | ------------------------------------------------------------------------------------------- |
| OMSId     | **integer**. The ID of the OMS. **required**.                                               |
| AccountId | **integer**. The ID of the account whose open blocktrade/s will be retrieved. **required**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetOpenTradeReports",
  "o": "[
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6723,
      \"Price\": 29500,
      \"Quantity\": 0.2563,
      \"DisplayQuantity\": 0.2563,
      \"Instrument\": 1,
      \"Account\": 9,
      \"AccountName\": \"AnotherName\",
      \"OrderType\": \"BlockTrade\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"Working\",
      \"ReceiveTime\": 1683190853154,
      \"ReceiveTimeTicks\": 638187876531538042,
      \"LastUpdatedTime\": 1683190853159,
      \"LastUpdatedTimeTicks\": 638187876531592832,
      \"OrigQuantity\": 0.2563,
      \"QuantityExecuted\": 0,
      \"GrossValueExecuted\": 0,
      \"ExecutableValue\": 0,
      \"AvgPrice\": 0,
      \"CounterPartyId\": 7,
      \"ChangeReason\": \"NewInputAccepted\",
      \"OrigOrderId\": 6723,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 1,
      \"UserName\": \"admin\",
      \"IsQuote\": false,
      \"InsideAsk\": 31000,
      \"InsideAskSize\": 0.5,
      \"InsideBid\": 30000,
      \"InsideBidSize\": 0.5,
      \"LastTradePrice\": 30500,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0,
      \"PegPriceType\": \"Last\",
      \"PegOffset\": 0,
      \"PegLimitOffset\": 0,
      \"IpAddress\": null,
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    }
  ]"
}
```

| Key                | Value                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Side               | <p><strong>string</strong>. The side of a trade. One of:<br>- 0 Buy<br>- 1 Sell.</p>                                                                                                                                                                                                                                                                                                             |
| OrderId            | **long integer**. The ID of the open order. The *OrderID* is unique in each OMS.                                                                                                                                                                                                                                                                                                                 |
| Price              | **decimal**. The price at which the buy or sell has been ordered.                                                                                                                                                                                                                                                                                                                                |
| Quantity           | **decimal**. The quantity of the product to be bought or sold.                                                                                                                                                                                                                                                                                                                                   |
| DisplayQuantity    | **decimal**. The quantity available to buy or sell that is publicly displayed to the market. To display a *displayQuantity* value, an order must be a Limit order with a reserve.                                                                                                                                                                                                                |
| Instrument         | **integer**. The ID of the instrument being traded. The call **GetInstruments** can supply the instrument IDs that are available.                                                                                                                                                                                                                                                                |
| Account            | **integer**. The ID of the of the account which submitted the order.                                                                                                                                                                                                                                                                                                                             |
| AccountName        | **string**. Name of the of the account which submitted the order.                                                                                                                                                                                                                                                                                                                                |
| OrderType          | **string**. Will always be **BlockTrade** as this GetOpenTradeReports API will only return open blocktrades.                                                                                                                                                                                                                                                                                     |
| ClientOrderId      | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                                                                                                                                                                                               |
| OrderState         | <p><strong>string</strong>. The current state of the order. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 FullyExecuted.</p>                                                                                                                                                                                                                       |
| ReceiveTime        | **long integer**. Time stamp of the order in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                 |
| ReceiveTimeTicks   | **long integer**. Time stamp of the order Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                     |
| OrigQuantity       | **decimal**. If the open order has been changed or partially filled, this value shows the original quantity of the order.                                                                                                                                                                                                                                                                        |
| QuantityExecuted   | **decimal**. If the open order has been at least partially executed, this value shows the amount that has been executed.                                                                                                                                                                                                                                                                         |
| GrossValueExecuted | **decimal**. If the open order has been at least partially executed, this value shows the gross amount that has been executed.                                                                                                                                                                                                                                                                   |
| AvgPrice           | **decimal**. The average executed price of the order.                                                                                                                                                                                                                                                                                                                                            |
| CounterPartyId     | **integer**. The ID of the account who will be the counter party of the blocktrade.                                                                                                                                                                                                                                                                                                              |
| ChangeReason       | <p><strong>string</strong>. If the order has been changed, this string value holds the reason. One of:<br>- 0 Unknown<br>- 1 NewInputAccepted<br>- 2 NewInputRejected<br>- 3 OtherRejected<br>- 4 Expired<br>- 5 Trade<br>- 6 SystemCanceled\_NoMoreMarket<br>- 7 SystemCanceled\_BelowMinimum<br>- 8 SystemCanceled\_PriceCollar<br>- 9 SystemCanceled\_MarginFailed<br>- 100 UserModified.</p> |
| OrigOrderId        | **integer**. If the order has been changed, this is the ID of the original order.                                                                                                                                                                                                                                                                                                                |
| OrigClOrdId        | **integer**. If the order has been changed, this is the ID of the original client order ID.                                                                                                                                                                                                                                                                                                      |
| EnteredBy          | **integer**. The ID of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                         |
| Username           | **integer**. The username of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                   |
| IsQuote            | **boolean**. If this order is a quote (created using **CreateDirectQuote** API method or the **CreateInverseQuote** API method), the value for *IsQuote* is *true*, else *false.*                                                                                                                                                                                                                |
| InsideAsk          | **decimal**. If this order is a quote, this value is the Inside Ask price.                                                                                                                                                                                                                                                                                                                       |
| InsideAskSize      | **decimal**. If this order is a quote, this value is the quantity of the Inside Ask quote.                                                                                                                                                                                                                                                                                                       |
| InsideBid          | **decimal**. If this order is a quote, this value is the Inside Bid price.                                                                                                                                                                                                                                                                                                                       |
| InsideBidSize      | **decimal**. If this order is a quote, this value is the quantity of the Inside Bid quote.                                                                                                                                                                                                                                                                                                       |
| LastTradePrice     | **decimal**. The last price that this instrument traded at.                                                                                                                                                                                                                                                                                                                                      |
| RejectReason       | **string**. If this open order has been rejected, this string holds the reason for the rejection.                                                                                                                                                                                                                                                                                                |
| IsLockedIn         | **boolean**. For a block trade, if both parties to the block trade agree that one of the parties will report the trade for both sides, this value is *true.* Othersise, *false.*                                                                                                                                                                                                                 |
| CancelReason       | **string**. If this order has been canceled, this string holds the cancellation reason.                                                                                                                                                                                                                                                                                                          |
| UseMargin          | **boolean**. Margin is not yet supported so this always defaults to false.                                                                                                                                                                                                                                                                                                                       |
| StopPrice          | **decimal**. The price at which the order executes, if the order is a stop order. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                        |
| PegPriceType       | **string**. Not applicable for an order resulting from **SubmitBlockTrade**                                                                                                                                                                                                                                                                                                                      |
| PegOffset          | **decimal**. Not applicable for an order resulting from **SubmitBlockTrade**                                                                                                                                                                                                                                                                                                                     |
| PegLimitOffset     | **decimal**. Not applicable for an order resulting from **SubmitBlockTrade**                                                                                                                                                                                                                                                                                                                     |
| IpAddress          | **string**. The IP address from where the order was submitted.                                                                                                                                                                                                                                                                                                                                   |
| OMSId              | **integer**. The ID of the OMS.                                                                                                                                                                                                                                                                                                                                                                  |

### GetOrders

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Gets the list of the latest states of orders for an account. ReceiveTime is in POSIX format X 1000 (milliseconds since 1 January 1970).

Results can also be filtered according to different search parameters such as OrderState, InstrumentId, OrderId etc. This API method functions just like **GetOrdersHistory**

A user with NotbankTrading permission can only retrieve orders for accounts with which he/she is associated to.

**Note:** In this method, "Depth" refers to the count of trades to report, not the depth of the order book.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOrders({
  "AccountId": 7
});


// request payload
{
  AccountId: number;
  OrderState?: string;
  OrderId?: number;
  ClientOrderId?: number;
  OriginalOrderId?: number;
  OriginalClientOrderId?: number;
  UserId?: number;
  InstrumentId?: number;
  StartTimestamp?: number;
  EndTimestamp?: number;
  Depth?: number;
  Limit?: number;
  StartIndex?: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOrdersParamBuilder;

var response = client.getTradingService().getOrders(new GetOrdersParamBuilder(7)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetOrdersRequest

response = client.get_orders(GetOrdersRequest(
    account_id=7,
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetOrders",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 7
  }"
}
```

{% endtab %}
{% endtabs %}

| Key                   | Value                                                                                                                                                                                                                                                                                                                                                                                             |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId                 | **integer**. The ID of the OMS on which the orders took place. **required**.                                                                                                                                                                                                                                                                                                                      |
| AccountId             | **integer**. The account ID that made the trades. A user with NotbankTrading permission must be associated with this account, although other users also can be associated with the account. **required**.                                                                                                                                                                                         |
| OrderState            | <p><strong>string</strong>. The current state of the order. Can be used to filter results. If not specified all orders regardless of the order state will be returned. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 FullyExecuted<br><strong>optional</strong>.</p>                                                                                |
| OrderId               | **long integer**. The ID for the order. Can be used to filter results. Can be used to filter for a specific orderId. There is a specific API call **GetOrderHistoryByOrderId** for filtering orders by **OrderId**. **optional**.                                                                                                                                                                 |
| ClientOrderId         | **long integer**. A user-assigned ID for the order (like a purchase-order number assigned by a company). Can be used to filter results. Default is 0. **optional**.                                                                                                                                                                                                                               |
| OriginalOrderId       | **long integer**. The original ID of the order. If specified, the call returns changed orders associated with this order ID. Can be used to filter results. **optional**.                                                                                                                                                                                                                         |
| OriginalClientOrderId | **long integer**. If the order has been changed, shows the original client order ID, a value that the client can create (much like a purchase order). Can be used to filter results. **optional**.                                                                                                                                                                                                |
| UserId                | **integer**. The ID of the user whose account orders will be returned. If not specified, the call returns the orders of the logged-in user. Can be used to filter results. **optional**.                                                                                                                                                                                                          |
| InstrumentId          | **long integer**. The ID of the instrument named in the order. If not specified, the call returns orders for all instruments traded by this account. Can be used to filter results. **optional**.                                                                                                                                                                                                 |
| StartTimestamp        | **long integer**. Date and time at which to begin the orders history, in POSIX format. Can be used to filter results. **optional**.                                                                                                                                                                                                                                                               |
| EndTimestamp          | **long integer**. Date and time at which to end the orders report, in POSIX format. Can be used to filter results. **optional**.                                                                                                                                                                                                                                                                  |
| Depth                 | **integer**. In this case, the maximum number/count of orders to return, counting from the *StartIndex* if it is also specified. If not specified, returns all orders from the most recent to oldest; results can vary depending if other optional fields are defined such as *StartIndex*, *StartTimestamp*, and *EndTimestamp*. Can be used to filter results and for pagination. **optional**. |
| Limit                 | **integer**. Functions exactly the same as the **Depth** field. **optional**.                                                                                                                                                                                                                                                                                                                     |
| StartIndex            | **integer**. A value of 0 means the first object in the result will be the the most recent order, a value of 2 means that the first object in the result set will be the third most recent order. Can be used to filter results or for pagination. Default is 0. **optional**.                                                                                                                    |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetOrders",
  "o": "[
    {
      \"Side\": \"Sell\",
      \"OrderId\": 6713,
      \"Price\": 0.0,
      \"Quantity\": 0.0,
      \"DisplayQuantity\": 0.0,
      \"Instrument\": 11,
      \"Account\": 7,
      \"AccountName\": \"sample\",
      \"OrderType\": \"Market\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"FullyExecuted\",
      \"ReceiveTime\": 1682663431785,
      \"ReceiveTimeTicks\": 638182602317851821,
      \"LastUpdatedTime\": 1682663431791,
      \"LastUpdatedTimeTicks\": 638182602317910891,
      \"OrigQuantity\": 0.01,
      \"QuantityExecuted\": 0.01,
      \"GrossValueExecuted\": 60.0,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 6000.0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6713,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"LastTradePrice\": 6000.0,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Bid\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Sell\",
      \"OrderId\": 6709,
      \"Price\": 0.0,
      \"Quantity\": 0.0,
      \"DisplayQuantity\": 0.0,
      \"Instrument\": 11,
      \"Account\": 7,
      \"AccountName\": \"sample\",
      \"OrderType\": \"Market\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"FullyExecuted\",
      \"ReceiveTime\": 1682663089848,
      \"ReceiveTimeTicks\": 638182598898484597,
      \"LastUpdatedTime\": 1682663089923,
      \"LastUpdatedTimeTicks\": 638182598899230197,
      \"OrigQuantity\": 0.01,
      \"QuantityExecuted\": 0.01,
      \"GrossValueExecuted\": 60.0,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 6000.0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6709,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"LastTradePrice\": 0.0,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Bid\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    }
  ]"
}
```

Returns an array of objects, each object represents an order. The call returns an empty array if there are no orders for the account.

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Side                 | <p><strong>string</strong>. The side of a trade. One of:<br>- <strong>0</strong> Buy<br>- <strong>1</strong> Sell.</p>                                                                                                                                                                                                                                                                                                                                                                                |
| OrderId              | **long integer**. The ID of the open order. The *OrderID* is unique in each OMS.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Price                | **decimal**. The price at which the buy or sell has been ordered.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Quantity             | **decimal**. The quantity of the product to be bought or sold.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| DisplayQuantity      | **decimal**. The quantity available to buy or sell that is publicly displayed to the market. To display a *displayQuantity* value, an order must be a Limit order with a reserve.                                                                                                                                                                                                                                                                                                                     |
| Instrument           | **integer**. The ID of the instrument being traded. The API method **GetInstruments** can supply the instrument IDs that are available.                                                                                                                                                                                                                                                                                                                                                               |
| Account              | **integer**. The ID of the of the account which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| AccountName          | **string**. Name of the of the account which which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| OrderType            | <p><strong>string</strong>. Describes the type of order this is. One of:<br>- 0 Unknown (an error condition)<br>- 1 Market<br>- 2 Limit<br>- 3 StopMarket<br>- 4 StopLimit<br>- 5 TrailingStopMarket<br>- 6 TrailingStopLimit<br>- 7 BlockTrade.</p>                                                                                                                                                                                                                                                  |
| ClientOrderId        | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                                                                                                                                                                                                                                                                                                    |
| OrderState           | <p><strong>string</strong>. The current or the latest state of the order. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 Fully Executed.</p>                                                                                                                                                                                                                                                                                                             |
| ReceiveTime          | **long integer**. Time stamp of the order in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                                      |
| ReceiveTimeTicks     | **long integer**. Time stamp of the order Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                                          |
| LastUpdatedTime      | **long integer**. Time stamp when the order was last updated, in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                  |
| LastUpdatedTimeTicks | **long integer**. Time stamp when the order was last updated, in Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                   |
| OrigQuantity         | **decimal**. If the open order has been changed or partially filled, this value shows the original quantity of the order.                                                                                                                                                                                                                                                                                                                                                                             |
| QuantityExecuted     | **decimal**. If the open order has been at least partially executed, this value shows the amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                              |
| GrossValueExecuted   | **decimal**. If the open order has been at least partially executed, this value shows the gross amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                        |
| ExecutableValue      | **decimal**. Defaults to 0. For future provision                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| AvgPrice             | **decimal**. The average executed price of the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| CounterPartyId       | **integer**. The ID of the account who is the counterparty for the trade if order is already executed, either partial or fully executed.                                                                                                                                                                                                                                                                                                                                                              |
| ChangeReason         | <p><strong>string</strong>. If the order has been changed, this string value holds the reason. One of:<br>- 0 Unknown<br>- 1 NewInputAccepted<br>- 2 NewInputRejected<br>- 3 OtherRejected<br>- 4 Expired<br>- 5 Trade<br>- 6 SystemCanceled\_NoMoreMarket<br>- 7 SystemCanceled\_BelowMinimum<br>- 8 SystemCanceled\_PriceCollar<br>- 9 SystemCanceled\_MarginFailed<br>- 100 UserModified<br>An order that is newly added to book will have <strong>NewInputAccepted</strong> value by default.</p> |
| OrigOrderId          | **long integer**. If the order is a replacement order, this is the ID of the original order.                                                                                                                                                                                                                                                                                                                                                                                                          |
| OrigClOrdId          | **long integer**. If the order is a replacement order, this is the client order ID or the original order.                                                                                                                                                                                                                                                                                                                                                                                             |
| EnteredBy            | **integer**. The ID of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Username             | **string**. The username of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| IsQuote              | **boolean**. If this order is a quote, the value for *IsQuote* is *true*, otherwise it is *false.*                                                                                                                                                                                                                                                                                                                                                                                                    |
| InsideAsk            | **decimal**. If this order is a quote, this value is the Inside Ask price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideAskSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Ask quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBid            | **decimal**. If this order is a quote, this value is the Inside Bid price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBidSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Bid quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| LastTradePrice       | **decimal**. The last price that this instrument traded at.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| RejectReason         | **string**. If this open order has been rejected, this string holds the reason for the rejection.                                                                                                                                                                                                                                                                                                                                                                                                     |
| IsLockedIn           | **boolean**. For a block trade, if both parties to the block trade agree that one of the parties will report the trade for both sides, this value is *true.* Othersise, *false.*                                                                                                                                                                                                                                                                                                                      |
| CancelReason         | **string**. If this order has been canceled, this string holds the cancellation reason.                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderFlag            | <p><strong>integer or string</strong>. One or more of:<br>1 NoAccountRiskCheck<br>2 AddedToBook<br>4 RemovedFromBook<br>8 PostOnly<br>16 Liquidation<br>32 ReverseMarginPosition.</p>                                                                                                                                                                                                                                                                                                                 |
| UseMargin            | **boolean**. Margin is not yet supported so this always defaults to false.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| StopPrice            | **decimal**. The price at which the order executes, if the order is a stop order. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                             |
| PegPriceType         | **string**. The type of price to peg the Stop to for Stop/Trailing orders.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PegOffset            | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| PegLimitOffset       | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| IpAddress            | **string**. The IP address from where the order was submitted.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| OMSId                | **integer**. The ID of the OMS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

### GetOrderHistory

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Gets a list of orders, being the history of orders for the specified search parameters.

For example, if *depth* = 200 and *startIndex* = 0, the history returns 200 unique orders into the past starting with the most recent (0) order. If *depth* = 200 and *startIndex* = 100, the history returns 200 unique orders into the past starting at 101st order in the past.

The owner of the trading venue determines how long to retain order history before archiving.

A user with NotbankTrading permission can only retrieve orders history for accounts with which he/she is associated to.

**Note:** In this method, "Depth" refers to the maximum number/count of orders that can be retrieved.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOrderHistory({
  "AccountId": 7
});


// request payload
{
  AccountId: number;
  OrderState?: OrderState;
  OrderId?: number;
  ClientOrderId?: number;
  OriginalOrderId?: number;
  OriginalClientOrderId?: number;
  UserId?: number;
  InstrumentId?: number;
  StartTimestamp?: number;
  EndTimestamp?: number;
  Depth?: number;
  Limit?: number;
  StartIndex?: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOrderHistoryParamBuilder;

var response = client.getTradingService()
        .getOrderHistory(new GetOrderHistoryParamBuilder(7)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetOrderHistoryRequest

response = client.get_order_history(GetOrderHistoryRequest(
    account_id=7,
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetOrderHistory",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 7
  }"
}
```

{% endtab %}
{% endtabs %}

| Key                   | Value                                                                                                                                                                                                                                                                                                                                                                          |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| OMSId                 | **integer**. The ID of the OMS on which the orders took place. **required**.                                                                                                                                                                                                                                                                                                   |
| AccountId             | **integer**. The account ID that made the trades. A user with NotbankTrading permission must be associated with this account, although other users also can be associated with the account. **required**.                                                                                                                                                                      |
| OrderState            | <p><strong>string</strong>. The current state of the order. Can be used to filter results. If not specified all orders regardless of the order state will be returned. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 FullyExecuted<br><strong>optional</strong>.</p>                                                             |
| OrderId               | **long integer**. The ID for the order. Can be used to filter results. Can be used to filter for a specific orderId. There is a specific API call **GetOrderHistoryByOrderId** for filtering orders by **OrderId**. **optional**.                                                                                                                                              |
| ClientOrderId         | **long integer**. A user-assigned ID for the order (like a purchase-order number assigned by a company). Can be used to filter results. Default is 0. **optional**.                                                                                                                                                                                                            |
| OriginalOrderId       | **long integer**. The original ID of the order. If specified, the call returns changed orders associated with this order ID. Can be used to filter results. **optional**.                                                                                                                                                                                                      |
| OriginalClientOrderId | **long integer**. If the order has been changed, shows the original client order ID, a value that the client can create (much like a purchase order). Can be used to filter results. **optional**.                                                                                                                                                                             |
| UserId                | **integer**. The ID of the user whose account orders will be returned. If not specified, the call returns the orders of the logged-in user. Can be used to filter results. **optional**.                                                                                                                                                                                       |
| InstrumentId          | **long integer**. The ID of the instrument named in the order. If not specified, the call returns orders for all instruments traded by this account. Can be used to filter results. **optional**.                                                                                                                                                                              |
| StartTimestamp        | **long integer**. Date and time at which to begin the orders history, in POSIX format. Can be used to filter results. **optional**.                                                                                                                                                                                                                                            |
| EndTimestamp          | **long integer**. Date and time at which to end the orders report, in POSIX format. Can be used to filter results. **optional**.                                                                                                                                                                                                                                               |
| Depth                 | **integer**. In this case, the maximum number/count of orders to return, counting from the *StartIndex* if it is also specified. If not specified, returns 100 most recent orders; results can vary depending if other optional fields are defined such as *StartIndex*, *StartTimestamp*, and *EndTimestamp*. Can be used to filter results and for pagination. **optional**. |
| Limit                 | **integer**. Functions exactly the same as the **Depth** field. **optional**.                                                                                                                                                                                                                                                                                                  |
| StartIndex            | **integer**. A value of 0 means the first object in the result will be the the most recent order, a value of 2 means that the first object in the result set will be the third most recent order. Can be used to filter results or for pagination. Default is 0. **optional**.                                                                                                 |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetOrderHistory",
  "o": "[
    {
      \"Side\": \"Sell\",
      \"OrderId\": 6713,
      \"Price\": 0.0,
      \"Quantity\": 0.0,
      \"DisplayQuantity\": 0.0,
      \"Instrument\": 11,
      \"Account\": 7,
      \"AccountName\": \"sample\",
      \"OrderType\": \"Market\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"FullyExecuted\",
      \"ReceiveTime\": 1682663431785,
      \"ReceiveTimeTicks\": 638182602317851821,
      \"LastUpdatedTime\": 1682663431791,
      \"LastUpdatedTimeTicks\": 638182602317910891,
      \"OrigQuantity\": 0.01,
      \"QuantityExecuted\": 0.01,
      \"GrossValueExecuted\": 60.0,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 6000.0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6713,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"LastTradePrice\": 6000.0,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Bid\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Sell\",
      \"OrderId\": 6709,
      \"Price\": 0.0,
      \"Quantity\": 0.0,
      \"DisplayQuantity\": 0.0,
      \"Instrument\": 11,
      \"Account\": 7,
      \"AccountName\": \"sample\",
      \"OrderType\": \"Market\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"FullyExecuted\",
      \"ReceiveTime\": 1682663089848,
      \"ReceiveTimeTicks\": 638182598898484597,
      \"LastUpdatedTime\": 1682663089923,
      \"LastUpdatedTimeTicks\": 638182598899230197,
      \"OrigQuantity\": 0.01,
      \"QuantityExecuted\": 0.01,
      \"GrossValueExecuted\": 60.0,
      \"ExecutableValue\": 0.0,
      \"AvgPrice\": 6000.0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"Trade\",
      \"OrigOrderId\": 6709,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"InsideBid\": 6000.0,
      \"InsideBidSize\": 0.01,
      \"LastTradePrice\": 0.0,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 0.0,
      \"PegPriceType\": \"Bid\",
      \"PegOffset\": 0.0,
      \"PegLimitOffset\": 0.0,
      \"IpAddress\": \"69.10.61.175\",
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    }
  ]"
}
```

The call **GetOrderHistory** returns an array or objects, each object representin an order at its latest status; an order will only occupy 1 index or just 1 instance in the result. The API method **GetOrderHistory** does not return the full history of a specific order, there is another API that will give you just that: **GetOrderHistoryByOrderId**.

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Side                 | <p><strong>string</strong>. The side of a trade. One of:<br>- 0 Buy<br>- 1 Sell.</p>                                                                                                                                                                                                                                                                                                                                                                                                                  |
| OrderId              | **long integer**. The ID of the open order. The *OrderID* is unique in each OMS.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Price                | **decimal**. The price at which the buy or sell has been ordered.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Quantity             | **decimal**. The quantity of the product to be bought or sold.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| DisplayQuantity      | **decimal**. The quantity available to buy or sell that is publicly displayed to the market. To display a *displayQuantity* value, an order must be a Limit order with a reserve.                                                                                                                                                                                                                                                                                                                     |
| Instrument           | **integer**. The ID of the instrument being traded. The call **GetInstruments** can supply the instrument IDs that are available.                                                                                                                                                                                                                                                                                                                                                                     |
| Account              | **integer**. The ID of the of the account which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| AccountName          | **string**. Name of the of the account which which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| OrderType            | <p><strong>string</strong>. Describes the type of order this is. One of:<br>- 0 Unknown (an error condition)<br>- 1 Market order<br>- 2 Limit<br>- 3 StopMarket<br>- 4 StopLimit<br>- 5 TrailingStopMarket<br>- 6 TrailingStopLimit<br>- 7 BlockTrade.</p>                                                                                                                                                                                                                                            |
| ClientOrderId        | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                                                                                                                                                                                                                                                                                                    |
| OrderState           | <p><strong>string</strong>. The current or the latest state of the order. One of:<br>- 0 Unknown<br>- 1 Working<br>- 2 Rejected<br>- 3 Canceled<br>- 4 Expired<br>- 5 Fully Executed.</p>                                                                                                                                                                                                                                                                                                             |
| ReceiveTime          | **long integer**. Time stamp of the order in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                                      |
| ReceiveTimeTicks     | **long integer**. Time stamp of the order Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                                          |
| LastUpdatedTime      | **long integer**. Time stamp when the order was last updated, in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                  |
| LastUpdatedTimeTicks | **long integer**. Time stamp when the order was last updated, in Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                   |
| OrigQuantity         | **decimal**. If the open order has been changed or partially filled, this value shows the original quantity of the order.                                                                                                                                                                                                                                                                                                                                                                             |
| QuantityExecuted     | **decimal**. If the open order has been at least partially executed, this value shows the amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                              |
| GrossValueExecuted   | **decimal**. If the open order has been at least partially executed, this value shows the gross amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                        |
| ExecutableValue      | **decimal**. Defaults to 0. For future provision                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| AvgPrice             | **decimal**. The average executed price of the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| CounterPartyId       | **integer**. The ID of the account who is the counterparty for the trade if order is already executed, either partial or fully executed.                                                                                                                                                                                                                                                                                                                                                              |
| ChangeReason         | <p><strong>string</strong>. If the order has been changed, this string value holds the reason. One of:<br>- 0 Unknown<br>- 1 NewInputAccepted<br>- 2 NewInputRejected<br>- 3 OtherRejected<br>- 4 Expired<br>- 5 Trade<br>- 6 SystemCanceled\_NoMoreMarket<br>- 7 SystemCanceled\_BelowMinimum<br>- 8 SystemCanceled\_PriceCollar<br>- 9 SystemCanceled\_MarginFailed<br>- 100 UserModified<br>An order that is newly added to book will have <strong>NewInputAccepted</strong> value by default.</p> |
| OrigOrderId          | **long integer**. If the order is a replacement order, this is the ID of the original order.                                                                                                                                                                                                                                                                                                                                                                                                          |
| OrigClOrdId          | **long integer**. If the order is a replacement order, this is the client order ID or the original order.                                                                                                                                                                                                                                                                                                                                                                                             |
| EnteredBy            | **integer**. The ID of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Username             | **string**. The username of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| IsQuote              | **boolean**. If this order is a quote, the value for *IsQuote* is *true*, otherwise it is *false.*                                                                                                                                                                                                                                                                                                                                                                                                    |
| InsideAsk            | **decimal**. If this order is a quote, this value is the Inside Ask price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideAskSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Ask quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBid            | **decimal**. If this order is a quote, this value is the Inside Bid price.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InsideBidSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Bid quote.                                                                                                                                                                                                                                                                                                                                                                                                            |
| LastTradePrice       | **decimal**. The last price that this instrument traded at.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| RejectReason         | **string**. If this open order has been rejected, this string holds the reason for the rejection.                                                                                                                                                                                                                                                                                                                                                                                                     |
| IsLockedIn           | **boolean**. For a block trade, if both parties to the block trade agree that one of the parties will report the trade for both sides, this value is *true.* Othersise, *false.*                                                                                                                                                                                                                                                                                                                      |
| CancelReason         | **string**. If this order has been canceled, this string holds the cancellation reason.                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderFlag            | <p><strong>integer or string</strong>. One or more of:<br>1 NoAccountRiskCheck<br>2 AddedToBook<br>4 RemovedFromBook<br>8 PostOnly<br>16 Liquidation<br>32 ReverseMarginPosition.</p>                                                                                                                                                                                                                                                                                                                 |
| UseMargin            | **boolean**. Margin is not yet supported so this always defaults to false.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| StopPrice            | **decimal**. The price at which the order executes, if the order is a stop order. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                             |
| PegPriceType         | **string**. The type of price to peg the Stop to for Stop/Trailing orders.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PegOffset            | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| PegLimitOffset       | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                         |
| IpAddress            | **string**. The IP address from where the order was submitted.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                               |
| OMSId                | **integer**. The ID of the OMS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

### SendOrder

**Permissions:** NotbankTrading\
**Call Type:** Asynchronous

Creates an order.

Anyone submitting an order should also subscribe to the various market data and event feeds, or call **GetOpenOrders** or **GetOrderStatus** to monitor the status of the order. If the order is not in a state to be executed, **GetOpenOrders** will not return it.

A user with NotbankTrading permission can only create an order for accounts with which he/she is associated to.

**Note:** Call Type is asynchronous.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

//Limit order
await client.getTradingService().sendOrder({
  "InstrumentId": 9,
  "AccountId": 9,
  "TimeInForce": 1,
  "ClientOrderId": 0,
  "OrderIdOCO": 0,
  "UseDisplayQuantity": false,
  "Side": 0,
  "Quantity": 1,
  "OrderType": 2,
  "PegPriceType": 3,
  "LimitPrice": 31000,
});

//Market order
await client.getTradingService().sendOrder({
  "InstrumentId": 9,
  "AccountId": 9,
  "TimeInForce": 1,
  "ClientOrderId": 0,
  "OrderIdOCO": 0,
  "UseDisplayQuantity": false,
  "Side": 0,
  "OrderType": 1,
  "PegPriceType": 3,
  "Quantity": 0.5,
});

//Order by value: In a market order, a user can opt to input total value of the trade instead of putting the quantity which will then be automatically calculated: value/marketprice.
await client.getTradingService().sendOrder({
  "InstrumentId": 9,
  "AccountId": 9,
  "TimeInForce": 1,
  "ClientOrderId": 0,
  "OrderIdOCO": 0,
  "UseDisplayQuantity": false,
  "Side": 0,
  "OrderType": 1,
  "PegPriceType": 3,
  "Value": 10,
});

// request payload
{
  InstrumentId: number;
  AccountId: number;
  TimeInForce: TimeInForce;
  ClientOrderId?: number;
  OrderIdOCO?: number;
  UseDisplayQuantity?: boolean;
  Side: OrderSide;
  Quantity?: number;
  OrderType: OrderTypeInt;
  PegPriceType?: PegPriceType;
  LimitPrice?: number;
  StopPrice?: number;
  TrailingAmount?: number;
  LimitOffset?: number;
  DisplayQuantity?: number;
  Value?: number;
  PostOnly?: boolean;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.math.BigDecimal;
import exchange.notbank.trading.constants.OrderSide;
import exchange.notbank.trading.constants.OrderType;
import exchange.notbank.trading.constants.PegPriceType;
import exchange.notbank.trading.constants.TimeInForce;
import exchange.notbank.trading.paramBuilders.SendOrderParamBuilder;

var anInstrument = client.getInstrumentService().getInstrument("BTCUSDT").get();
//Limit order
var response = client.getTradingService().sendOrder(new SendOrderParamBuilder(
    anInstrument,
    1,
    TimeInForce.GTC,
    OrderSide.BUY,
    OrderType.LIMIT)
    .quantity(new BigDecimal("1"))
    .clientOrderId(123L)
    .orderIdOCO(123L)
    .useDisplayQuantity(false)
    .pegPriceType(PegPriceType.ASK)
    .limitPrice(new BigDecimal("31000"))).get();

//Market order
var response = client.getTradingService().sendOrder(new SendOrderParamBuilder(
    anInstrument,
    1,
    TimeInForce.FOK,
    OrderSide.BUY,
    OrderType.MARKET)
    .quantity(new BigDecimal("0.5"))
    .clientOrderId(123L)
    .orderIdOCO(123L)
    .useDisplayQuantity(false)
    .pegPriceType(PegPriceType.ASK)).get();

//Order by value: In a market order, a user can opt to input total value of the trade instead of putting the quantity which will then be automatically calculated: value/marketprice.
var response = client.getTradingService().sendOrder(new SendOrderParamBuilder(
    anInstrument,
    1,
    TimeInForce.FOK,
    OrderSide.BUY,
    OrderType.MARKET)
    .clientOrderId(123L)
    .orderIdOCO(123L)
    .useDisplayQuantity(false)
    .pegPriceType(PegPriceType.ASK)
    .value(new BigDecimal(10))).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.constants import PegPriceType, OrderType, Side, TimeInForce
from notbank_python_sdk.requests_models import SendOrderRequest

instrument = client.get_instrument_by_symbol("BTCUSDT")

# Limit order
response = client.send_order(SendOrderRequest(
    instrument=instrument,
    account_id=7,
    time_in_force=TimeInForce.GTD,
    side=Side.SELL,
    quantity=Decimal("1"),
    limit_price=Decimal("31000"),
    order_type=OrderType.LIMIT,
    peg_price_type=PegPriceType.ASK,
    use_display_quantity=False,
    client_order_id=123,
    order_id_oco=123,            
))

# Market order
response = client.send_order(SendOrderRequest(
    instrument=instrument,
    account_id=7,
    time_in_force=TimeInForce.FOK,
    side=Side.SELL,
    quantity=Decimal("0.5"),
    order_type=OrderType.MARKET,
    peg_price_type=PegPriceType.ASK,
    use_display_quantity=False,
    client_order_id=123,
    order_id_oco=123,            
))

# Order by value: In a market order, a user can opt to input total value of the trade instead of putting the quantity which will then be automatically calculated: value/marketprice.
response = client.send_order(SendOrderRequest(
    instrument=instrument,
    account_id=7,
    time_in_force=TimeInForce.FOK,
    side=Side.SELL,
    quantity=Decimal("0.5"),
    order_type=OrderType.MARKET,
    peg_price_type=PegPriceType.ASK,
    use_display_quantity=False,
    client_order_id=123,
    order_id_oco=123,
    value=Decimal("10"),
))
```

{% endtab %}

{% tab title="Json" %}

```json
//Limit order
{
  "m": 0,
  "i": 0,
  "n": "SendOrder",
  "o": "{
    \"InstrumentId\": 9,
    \"OMSId\": 1,
    \"AccountId\": 9,
    \"TimeInForce\": 1,
    \"ClientOrderId\": 0,
    \"OrderIdOCO\": 0,
    \"UseDisplayQuantity\": false,
    \"Side\": 0,
    \"Quantity\": 1,
    \"OrderType\": 2,
    \"PegPriceType\": 3,
    \"LimitPrice\": 31000,
  }"
}


//Market order
{
  "m": 0,
  "i": 0,
  "n": "SendOrder",
  "o": "{
    \"InstrumentId\": 9,
    \"OMSId\": 1,
    \"AccountId\": 9,
    \"TimeInForce\": 1,
    \"ClientOrderId\": 0,
    \"OrderIdOCO\": 0,
    \"UseDisplayQuantity\": false,
    \"Side\": 0,
    \"OrderType\": 1,
    \"PegPriceType\": 3,
    \"Quantity\": 0.5,
  }"
}


//Order by value: In a market order, a user can opt to input total value of the trade instead of putting the quantity which will then be automatically calculated: value/marketprice.
{
  "m": 0,
  "i": 0,
  "n": "SendOrder",
  "o": "{
    \"InstrumentId\": 9,
    \"OMSId\": 1,
    \"AccountId\": 9,
    \"TimeInForce\": 1,
    \"ClientOrderId\": 0,
    \"OrderIdOCO\": 0,
    \"UseDisplayQuantity\": false,
    \"Side\": 0,
    \"OrderType\": 1,
    \"PegPriceType\": 3,
    \"Value\": 10,
  }"
}
```

{% endtab %}
{% endtabs %}

If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified

| Key                | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| InstrumentId       | **integer**. The ID of the instrument being traded. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| OMSId              | **integer**. The ID of the OMS on which the instrument is being traded. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| AccountId          | **integer**. The ID of the account the order will be placed for. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| TimeInForce        | <p><strong>integer</strong>. An integer that represents the period during which the new order is executable. One of:<br>- <strong>0</strong> Unknown (an error condition)<br>- <strong>1</strong> GTC (good 'til canceled, the default)<br>- <strong>2</strong> OPG (execute as close to opening price as possible: not yet used, for future provision)<br>- <strong>3</strong> IOC (immediate or canceled)<br>- <strong>4</strong> FOK (fill-or-kill — fill immediately or kill immediately)<br>- <strong>5</strong> GTX (good 'til executed: not yet used, for future provision)<br>- <strong>6</strong> GTD (good 'til date: not yet used, for future provision)<br><strong>required</strong>.</p>                                                                                                                                                       |
| ClientOrderId      | **long integer**. A user-assigned ID for the order (like a purchase-order number assigned by a company). This ID is useful for recognizing future states related to this order. Duplicate client orderid of two open orders of the same account is not allowed, the incoming order with the same ClientOrderId will get rejected. Default is 0. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderIdOCO         | **long integer**. The order ID if One Cancels the Other — If this order is order A, *OrderIdOCO* refers to the order ID of an order B (which is *not* the order being created by this call). If order B executes, then order A created by this call is canceled. You can also set up order B to watch order A in the same way, but that may require an update to order B to make it watch this one, which could have implications for priority in the order book. See **CancelReplaceOrder** and **ModifyOrder**. **optional**.                                                                                                                                                                                                                                                                                                                             |
| UseDisplayQuantity | **boolean**. If you enter a Limit order with a reserve (reserve order), you must set *UseDisplayQuantity* to *true* else, the quantity of your order will be 0, defaults to **false**. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Side               | <p><strong>integer</strong>. A number representing the side of a trade. One of:<br>- <strong>0</strong> Buy<br>- <strong>1</strong> Sell<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Quantity           | **decimal**. The quantity of the instrument being ordered. Not required if **OrderType** is Market (1) and as long as **Value** is defined. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| OrderType          | <p><strong>integer</strong>. The type of the order. One of:<br>- <strong>0</strong> Unknown<br>- <strong>1</strong> Market<br>- <strong>2</strong> Limit<br>- <strong>3</strong> StopMarket<br>- <strong>4</strong> StopLimit<br>- <strong>5</strong> TrailingStopMarket<br>- <strong>6</strong> TrailingStopLimit<br>- <strong>7</strong> BlockTrade<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| PegPriceType       | <p><strong>integer or string</strong>. Only applicable to TrailingStop and Stop orders. The type of price that pegs the stop. One of:<br>- 1 Last<br>- 2 Bid<br>- 3 Ask<br>- 4 Midpoint (Currently unsupported; for future provision)<br>Default is 1 Last. <strong>optional</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| LimitPrice         | **decimal**. The price at which the order will be placed. Required if OrderType is **2 Limit** or **4 StopLimit** or **7 TrailingStopLimit**. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| StopPrice          | **decimal**. Applicable to TrailingStop (Limit and Market) and Stop (Limit and Market) orders only; the price at which the order will get activated. Is not required to be defined for TrailingStop order as this price will be determined automatically based on the **TrailingAmount**, **PegPriceType** and most importantly the movement of the price where the order is pegged (**PegPriceType**). Default is 0. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                           |
| TrailingAmount     | **decimal**. Applicable to TrailingStopLimit and TrailingStopMarket orders only; a number that will be either added to (buy side) or subtracted from (sell side) the price where the order is pegged(depends on the **PegPriceType**); the sum or the difference will be the **StopPrice** of the **TrailingStop** order. On the buy side, if the price where the order is pegged increases and never goes down below the value when the order was placed, the resulting StopPrice will be the sum of the price where the order is pegged during submission and the TrailingAmount; however, if the price where the order is pegged decreases, the StopPrice will change, it will be the sum of the whatever is the lowest value the pegged price will have and the TrailingAmount: the logic on the sell side is the opposite. **conditionally required**. |
| LimitOffset        | **decimal**. Applicable to TrailingStopLimit only; a number that will be either added (buy side) or subtracted (sell side) to the **StopPrice**, the sum or the difference will be the LimitPrice of the order when it gets activated. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| DisplayQuantity    | **integer**. If *UseDisplayQuantity* is set to *true*, you must set a value of this field greater than 0, else, order will not appear in the orderbook. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Value              | **decimal** The total value of the trade. Only applicable in a market order type: a user can opt to input a value instead of defining the quantity which will then be automatically calculated: value/marketprice. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PostOlny           | **boolean** If the order is post only. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "SendOrder",
  "o": "{
    \"status\": \"Accepted\",
    \"errormsg\": \"\",
    \"OrderId\": 6500
  }"
}

//Possible error messages
//Order is rejected due to lack of funds
{
  "m": 1,
  "i": 0,
  "n": "SendOrder",
  "o": "{
    \"status\": \"Rejected\",
    \"errormsg\": \"Not_Enough_Funds\",
    \"errorcode\": 101
  }"
}

//Order is rejected due to duplicate Client_OrderId, it means that the order you are sending has the same Client_OrderId with your other working/open order.
{
  "m": 1,
  "i": 0,
  "n": "SendOrder",
  "o": "{
    \"status\": \"Rejected\",
    \"errormsg\": \"Invalid_ClientOrderId\",
    \"errorcode\": 101
  }"
}
```

| Key      | Value                                                                                                                                                |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| status   | <p><strong>string</strong>. If the order is accepted by the system, it returns "Accepted," if not it returns "Rejected."<br>Accepted<br>Rejected</p> |
| errormsg | **string**. Any error message the server returns.                                                                                                    |
| OrderId  | **long integer**. The ID assigned to the order by the server. This allows you to track the order.                                                    |

### CancelReplaceOrder

**Permissions:** NotbankTrading\
**Call Type:** Asynchronous

CancelReplaceOrder is a single API method that both cancels an existing order and replaces it with a new order. Canceling one order and replacing it with another also cancels the order’s priority in the order book. You can use **ModifyOrder** to preserve priority in the book but it only allows a reduction in order quantity.

**Warning:** **CancelReplaceOrder** sacrifices the order's priority in the order book.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

//Limit order to replace OrderId 123456
await client.getTradingService().cancelReplaceOrder({
  "OrderIdToReplace":123456,
  "ClientOrdId":0,
  "OrderType":"Limit",
  "Side":"Buy",
  "AccountId":20,
  "InstrumentId":9,
  "LimitPrice":1.363,
  "TimeInForce":1,
  "Quantity":7322.24
});


OrderTypeInt {
  Unknown = 0,
  Market = 1,
  Limit = 2,
  StopMarket = 3,
  StopLimit = 4,
  TrailingStopMarket = 5,
  TrailingStopLimit = 6,
  BlockTrade = 7
}

OrderSide {
  Buy = 0,
  Sell = 1
}

// Tipo de precio para órdenes Stop y Trailing
PegPriceType {
  Last = 1,
  Bid = 2,
  Ask = 3,
  Midpoint = 4 // No soportado actualmente
}

// Tiempo de ejecución
TimeInForce {
  Unknown = 0,
  GTC = 1, // Good 'til canceled
  OPG = 2, // Execute as close to opening price
  IOC = 3, // Immediate or canceled
  FOK = 4, // Fill or kill
  GTX = 5, // Good 'til executed
  GTD = 6 // Good 'til date
}

// request payload
{
  OrderIdToReplace: number;
  ClientOrderId?: number;
  OrderType: OrderTypeInt;
  Side: OrderSide;
  AccountId: number;
  InstrumentId: number;
  UseDisplayQuantity?: boolean;
  DisplayQuantity?: number;
  LimitPrice?: number;
  StopPrice?: number;
  ReferencePrice?: number;
  PegPriceType?: PegPriceType;
  TimeInForce: TimeInForce;
  OrderIdOCO?: number;
  Quantity: number;
}


```

{% endtab %}

{% tab title="Java" %}

```java
import java.math.BigDecimal;
import exchange.notbank.trading.constants.OrderSide;
import exchange.notbank.trading.constants.OrderType;
import exchange.notbank.trading.constants.PegPriceType;
import exchange.notbank.trading.constants.TimeInForce;
import exchange.notbank.trading.paramBuilders.CancelReplaceOrderParamBuilder;

var anInstrument = client.getInstrumentService().getInstrument("BTCUSDT").get();

//Limit order to replace OrderId 123456
var response = client.getTradingService().cancelReplaceOrder(new CancelReplaceOrderParamBuilder(
    7,
    anInstrument.instrumentId,
    new BigDecimal("7322.24"),
    123456L,
    OrderType.LIMIT,
    OrderSide.BUY,
    TimeInForce.GTC)
    .clientOrderId(123L)
    .limitPrice(new BigDecimal("1.363"))).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from decimal import Decimal
from notbank_python_sdk.constants import OrderType, PegPriceType, Side, TimeInForce

from notbank_python_sdk.requests_models import CancelReplaceOrderRequest

# Limit order to replace OrderId 123456
response = client.cancel_replace_order(CancelReplaceOrderRequest(
    order_id_to_replace=123456,
    client_order_id=0,
    order_type=OrderType.LIMIT,
    side=Side.BUY,
    account_id=20,
    instrument_id=9,
    limit_price=Decimal("1.363"),
    time_in_force=TimeInForce.FOK,
    quantity=Decimal("7322.24"),
))
```

{% endtab %}

{% tab title="Json" %}

```json
//Limit order to replace OrderId 123456
{
  "m": 0,
  "i": 0,
  "n": "CancelReplaceOrder",
  "o": "{
    \"OMSId\":1,
    \"OrderIdToReplace\":123456,
    \"ClientOrdId\":0,
    \"OrderType\":\"Limit\",
    \"Side\":\"Buy\",
    \"AccountId\":20,
    \"InstrumentId\":9,
    \"LimitPrice\":1.363,
    \"TimeInForce\":1,
    \"Quantity\":7322.24
  }"
}


//StopMarket order to replace OrderId 123456
{
  "m": 0,
  "i": 0,
  "n": "CancelReplaceOrder",
  "o": "{
    \"OMSId\":1,
    \"OrderIdToReplace\":123456,
    \"ClientOrdId\":0,
    \"OrderType\":\"StopMarket\",
    \"Side\":\"Buy\",
    \"AccountId\":20,
    \"InstrumentId\":9,
    \"StopPrice\":1.363,
    \"TimeInForce\":1,
    \"Quantity\":7322.24
  }"
}
```

{% endtab %}
{% endtabs %}

| Key                | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId              | **integer**. The ID of the OMS on which the order is being canceled and replaced by another order. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| OrderIdToReplace   | **long integer**. The ID of the order to replace with this order. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ClientOrderId      | **long integer**. A user-assigned ID for the new, replacement order (like a purchase-order number assigned by a company). This ID is useful for recognizing future states related to this order. Default is 0. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                |
| OrderType          | <p><strong>integer or string</strong>. The type of the replacement order. One of:<br>- 0 Unknown<br>- 1 Market<br>- 2 Limit<br>- 3 StopMarket<br>- 4 StopLimit<br>- 5 TrailingStopMarket<br>- 6 TrailingStopLimit<br>- 7 BlockTrade<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                       |
| Side               | <p><strong>integer or string</strong>. The side of the replacement order. One of:<br>- 0 Buy<br>- 1 Sell<br>- 2 Short(reserved for future use)<br>- 3 Unknown (an error condition)<br><strong>required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                        |
| AccountId          | **integer**. The ID of the account under which the original order was placed and the new order will be placed. If AccountId will not match the one on the order to be replaced, request will fail. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| InstrumentId       | **integer**. The ID of the instrument being traded. Must be identical with the instrument ID of the order to be replaced, else, request will fail. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| UseDisplayQuantity | **boolean**. The display quantity is the quantity of a product shown to the market to buy or sell. A larger quantity may be wanted or available, but it may disadvantageous to display it when buying or selling. The display quantity is set when placing an order (using **SendOrder** or **CancelReplaceOrder** for instance). If you enter a Limit order with reserve, you must set *useDisplayQuantity* to *true*. **conditionally required**.                                                                                                                                                                                         |
| DisplayQuantity    | **decimal**. The quantity of a product that is available to buy or sell that is publicly displayed to the market. Needs to be defined with a value greater than 0 if **UseDisplayQuantity** is set to true, otherwise new order will not be visible in the orderbook. **conditionally required**.                                                                                                                                                                                                                                                                                                                                           |
| LimitPrice         | **decimal**. The price at which to execute the new order, if the new order is a limit order. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| StopPrice          | **decimal**. The price at which to execute the new order, if the order is a stop order. **conditionally required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ReferencePrice     | **decimal**. The reference price of the instrument in the order. **optional**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| PegPriceType       | <p><strong>integer or string</strong>. When entering a stop/trailing order, set PegPriceType to the type of price that pegs the stop. One of:<br>- 1 Last<br>- 2 Bid<br>- 3 Ask<br>- 4 Midpoint<br><strong>conditionally required</strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                             |
| TimeInForce        | <p><strong>integer or string</strong>. The period during which the new order is executable. One of:<br>- 0 Unknown (an error condition)<br>- 1 GTC (good 'til canceled, the default)<br>- 2 OPG (execute as close to opening price as possible: not yet used, for future provision)<br>- 3 IOC (immediate or canceled)<br>- 4 FOK (fill or kill — fill the order immediately, or cancel it immediately)<br>- 5 GTX (good 'til executed: not yet used, for future provision)<br>- 6 GTD (good 'til date: not yet used, for future provision)<br>The string value or the equivalent integer value can be used. <strong>required</strong>.</p> |
| OrderIdOCO         | **long integer**. One Cancels the Other — If the order being canceled in this call is order A, and the order replacing order A in this call is order B, then *OrderIdOCO* refers to an order C that is currently open. If order C executes, then order B is canceled. You can also set up order C to watch order B in this way, but that will require an update to order C. **optional**.                                                                                                                                                                                                                                                   |
| Quantity           | **decimal**. The amount of the order (either buy or sell). Not explicitly required but defaults to 0 when not defined, so it makes sense to be set greater than 0. **required**.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "CancelReplaceOrder",
  "o": "{
    \"ReplacementOrderId\": 123457,
    \"ReplacementClOrdId\": 0,
    \"OrigOrderId\": 123456,
    \"OrigClOrdId\": 0
  }"
}

```

The response returns the new replacement order ID and echoes back any replacement client ID you have supplied, along with the original order ID and the original client order ID.

| Key                | Value                                                                                                        |
| ------------------ | ------------------------------------------------------------------------------------------------------------ |
| replacementOrderId | **integer**. The order ID assigned to the replacement order by the server.                                   |
| replacementClOrdId | **long integer**. Echoes the contents of the *clientOrderId* value from the request.                         |
| origOrderId        | **integer**. Echoes *orderIdToReplace*, which is the original order you are replacing.                       |
| origClOrdId        | **long integer**. Provides the client order ID of the original order (not specified in the requesting call). |

### CancelOrder

**Permissions:** NotbankTrading\
**Call Type:** Synchronous

Cancels a specific open order that has been placed but has not yet been fully executed.

A user with NotbankTrading permission can only cancel an order for accounts with which he/she is associated to.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().cancelOrder({
  "OrderId": 6500,
  "AccountId": 9
});


// request payload
{
  AccountId?: number;
  OrderId?: number;
  ClOrderId?: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.CancelOrderParamBuilder;

var response = client.getTradingService()
        .cancelOrder(new CancelOrderParamBuilder(7, 6500L)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import CancelOrderRequest

response = client.cancel_order(CancelOrderRequest(
    account_id=7,
    order_id=6500
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "CancelOrder",
  "o": "{
    \"OMSId\": 1,
    \"OrderId\": 6500,
    \"AccountId\": 9
  }"
}
```

{% endtab %}
{% endtabs %}

The OMS ID and the Order ID precisely identify the order you wish to cancel, the Order ID is unique across an OMS but there is still a need to identify the account owning the order.

| Key       | Value                                                                              |
| --------- | ---------------------------------------------------------------------------------- |
| OMSId     | **integer**. The ID of the OMS on which the order exists. **required**.            |
| AccountId | **integer**. The ID of the account under which the order was placed. **required**. |
| OrderId   | **long integer**. The order to be canceled. **required**.                          |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "CancelOrder",
  "o": "{
    \"result\": true,
    \"errormsg\": null,
    \"errorcode\": 0,
    \"detail\": null
  }"
}
```

The response to **CancelOrder** verifies that the call was received, not that the order has been canceled successfully. Individual event updates to the user show order cancellation. To verify that an order has been canceled, call **GetOrderStatus** or **GetOpenOrders**.

| Key       | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| result    | **boolean**. Returns *true* if the call to cancel the order has been successfully received, otherwise returns *false*.                                                                                                                                                                                                                                                                                                                               |
| errormsg  | <p><strong>string</strong>. A successful receipt of a call to cancel an order returns <em>null</em>; the <em>errormsg</em> parameter for an unsuccessful call to cancel an order returns one of the following messages:<br>Not Authorized (errorcode 20)<br>Invalid Request (errorcode 100)<br>Operation Failed (errorcode 101)<br>Server Error (errorcode 102)<br>Resource Not Found (errorcode 104)<br>Operation Not Supported (errorcode 106)</p> |
| errorcode | **integer**. A successfully received call to cancel an order returns 0. An unsuccessfully received call to cancel an order returns one of the *errorcodes* shown in the *errormsg* list.                                                                                                                                                                                                                                                             |
| detail    | **string**. Message text that the system may send. The contents of this parameter are usually null.                                                                                                                                                                                                                                                                                                                                                  |

### GetOpenOrders

**Permissions:** NotbankTrading, NotbankReadOnly\
**Call Type:** Synchronous

Gets the list of Open Orders of an account, excluding Block Trades and Quotes.

A user with NotbankTrading or NotbankReadOnly permission can only get open orders for accounts with which he/she is associated to.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOpenOrders({
  "AccountId": 9
});


// request payload
{
  AccountId: number;
  InstrumentId?: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOpenOrdersParamBuilder;

var response = client.getTradingService().getOpenOrders(new GetOpenOrdersParamBuilder(7)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetOpenOrdersRequest

response = client.get_open_orders(GetOpenOrdersRequest(
    account_id=9
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetOpenOrders",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 9
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                                                      |
| ------------ | ------------------------------------------------------------------------------------------ |
| OMSId        | **integer**. The ID of the OMS on which the user resides. **required**.                    |
| AccountId    | **integer**. The ID of the account which you are getting open orders for. **required**.    |
| InstrumentId | **integer**. The ID of a specific instrument, can be used to filter results. **optional**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetOpenOrders",
  "o": "[
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6598,
      \"Price\": 39000,
      \"Quantity\": 1,
      \"DisplayQuantity\": 1,
      \"Instrument\": 1,
      \"Account\": 9,
      \"AccountName\": \"AnotherName\",
      \"OrderType\": \"StopMarket\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"Working\",
      \"ReceiveTime\": 1681114594150,
      \"ReceiveTimeTicks\": 638167113941496303,
      \"LastUpdatedTime\": 1681114594155,
      \"LastUpdatedTimeTicks\": 638167113941554842,
      \"OrigQuantity\": 1,
      \"QuantityExecuted\": 0,
      \"GrossValueExecuted\": 0,
      \"ExecutableValue\": 0,
      \"AvgPrice\": 0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"NewInputAccepted\",
      \"OrigOrderId\": 6598,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 26000,
      \"InsideAskSize\": 1,
      \"InsideBid\": 25000,
      \"InsideBidSize\": 1,
      \"LastTradePrice\": 26000,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"0\",
      \"UseMargin\": false,
      \"StopPrice\": 39000,
      \"PegPriceType\": \"Ask\",
      \"PegOffset\": 0,
      \"PegLimitOffset\": 0,
      \"IpAddress\": null,
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6627,
      \"Price\": 2,
      \"Quantity\": 1,
      \"DisplayQuantity\": 1,
      \"Instrument\": 1,
      \"Account\": 9,
      \"AccountName\": \"AnotherName\",
      \"OrderType\": \"Limit\",
      \"ClientOrderId\": 0,
      \"OrderState\": \"Working\",
      \"ReceiveTime\": 1681207997025,
      \"ReceiveTimeTicks\": 638168047970250300,
      \"LastUpdatedTime\": 1681207997026,
      \"LastUpdatedTimeTicks\": 638168047970264465,
      \"OrigQuantity\": 1,
      \"QuantityExecuted\": 0,
      \"GrossValueExecuted\": 0,
      \"ExecutableValue\": 0,
      \"AvgPrice\": 0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"NewInputAccepted\",
      \"OrigOrderId\": 6627,
      \"OrigClOrdId\": 0,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 26000,
      \"InsideAskSize\": 1,
      \"InsideBid\": 2,
      \"InsideBidSize\": 1,
      \"LastTradePrice\": 25000,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"AddedToBook\",
      \"UseMargin\": false,
      \"StopPrice\": 0,
      \"PegPriceType\": \"Ask\",
      \"PegOffset\": 0,
      \"PegLimitOffset\": 0,
      \"IpAddress\": null,
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    },
    {
      \"Side\": \"Buy\",
      \"OrderId\": 6507,
      \"Price\": 31000,
      \"Quantity\": 0.01,
      \"DisplayQuantity\": 0.01,
      \"Instrument\": 9,
      \"Account\": 9,
      \"AccountName\": \"AnotherName\",
      \"OrderType\": \"Limit\",
      \"ClientOrderId\": 1,
      \"OrderState\": \"Working\",
      \"ReceiveTime\": 1678976987086,
      \"ReceiveTimeTicks\": 638145737870859306,
      \"LastUpdatedTime\": 1679025072387,
      \"LastUpdatedTimeTicks\": 638146218723867613,
      \"OrigQuantity\": 1,
      \"QuantityExecuted\": 0,
      \"GrossValueExecuted\": 0,
      \"ExecutableValue\": 0,
      \"AvgPrice\": 0,
      \"CounterPartyId\": 0,
      \"ChangeReason\": \"UserModified\",
      \"OrigOrderId\": 6507,
      \"OrigClOrdId\": 1,
      \"EnteredBy\": 6,
      \"UserName\": \"sample_user\",
      \"IsQuote\": false,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0,
      \"InsideBid\": 31000,
      \"InsideBidSize\": 1,
      \"LastTradePrice\": 0,
      \"RejectReason\": \"\",
      \"IsLockedIn\": false,
      \"CancelReason\": \"\",
      \"OrderFlag\": \"AddedToBook\",
      \"UseMargin\": false,
      \"StopPrice\": 0,
      \"PegPriceType\": \"Ask\",
      \"PegOffset\": 0,
      \"PegLimitOffset\": 0,
      \"IpAddress\": null,
      \"IPv6a\": 0,
      \"IPv6b\": 0,
      \"ClientOrderIdUuid\": null,
      \"OMSId\": 1
    }
  ]"
}
```

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Side                 | <p><strong>string</strong>. The side of a trade. One of:<br>- 0 Buy<br>- 1 Sell.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| OrderId              | **long integer**. The ID of the open order. The *OrderID* is unique in each OMS.                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Price                | **decimal**. The price at which the buy or sell has been ordered.                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Quantity             | **decimal**. The quantity of the product to be bought or sold.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| DisplayQuantity      | **decimal**. The quantity available to buy or sell that is publicly displayed to the market. To display a *displayQuantity* value, an order must be a Limit order with a reserve.                                                                                                                                                                                                                                                                                                                                      |
| Instrument           | **integer**. The ID of the instrument being traded. The API method **GetInstruments** can supply the instrument IDs that are available.                                                                                                                                                                                                                                                                                                                                                                                |
| Account              | **integer**. The ID of the of the account which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| AccountName          | **string**. Name of the of the account which which the order belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| OrderType            | <p><strong>string</strong>. Describes the type of order this is. One of:<br>- 0 Unknown (an error condition)<br>- 1 Market order<br>- 2 Limit<br>- 3 StopMarket<br>- 4 StopLimit<br>- 5 TrailingStopMarket<br>- 6 TrailingStopLimit<br>- 7 BlockTrade.</p>                                                                                                                                                                                                                                                             |
| ClientOrderId        | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                                                                                                                                                                                                                                                                                                                     |
| OrderState           | **string**. The current state of the order. Will always be Working as this API method is getting **open orders**.                                                                                                                                                                                                                                                                                                                                                                                                      |
| ReceiveTime          | **long integer**. Time stamp of the order in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                                                       |
| ReceiveTimeTicks     | **long integer**. Time stamp of the order Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                                                           |
| LastUpdatedTime      | **long integer**. Time stamp when the order was last updated, in POSIX format x 1000 (milliseconds since 1/1/1970 in UTC time zone).                                                                                                                                                                                                                                                                                                                                                                                   |
| LastUpdatedTimeTicks | **long integer**. Time stamp when the order was last updated, in Microsoft Ticks format and UTC time zone. **Note:** Microsoft Ticks format is usually provided as a string. Here it is provided as a long integer.                                                                                                                                                                                                                                                                                                    |
| OrigQuantity         | **decimal**. If the open order has been changed or partially filled, this value shows the original quantity of the order.                                                                                                                                                                                                                                                                                                                                                                                              |
| QuantityExecuted     | **decimal**. If the open order has been at least partially executed, this value shows the amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                                               |
| GrossValueExecuted   | **decimal**. If the open order has been at least partially executed, this value shows the gross amount that has been executed.                                                                                                                                                                                                                                                                                                                                                                                         |
| ExecutableValue      | **decimal**. Defaults to 0. For future provision                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| AvgPrice             | **decimal**. The average executed price of the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| CounterPartyId       | **integer**. The ID of the account who is the counterparty for the trade if order is already executed, either partial or fully executed.                                                                                                                                                                                                                                                                                                                                                                               |
| ChangeReason         | <p><strong>string</strong>. If the order has been changed, this string value holds the reason. One of:<br>- 0 Unknown<br>- <strong>1</strong> NewInputAccepted<br>- 2 NewInputRejected<br>- 3 OtherRejected<br>- 4 Expired<br>- 5 Trade<br>- 6 SystemCanceled\_NoMoreMarket<br>- 7 SystemCanceled\_BelowMinimum<br>- 8 SystemCanceled\_PriceCollar<br>- 9 SystemCanceled\_MarginFailed<br>- 100 UserModified<br>An order that is newly added to book will have <strong>NewInputAccepted</strong> value by default.</p> |
| OrigOrderId          | **long integer**. If the order is a replacement order, this is the ID of the original order.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| OrigClOrdId          | **long integer**. If the order is a replacement order, this is the client order ID or the original order.                                                                                                                                                                                                                                                                                                                                                                                                              |
| EnteredBy            | **integer**. The ID of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Username             | **string**. The username of the user who submitted the order.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| IsQuote              | **boolean**. If this order is a quote, the value for *IsQuote* is *true*, otherwise it is *false.*                                                                                                                                                                                                                                                                                                                                                                                                                     |
| InsideAsk            | **decimal**. If this order is a quote, this value is the Inside Ask price.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| InsideAskSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Ask quote.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| InsideBid            | **decimal**. If this order is a quote, this value is the Inside Bid price.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| InsideBidSize        | **decimal**. If this order is a quote, this value is the quantity of the Inside Bid quote.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| LastTradePrice       | **decimal**. The last price that this instrument traded at.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| RejectReason         | **string**. If this open order has been rejected, this string holds the reason for the rejection.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| IsLockedIn           | **boolean**. For a block trade, if both parties to the block trade agree that one of the parties will report the trade for both sides, this value is *true.* Othersise, *false.*                                                                                                                                                                                                                                                                                                                                       |
| CancelReason         | **string**. If this order has been canceled, this string holds the cancellation reason.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| OrderFlag            | <p><strong>integer or string</strong>. One or more of:<br>1 NoAccountRiskCheck<br>2 AddedToBook<br>4 RemovedFromBook<br>8 PostOnly<br>16 Liquidation<br>32 ReverseMarginPosition.</p>                                                                                                                                                                                                                                                                                                                                  |
| UseMargin            | **boolean**. Margin is not yet supported so this always defaults to false.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| StopPrice            | **decimal**. The price at which the order executes, if the order is a stop order. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                              |
| PegPriceType         | **string**. The type of price to peg the Stop to for Stop/Trailing orders.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| PegOffset            | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| PegLimitOffset       | **decimal**. Only applicable to trailing/stop orders. Defaults to 0 if order is another type.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| IpAddress            | **string**. The IP address from where the order was submitted.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                                                |
| IPv6a                | **UInt64**. The IPv6 where the order was submitted from. Currently not being used, for future provision. Defaults to 0.                                                                                                                                                                                                                                                                                                                                                                                                |
| OMSId                | **integer**. The ID of the OMS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

### GetAccountTrades

**Permissions:** NotbankTrading, NotbankReadOnly\
**Call Type:** Synchronous

Gets a list of details of up to 200 past trade executions for a single specific account and OMS, starting at index *i*, where *i* is an integer identifying a specific execution, and advancing in reverse order; that is, the most recent execution has an index of 0, and increments by one as trade executions recede into the past.

A user with NotbankTrading or NotbankReadOnly permission can only access trade information for accounts with which he/she is associated to.

The operator of the trading venue determines how long to retain an accessible trading history before archiving.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getAccountTrades({
  "AccountId": 7,
  "Depth": 2
});


// request payload
{
  AccountId?: number;
  StartIndex?: number;
  Depth?: number;
  InstrumentId?: number;
  TradeId?: number;
  OrderId?: number;
  StartTimestamp?: number;
  EndTimestamp?: number;
  ExecutionId?: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetAccountTradesParamBuilder;

var response = client.getTradingService()
        .getAccountTrades(new GetAccountTradesParamBuilder().accountId(7).depth(2)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetAccountTradesRequest

response = client.get_account_trades(GetAccountTradesRequest(
    account_id=7,
    depth=2
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetAccountTrades",
  "o": "{
    \"OMSId\": 1,
    \"AccountId\": 7,
    \"Depth\": 2
  }"
}
```

{% endtab %}
{% endtabs %}

| Key            | Value                                                                                                                                                                                                                                                                  |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId          | **integer**. The ID of the OMS on which the user resides. **required**.                                                                                                                                                                                                |
| AccountId      | **integer**. The ID of the account. If not specified, if authenticated user has the default permissions, its default account's trades will be returned, else if the authenticated user has elevated permissions, trades of any account will be returned. **optional**. |
| StartIndex     | **integer**. The starting index into the history of trades, beginning from 0 (the most recent trade). **optional**.                                                                                                                                                    |
| Count or Depth | **integer**. The number of trades to return. The system can return up to 200 trades. **optional**.                                                                                                                                                                     |
| InstrumentId   | **integer**. The ID of the instrument for which account trades will be returned, filter parameter. **optional**.                                                                                                                                                       |
| TradeId        | **integer**. The ID of a specific trade, filter parameter. **optional**.                                                                                                                                                                                               |
| OrderId        | **integer**. The ID of a specific order, filter parameter. **optional**.                                                                                                                                                                                               |
| StartTimeStamp | **long integer**. Filter parameter. **optional**.                                                                                                                                                                                                                      |
| EndTimeStamp   | **long integer**. Filter parameter. **optional**.                                                                                                                                                                                                                      |
| ExecutionId    | **integer**. Filter parameter. **optional**.                                                                                                                                                                                                                           |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetAccountTrades",
  "o": "[
    {
      \"OMSId\": 1,
      \"ExecutionId\": 1831,
      \"TradeId\": 916,
      \"OrderId\": 6559,
      \"AccountId\": 7,
      \"AccountName\": \"sample\",
      \"SubAccountId\": 0,
      \"ClientOrderId\": 0,
      \"InstrumentId\": 2,
      \"Side\": \"Buy\",
      \"OrderType\": \"Limit\",
      \"Quantity\": 0.02,
      \"RemainingQuantity\": 0.0,
      \"Price\": 23436.0,
      \"Value\": 468.72,
      \"CounterParty\": \"9\",
      \"OrderTradeRevision\": 1,
      \"Direction\": \"NoChange\",
      \"IsBlockTrade\": false,
      \"Fee\": 0.0004,
      \"FeeProductId\": 4,
      \"OrderOriginator\": 0,
      \"UserName\": \"\",
      \"TradeTimeMS\": 1681203988297,
      \"MakerTaker\": \"Maker\",
      \"AdapterTradeId\": 0,
      \"InsideBid\": 23436.0,
      \"InsideBidSize\": 0.0,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"IsQuote\": false,
      \"CounterPartyClientUserId\": 1,
      \"NotionalProductId\": 1,
      \"NotionalRate\": 1.0,
      \"NotionalValue\": 468.72,
      \"NotionalHoldAmount\": 0,
      \"TradeTime\": 638168007882966478
    },
    {
      \"OMSId\": 1,
      \"ExecutionId\": 1829,
      \"TradeId\": 915,
      \"OrderId\": 6557,
      \"AccountId\": 7,
      \"AccountName\": \"sample\",
      \"SubAccountId\": 0,
      \"ClientOrderId\": 0,
      \"InstrumentId\": 2,
      \"Side\": \"Buy\",
      \"OrderType\": \"Limit\",
      \"Quantity\": 0.02,
      \"RemainingQuantity\": 0.0,
      \"Price\": 23436.0,
      \"Value\": 468.72,
      \"CounterParty\": \"9\",
      \"OrderTradeRevision\": 1,
      \"Direction\": \"NoChange\",
      \"IsBlockTrade\": false,
      \"Fee\": 0.0004,
      \"FeeProductId\": 4,
      \"OrderOriginator\": 0,
      \"UserName\": \"\",
      \"TradeTimeMS\": 1681203988296,
      \"MakerTaker\": \"Maker\",
      \"AdapterTradeId\": 0,
      \"InsideBid\": 23436.0,
      \"InsideBidSize\": 0.0,
      \"InsideAsk\": 79228162514264337593543950335,
      \"InsideAskSize\": 0.0,
      \"IsQuote\": false,
      \"CounterPartyClientUserId\": 1,
      \"NotionalProductId\": 1,
      \"NotionalRate\": 1.0,
      \"NotionalValue\": 468.72,
      \"NotionalHoldAmount\": 0,
      \"TradeTime\": 638168007882963921
    }
  ]"
}
```

The response is an array of objects, each element of which represents a trade by the account.

| Key                      | Value                                                                                                                                                                                                                 |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId                    | **integer**. The ID of the OMS on which the account resdies.                                                                                                                                                          |
| ExecutionId              | **integer**. The ID of this account's side of the trade. Every trade has two sides.                                                                                                                                   |
| TradeId                  | **integer**. The ID of the overall trade.                                                                                                                                                                             |
| OrderId                  | **long integer**. The ID of the order causing the trade (buy or sell).                                                                                                                                                |
| AccountId                | **integer**. The ID of the account that made the trade (buy or sell).                                                                                                                                                 |
| AccountName              | **string**. The Name of the account that made the trade (buy or sell).                                                                                                                                                |
| SubAccountId             | **integer**. Not currently used; reserved for future use. Defaults to 0.                                                                                                                                              |
| ClientOrderId            | **long integer**. An ID supplied by the client to identify the order (like a purchase order number). Default is 0.                                                                                                    |
| InstrumentId             | **integer**. The ID of the instrument being traded. An instrument comprises two products, for example Dollars and Bitcoin.                                                                                            |
| Side                     | <p><strong>string</strong>. One of:<br>- 0 Buy<br>- 1 Sell.</p>                                                                                                                                                       |
| OrderType                | <p><strong>string</strong>. One of:<br>- Market<br>- Limit<br>- BlockTrade<br>- StopMarket<br>- StopLimit<br>- TrailingStopLimit<br>- StopMarket<br>- TrailingStopMarket</p>                                          |
| Quantity                 | **decimal**. The unit quantity of this side of the trade.                                                                                                                                                             |
| RemainingQuantity        | **decimal**. The number of units remaining to be traded by the order after this execution. This number is not revealed to the other party in the trade. This value is also known as "leave size" or "leave quantity". |
| Price                    | **decimal**. The unit price at which the instrument traded.                                                                                                                                                           |
| Value                    | <p><strong>decimal</strong>. The total value of the deal. The system calculates this as:<br>unit price X quantity executed.</p>                                                                                       |
| CounterParty             | **string**. The ID of the other party in a block trade. Usually, IDs are stated as integers; this value is an integer written as a string.                                                                            |
| OrderTradeRevision       | **integer**. The revision number of this trade; usually 1.                                                                                                                                                            |
| Direction                | <p><strong>string</strong>. The effect of the trade on the instrument's market price. One of:<br>- <strong>0</strong> No change<br>- <strong>1</strong> Uptick<br>- <strong>2</strong> DownTick</p>                   |
| IsBlockTrade             | **boolean**. A value of *true* means that this trade was a block trade; a value of *false* that it was not a block trade.                                                                                             |
| Fee                      | **decimal** Any fee levied against the trade by the Exchange.                                                                                                                                                         |
| FeeProductId             | **integer**. The ID of the product in which the fee was levied.                                                                                                                                                       |
| OrderOriginator          | **integer**. The ID of the user who initiated the trade.                                                                                                                                                              |
| UserName                 | **integer**. The UserName of the user who initiated the trade.                                                                                                                                                        |
| TradeTimeMS              | **long integer**. The date and time that the trade took place, in milliseconds and POSIX format. All dates and times are UTC.                                                                                         |
| MakerTaker               | <p><strong>string</strong>. One of:<br>- Maker<br>- Taker.</p>                                                                                                                                                        |
| AdapterTradeId           | **integer**. The ID of the adapter of the overall trade.                                                                                                                                                              |
| InsideBid                | **decimal**. The best (highest) price level of the buy side of the book at the time of the trade.                                                                                                                     |
| InsideBidSize            | **decimal**. The quantity of the best (highest) price level of the buy side of the book at the time of the trade.                                                                                                     |
| InsideAsk                | **decimal**. The best (lowest) price level of the sell side of the book at the time of the trade.                                                                                                                     |
| InsideAskSize            | **decimal**. The quantity of the best (lowest) price level of the sell side of the book at the time of the trade.                                                                                                     |
| CounterPartyClientUserId | **integer**. Indicates counterparty source of trade (OMS, Remarketer, FIX)                                                                                                                                            |
| NotionalProductId        | **integer**. Notional product the notional value was captured in                                                                                                                                                      |
| NotionalRate             | **decimal**. Notional rate from base currency at time of trade                                                                                                                                                        |
| NotionalValue            | **decimal**. Notional value in base currency of venue at time of trade                                                                                                                                                |
| TradeTime                | **long integer**. The date and time that the trade took place, in C# Ticks. All dates and times are UTC.                                                                                                              |

### Summary

**Permissions:** Public\
**Call Type:** Synchronous

Gets a list of summaries, one for each instrument present in the exchange.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getSummary();
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetSummaryParamBuilder;

var response = client.getTradingService().getSummary(new GetSummaryParamBuilder()).get();
```

{% endtab %}

{% tab title="Python" %}

```python
response = client.get_summary()
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "Summary",
  "o": "{}"
}
```

{% endtab %}
{% endtabs %}

No field is required in the request payload.

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "Summary",
  "o": "[
    {
      \"trading_pairs\": \"BTC_USD\",
      \"last_price\": 29000,
      \"lowest_ask\": 29000,
      \"highest_bid\": 28700,
      \"base_volume\": 0.222,
      \"quote_volume\": 6425.0,
      \"price_change_percent_24h\": 3.57142857142857142857142857,
      \"highest_price_24h\": 29000,
      \"lowest_price_24h\": 28000
    },
    {
      \"trading_pairs\": \"ETH_USD\",
      \"last_price\": 1970,
      \"lowest_ask\": 0,
      \"highest_bid\": 0,
      \"base_volume\": 0.0,
      \"quote_volume\": 0.0,
      \"price_change_percent_24h\": 0,
      \"highest_price_24h\": 0,
      \"lowest_price_24h\": 0
    }
  ]"
}
```

Returns an array of objects, each object represents a specific pair or instrument in the exchange.

| Key                         | Value                                                                                   |
| --------------------------- | --------------------------------------------------------------------------------------- |
| trading\_pairs              | **string**. The instrument pair.                                                        |
| last\_price                 | **decimal**. The last traded price of the instrument.                                   |
| lowest\_ask                 | **decimal**.The current lowest ask for the instrument.                                  |
| highest\_bid                | **decimal**. The current highest bid for the instrument.                                |
| base\_volume                | **decimal**. The current base volume of the instrument.                                 |
| quote\_volume               | **decimal**. The current quote volume of the instrument.                                |
| price\_change\_percent\_24h | **decimal**. The price percentage change of the instrument in 24H, resets UTC midnight. |
| highest\_price\_24h         | **decimal**. The highest traded price of the instrument in 24H, resets UTC midnight.    |
| lowest\_price\_24h          | **decimal**. The lowest traded price of the instrument in 24H, resets UTC midnight.     |

### Ticker

**Permissions:** Public\
**Call Type:** Synchronous

Gets a 24-hour pricing and volume summary for each market pair and each market type (spot, perpetuals, physical futures, options) available on Notbank for CMC integration.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getTicker();

```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetTickerParamBuilder;

var response = client.getTradingService().getTicker(new GetTickerParamBuilder()).get();
```

{% endtab %}

{% tab title="Python" %}

```python
response = client.get_ticker()
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "Ticker",
  "o": "{}"
}
```

{% endtab %}
{% endtabs %}

No field is required in the request payload.

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "Ticker",
  "o": "{
    \"BTC_USD\": {
      \"base_id\": 1,
      \"quote_id\": 0,
      \"last_price\": 29000,
      \"base_volume\": 0.222,
      \"quote_volume\": 6425.0
    },
    \"ETH_USD\": {
      \"base_id\": 1027,
      \"quote_id\": 0,
      \"last_price\": 1970,
      \"base_volume\": 0.0,
      \"quote_volume\": 0.0
    }
  }"
}

```

| Key           | Value                                                                          |
| ------------- | ------------------------------------------------------------------------------ |
| base\_id      | **integer**. The unified cryptoasset id of the base product of the instrument. |
| quote\_id     | **integer**. The quote id of the instrument.                                   |
| last\_price   | **decimal**. The last traded price of the instrument.                          |
| base\_volume  | **decimal**. The current base volume of the instrument.                        |
| quote\_volume | **decimal**. The current quote volume of the instrument.                       |

### OrderBook

**Permissions:** Public\
**Call Type:** Synchronous

Gets the orderbook for the given market pair.

A level 1 orderbook returns only the best bid and the best ask for a market pair (only one level).

A level 2 orderbook returns as many market levels as defined in the **Depth** parameter (bounded by the size of the market).

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getOrderBook({
  "Market_Pair": "BTCUSD",
  "Level": 1
});


// request payload
{
  Market_Pair: string;
  Depth?: number;
  Level?: 1 | 2;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetOrderBookParamBuilder;

var response = client.getTradingService().getOrderbook(new GetOrderBookParamBuilder("BTCUSD").level(1)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import OrderBookRequest

response = client.get_order_book(OrderBookRequest(
    market_pair="BTCUSD",
    level=1,
))
```

{% endtab %}

{% tab title="Json" %}

```json
//No need to set Depth if Level is set to 1
{
  "m": 0,
  "i": 0,
  "n": "OrderBook",
  "o": "{
    \"Market_Pair\": \"BTCUSD\",
    \"Level\": 1
  }"
}

////Level 2, you need to set Depth to a number higher than 1 else you will only see best bid and best ask
{
  "m": 0,
  "i": 0,
  "n": "OrderBook",
  "o": "{
    \"Market_Pair\": \"BTCUSD\",
    \"Depth\": 10,
    \"Level\": 2,
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                                                                                                                                                                                                                                                                                                            |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Market\_Pair | **string**. The instrument symbol, instrument id is not accepted. **required**.                                                                                                                                                                                                                                                                  |
| Depth        | **integer**. Depth of the orderbook you want to see, this only applicable if **Level** parameter is set to 2. Depth will always be 1 if this is not set or if Level is set to 1. **optional**.                                                                                                                                                   |
| Level        | **integer**. One of: 1, 2. 1 mean you only want to see the best bid and best ask, 2 means you want to see other levels of the book, number of bids and ask you will see depends on the **Depth** set, if **Depth** is not set and **Level** is set to 2, best bid and best ask will only be the ones to be returned. Default is 1. **optional**. |

#### Response

```json
//Level 1
{
  "m": 1,
  "i": 0,
  "n": "OrderBook",
  "o": "{
    \"timestamp\": 1679548364728,
    \"bids\": [
      [
        2, //Quantity
        28900 //Price
      ]
    ],
    \"asks\": [
      [
        0.5, //Quantity
        29000 //Price
      ]
    ]
  }"
}


//level 2, Depth 10, only 2 bids existing, only 1 ask existing
{
  "m": 1,
  "i": 0,
  "n": "OrderBook",
  "o": "{
    \"timestamp\": 1679548299447,
    \"bids\": [
      [
        2, //Quantity
        28900 //Price
      ],
      [
        1,
        28700
      ]
    ],
    \"asks\": [
      [
        0.5,
        29000
      ]
    ]
  }"
}
```

Returns a JSON object with fields timestamp, bids and asks.

| Key       | Value                                                                                                                 |
| --------- | --------------------------------------------------------------------------------------------------------------------- |
| timestamp | **long integer**. Unix timestamp in milliseconds, equivalent to the current timestamp when the response was returned. |
| bids      | **array**. The quantity (*decimal*) and price (*decimal*) per level which someone is willing to buy.                  |
| asks      | **array**. The quantity (*decimal*) and price (*decimal*) per level which someone is willing sell.                    |

### Trades

**Permissions:** Public\
**Call Type:** Synchronous

Gets trades for a specific market pair or instrument. Only returns the 100 most recent trades.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getTrades({
  "Market_Pair": "BTCUSD"
});


// request payload
{
  market_pair: string; // Market pair or instrument symbol (e.g., "BTCUSD")
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetTradesParamBuilder;

var response = client.getTradingService().getTrades(new GetTradesParamBuilder("BTCUSD")).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import TradesRequest

response = client.get_trades(TradesRequest(
    market_pair="BTCUSD"
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "Trades",
  "o": "{
    \"market_pair\": \"BTCUSD\"
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                           |
| ------------ | --------------------------------------------------------------- |
| market\_pair | **string**. The market pair or instrument symbol. **required**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "Trades",
  "o": "[
    {
      \"trade_id\": 1572,
      \"price\": 31000,
      \"base_volume\": 0.001,
      \"quote_volume\": 31.0,
      \"timestamp\": \"2023-05-05T04:47:58.917Z\",
      \"type\": \"sell\",
    },
    {
      \"trade_id\": 1573,
      \"price\": 31599,
      \"base_volume\": 0.001,
      \"quote_volume\": 31.599,
      \"timestamp\": \"2023-05-05T04:48:25.327Z\",
      \"type\": \"buy\",
    },
  ]"
}
```

| Key           | Value                                                                    |
| ------------- | ------------------------------------------------------------------------ |
| trade\_id     | **integer**. The ID of the trade execution.                              |
| price         | **decimal**. The price at which the trade was executed.                  |
| base\_volume  | **decimal**. The traded quantity of the base product/currency.           |
| quote\_volume | **decimal**. The traded quantity of the quote product/currency.          |
| timestamp     | **string**. The exact date and time when the trade was executed, in UTC. |
| type          | **string**. The side of the trade, One of: **buy**, **sell**.            |

### GetL2Snapshot

**Permissions:** Public\
**Call Type:** Synchronous

Gets the current Level 2 snapshot of a specific instrument.

A level 2 snapshot returns as many market levels as defined in the **Depth** parameter (bounded by the size of the market).

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getL2Snapshot({
  "InstrumentId": 1,
  "Depth": 100
});


// request payload
{
  InstrumentId: number;
  Depth: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetLevel2SnapshotParamBuilder;

var instrumentId = 1;
var response = client.getTradingService().getLevel2Snapshot(new GetLevel2SnapshotParamBuilder(instrumentId, 100)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetL2SnapshotRequest

response = client.get_l2_snapshot(GetL2SnapshotRequest(
    instrument_id=1,
    depth=10
))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetL2Snapshot",
  "o": "{
    \"OMSId\": 1,
    \"InstrumentId\": 1,
    \"Depth\": 100
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                                                                                                                                     |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMSId        | **integer**. The ID of the OMS. **required**.                                                                                                                             |
| InstrumentId | **integer**. The ID of the instrument that is the subject of the snapshot. **required**.                                                                                  |
| Depth        | **integer**. Maximum number of bids and asks that can be included in the results. If set to 10, there can be maximum of 10 bids and 10 asks in the results. **required**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetL2Snapshot",
  "o": "[
    [
      26, // MDUpdateId
      1, // Number of Unique Accounts
      1679559223042, //ActionDateTime in Posix format X 1000
      0, // ActionType 0 (New), 1 (Update), 2(Delete)
      29000, // LastTradePrice
      1, // Number of Orders
      28700, //Price
      1, // ProductPairCode
      0.5, // Quantity
      0, // Side 0 means buy and it is on the bid side
    ],
    [
      26,
      2,
      1679559223042,
      0,
      29000,
      2,
      29000,
      1,
      0.52,
      1, // Side 1 means sell and it is on the ask side
    ],
  ]"
}
```

The response is an array of elements for one specific instrument, the number of elements corresponding to the market depth specified in the Request. It is sent as an uncommented, comma-delimited list of numbers. The example is commented. The *Level2UpdateEvent* contains the same data, but is sent by the OMS whenever trades occur. To receive *Level2UpdateEvents*, a user must subscribe to *Level2UpdateEvents*.

| Key                       | Value                                                                                                                                                                                                                                                                  |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| MDUpdateID                | **integer**. Market Data Update ID. This sequential ID identifies the order in which the update was created.                                                                                                                                                           |
| Number of Unique Accounts | **integer**. Number of accounts that placed orders.                                                                                                                                                                                                                    |
| ActionDateTime            | **long integer**. Identifies the time and date that the snapshot was taken or the event occurred, in POSIX format X 1000 (milliseconds since 1 January 1970).                                                                                                          |
| ActionType                | <p><strong>integer</strong>. L2 information provides price data. This value shows whether this data is:<br><strong>0</strong> new<br><strong>1</strong> update<br><strong>2</strong> deletion</p>                                                                      |
| LastTradePrice            | **decimal**. The price at which the instrument was last traded.                                                                                                                                                                                                        |
| Number of Orders          | **integer**. Number of orders in the GetL2Snapshot.                                                                                                                                                                                                                    |
| Price                     | **decimal**. Bid or Ask price for the Quantity (see *Quantity* below).                                                                                                                                                                                                 |
| ProductPairCode           | **integer**. The same value and used for the same purpose as *InstrumentID*. The two are completely equivalent. *InstrumentId* 47 = *ProductPairCode* 47.                                                                                                              |
| Quantity                  | **decimal**. Quantity available at a given Bid or Ask price (see *Price* above).                                                                                                                                                                                       |
| Side                      | <p><strong>integer</strong>. One of:<br>- <strong>0</strong> Buy means it is on the bid side<br>- <strong>1</strong> Sell means it is on the ask side<br>- <strong>2</strong> Short (reserved for future use)<br>- <strong>3</strong> Unknown (an error condition)</p> |

### GetLevel1

**Permissions:** NotbankTrading, Public\
**Call Type:** Synchronous

Gets the current Level 1 snapshot (best bid, best offer and other data such last traded price) of a specific instrument.

The Level 1 snapshot is always of market depth 1.

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getLevel1({
  "InstrumentId": 1
});


// request payload
{
  InstrumentId: number;
}
```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetLevel1ParamBuilder;

var response = client.getTradingService().getLevel1(new GetLevel1ParamBuilder(154)).get();
```

{% endtab %}

{% tab title="Python" %}

```python
from notbank_python_sdk.requests_models import GetLevel1Request

response = client.get_level1(GetLevel1Request(instrument_id=1))
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetLevel1",
  "o": "{
    \"OMSId\": 1
    \"InstrumentId\": 1
  }"
}
```

{% endtab %}
{% endtabs %}

| Key          | Value                                                                                            |
| ------------ | ------------------------------------------------------------------------------------------------ |
| OMSId        | **integer**. The ID of the OMS. **required**.                                                    |
| InstrumentId | **integer**. The ID of the instrument whose Level 1 market snapshot will be taken. **required**. |

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetLevel1",
  "o": "{
    \"OMSId\": 1,
    \"InstrumentId\": 1,
    \"BestBid\": 28700,
    \"BestOffer\": 29000,
    \"LastTradedPx\": 29000,
    \"LastTradedQty\": 0.001,
    \"LastTradeTime\": 1679466290437,
    \"SessionOpen\": 28000,
    \"SessionHigh\": 29000,
    \"SessionLow\": 28000,
    \"SessionClose\": 29000,
    \"Volume\": 0.001,
    \"CurrentDayVolume\": 0.222,
    \"CurrentDayNotional\": 6425.0,
    \"CurrentDayNumTrades\": 5,
    \"CurrentDayPxChange\": 1000,
    \"Rolling24HrVolume\": 0.0,
    \"Rolling24HrNotional\": 0.0,
    \"Rolling24NumTrades\": 0,
    \"Rolling24HrPxChange\": 0,
    \"TimeStamp\": \"1679466290440\",
    \"BidQty\": 0.5,
    \"AskQty\": 0.5,
    \"BidOrderCt\": 0,
    \"AskOrderCt\": 0,
    \"Rolling24HrPxChangePercent\": 0
  }"
}
```

| Key                        | Value                                                                                                                                                                                            |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| OMSId                      | **integer**. The ID of the OMS.                                                                                                                                                                  |
| InstrumentId               | **integer**. The ID of the instrument being tracked.                                                                                                                                             |
| BestBid                    | **decimal**. The current best bid for the instrument.                                                                                                                                            |
| BestOffer                  | **decimal**. The current best offer for the instrument.                                                                                                                                          |
| LastTradedPx               | **decimal**. The last-traded price for the instrument.                                                                                                                                           |
| LastTradedQty              | **decimal**. The last-traded quantity for the instrument.                                                                                                                                        |
| LastTradeTime              | **long integer**. The time of the last trade, in POSIX format.                                                                                                                                   |
| SessionOpen                | **decimal**. Opening price. In markets with openings and closings, this is the opening price for the current session; in 24-hour markets, it is the price as of UTC Midnight.                    |
| SessionHigh                | **decimal**. Highest price during the trading day, either during a session with opening and closing prices or UTC midnight to UTC midnight.                                                      |
| SessionLow                 | **decimal**. Lowest price during the trading day, either during a session with opening and closing prices or UTC midnight to UTC midnight.                                                       |
| SessionClose               | **decimal**. The closing price. In markets with openings and closings, this is the closing price for the current session; in 24-hour markets, it is the price as of UTC Midnight.                |
| Volume                     | **decimal**. The last-traded quantity for the instrument, same value as LastTradedQty                                                                                                            |
| CurrentDayVolume           | **decimal**. The unit volume of the instrument traded either during a session with openings and closings or in 24-hour markets, the period from UTC Midnight to UTC Midnight.                    |
| CurrentDayNumTrades        | **integer**. The number of trades during the current day, either during a session with openings and closings or in 24-hour markets, the period from UTC Midnight to UTC Midnight.                |
| CurrentDayPxChange         | **decimal**. Current day price change, either during a trading session or UTC Midnight to UTC midnight.                                                                                          |
| CurrentNotional            | **decimal**. Current day quote volume - resets at UTC Midnight.                                                                                                                                  |
| Rolling24HrNotional        | **decimal**. Rolling 24 hours quote volume.                                                                                                                                                      |
| Rolling24HrVolume          | **decimal**. Unit volume(quantity traded, in the product 1 or in the base currency denomination) of the instrument during the past 24 hours, regardless of time zone. Recalculates continuously. |
| Rolling24HrNumTrades       | **integer**. Number of trades during the past 24 hours, regardless of time zone. Recalculates continuously.                                                                                      |
| Rolling24HrPxChange        | **decimal**. Price change during the past 24 hours, regardless of time zone. Recalculates continuously.                                                                                          |
| TimeStamp                  | **string**. The time this information was provided, in POSIX format.                                                                                                                             |
| BidQty                     | **decimal**. The quantity currently being bid.                                                                                                                                                   |
| AskQty                     | **decimal**. The quantity currently being asked.                                                                                                                                                 |
| BidOrderCt                 | **integer**. The count of bid orders.                                                                                                                                                            |
| AskOrderCt                 | **integer**. The count of ask orders.                                                                                                                                                            |
| Rolling24HrPxChangePercent | **decimal**. Percent change in price during the past 24hours regardles of the timezone. Recalculates continuously.                                                                               |

### GetEnums

**Permissions:** Public\
**Call Type:** Synchronous

Gets a list of enumeration definitions of the fields of orders (such as OrderState or TimeInForce).

#### Request

{% tabs %}
{% tab title="Node" %}

```javascript
import Notbank from 'notbank'
// websocket connection code ...

await client.getTradingService().getEnums();


```

{% endtab %}

{% tab title="Java" %}

```java
import exchange.notbank.trading.paramBuilders.GetEnumsParamBuilder;

var response = client.getTradingService().getEnums(new GetEnumsParamBuilder()).get();
```

{% endtab %}

{% tab title="Python" %}

```python
response = client.get_enums()
```

{% endtab %}

{% tab title="Json" %}

```json
{
  "m": 0,
  "i": 0,
  "n": "GetEnums",
  "o": "{}"
}
```

{% endtab %}
{% endtabs %}

No request payload required.

#### Response

```json
{
  "m": 1,
  "i": 0,
  "n": "GetEnums",
  "o": "[
    {
      \"Class\": \"Order\",
      \"Property\": \"OrderState\",
      \"Enums\": [
        {
          \"Name\": \"Working\",
          \"Description\": \"Order is in non-terminal state either on the order book or not activated yet if a stop order\",
          \"Number\": 1
        },
        {
          \"Name\": \"Rejected\",
          \"Description\": \"Order is in a terminal state and has been rejected by the matching engine\",
          \"Number\": 2
        },
        {
          \"Name\": \"Canceled\",
          \"Description\": \"Order is in a terminal state and has been cancelled by the oms or by the user\",
          \"Number\": 3
        },
        {
          \"Name\": \"Expired\",
          \"Description\": \"Order is in a terminal state and has been expired by the matching engine\",
          \"Number\": 4
        },
        {
          \"Name\": \"FullyExecuted\",
          \"Description\": \"Order is in a terminal state and has been fully executed by the matching engine\",
          \"Number\": 5
        }
      ]
    }
  ]"
}
```

| Key      | Value                                                                                                                                                                                                                                                                                                                                                             |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Class    | **string**. The class name. Since GetEnums is solely for Orders currently, the class name will always be **Order**.                                                                                                                                                                                                                                               |
| Property | **string**. The property name, since GetEnums is solely for Orders currently, property name will always be **OrderState**.                                                                                                                                                                                                                                        |
| Enums    | <p><strong>array of objects</strong>. The actual enum values for Orders.<br><strong>Name</strong> - <strong>string</strong>. The name of the order state enum.<br><strong>Description</strong> - <strong>string</strong>. The description of the order state enum.<br><strong>Number</strong> - <strong>integer</strong>. The number of the order state enum.</p> |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.notbank.com/learn/api-reference/websocket-api/trading.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
