# Block trades

Block Trade tickets allow users to perform a single amalgamated FX trade that is split across several accounts.

They implement "pre-trade allocations", enabling the user to import the required account allocations from a spreadsheet.

Spot, forward and swap trades are supported.

Block Trade tickets consist of a blade where the code is under the directory `<YOURAPP>/fxexecution-bladeset/blades/blocktrade`. They are implemented as a [Presenter,window="_blank"](../../caplin-trader/4/presenter/index.md) component whose main presentation model class is `caplinx.fxexecution.blocktrade.manager.Manager` and HTML template is `<blade-home>/html/resources/manager/template.html.`

## GUI Structure

The image below shows the Block Trade ticket with two blocks of trades one for EURGBP the other GBPUSD. Each block displays how the trade will be split between accounts. The Import/Export buttons allow blocks to be loaded from and saved to a spreadsheet.

![block-trade-entry](../../images/block-trade-entry.png)

The Netted tab displays the single resultant amalgamated trade for each block as shown below:

![block-trade-netted](../../images/block-trade-netted.png)

Finally clicking the ***_Quote_ **button displays the *Trading Mode** tab. To execute trades within the block, click the **_Accept_ **button. The trade is then executed as a single transaction where each account allocation is represented as a trade-leg.

![block-trade-trading](../../images/block-trade-trading.png)

## Code Architecture

The `Manager` class is responsible for the overall control of the ticket. Every time it is displayed, a new instance is instantiated. Each block is managed by an instance of the `caplinx.fxexecution.blocktrade.block.presentation.BlockTrade` class which in turn creates an instance of `caplinx.fxexecution.blocktrade.block.presentation.BlockTradeLeg` for each allocation row. Each `BlockTrade` creates an instance of the trade model from the trade service. The `caplinx.fxexecution.blocktrade.BlocktradeBootstrap` class registers `caplinx.fxexecution.blocktrade.block.trademodel.FXBlockTradeFactory` as the factory for the `caplinx.fxexecution.blocktrade.block.trademodel.FXBlockTrade` trade model class which in turn uses instances of `caplinx.fxexecution.blocktrade.block.trademodel.FXBlockTradeLeg` to model each allocation row. The trade model contains trade legs for both allocation rows and a single row for the netted values. Changing the mode (from input to netted or trading) simply toggles the visibility of those trade legs. See the [Block Trade Message Specifications](block-trade-messages.md) for details about the messages sent to the eserver when the trade is executed.

---

**See more:**

* [Block Trade Messages](block-trade-messages.md)
