# Trade model: BulkOrderAction

This page describes the FX Integration API's **BulkOrderAction** trade model, as defined in the file `config/TradingAdapter/Blade/DataSource/etc/trademodels.xml` in the FX Integration API Kit.

This documentation is for the FX Integration API 12.10.0.

Trade models are XML-defined state machines used by the [Java Trading API](https://docs.caplin.com/developer/api/trading_java/latest/) and Caplin Trader's [Trading API](../caplin-trader/4/trading-api/index.md) to manage trading workflows. For more information on trade model XML definitions, see the [Trade model XML schema](../caplin-platform/cis/cis-trade-model-schema.md) reference.

## State model

The BulkOrderAction trade model's state model in Mermaid JS format:

```mermaid
%% State diagram for the BulkOrderAction trade model
stateDiagram-v2
    [*] --> Initial
    Initial --> BulkActionSent : BulkActionSubmit (client)
    BulkActionSent --> Error : Error (server)
    BulkActionSent --> Processing : BulkActionAck (server)
    Error --> [*] 
    Processing --> Done : BulkActionCompleted (server)
    Processing --> Cancelled : CancelWait (client)
    Processing --> Error : Error (server)
    Done --> [*] 
    Cancelled --> [*] 
```

The BulkOrderAction trade model's state model in a flat state-transition matrix:

| Source state | Event trigger | Origin | Target state |
| ------------ | ------------- | ------ | ------------ |
| [*] | - | - | Initial |
| Initial | BulkActionSubmit | client | BulkActionSent |
| BulkActionSent | Error | server | Error |
| BulkActionSent | BulkActionAck | server | Processing |
| Error | - | - | [*] |
| Processing | BulkActionCompleted | server | Done |
| Processing | CancelWait | client | Cancelled |
| Processing | Error | server | Error |
| Done | - | - | [*] |
| Cancelled | - | - | [*] |

## Event message specifications

This section describes the messages sent between client and server when a state-model event occurs. The origin of an event (the client or the server) is specified in brackets after the name of the event.

The specification of some events depends on the type of financial product being traded, and when this applies, the variant specifications are detailed under level-4 headings.

Back-end developers build server events by using classes in the Caplin's FX Integration API, a Java library that makes it easy to provide data to Caplin's web applications. Where appropriate, the specifications below include references to JavaDoc documentation and code examples.


### Event: BulkActionSubmit (client)

Message specification:

```json
{
  "trade_model_name": "BulkOrderAction",
  "trade_model_trigger": "BulkActionSubmit",
  "message_origin": "client",
  "fields": [
    {
      "name": "MsgType",
      "type": "String",
      "flags": "",
      "definition": "Name of the transition",
      "example_value": "BulkActionSubmit",
      "deprecated": false
    },
    {
      "name": "RequestID",
      "type": "String",
      "flags": "",
      "definition": "The RequestID. A Unique identifier, must remain the same for each event in the trade model",
      "example_value": "",
      "deprecated": false
    },
    {
      "name": "BulkAction",
      "type": "",
      "flags": "",
      "definition": "The new state that we would like the order to switch to, e.g. Active, Inactive",
      "example_value": "",
      "deprecated": false
    },
    {
      "name": "OrderIDs",
      "type": "",
      "flags": "",
      "definition": "A comma separated list of the Order IDs to apply the action to",
      "example_value": "",
      "deprecated": false
    },
    {
      "name": "AppID",
      "type": "",
      "flags": "",
      "definition": "A unique identifier for the client application",
      "example_value": "",
      "deprecated": false
    }
  ]
}
```

### Event: CancelWait (client)

Message specification:

```json
{
  "trade_model_name": "BulkOrderAction",
  "trade_model_trigger": "CancelWait",
  "message_origin": "client",
  "fields": [
    {
      "name": "MsgType",
      "type": "String",
      "flags": "",
      "definition": "Name of the transition",
      "example_value": "CancelWait",
      "deprecated": false
    },
    {
      "name": "RequestID",
      "type": "String",
      "flags": "",
      "definition": "The RequestID. A Unique identifier, must remain the same for each event in the trade model",
      "example_value": "",
      "deprecated": false
    }
  ]
}
```


### Event: BulkActionAck (server)

Message specification:

```json
{
  "trade_model_name": "BulkOrderAction",
  "trade_model_trigger": "BulkActionAck",
  "message_origin": "server"
}
```

### Event: BulkActionCompleted (server)

Message specification:

```json
{
  "trade_model_name": "BulkOrderAction",
  "trade_model_trigger": "BulkActionCompleted",
  "message_origin": "server"
}
```

