# Trade Data Target Schema

To ensure the `send_trade` method supports a fully structured schema for trade data input, including all fields from the **R8fin Trade Data** schema.

***

### Installation

Install the SDK using pip:

```bash
pip install blockhouse==1.0.16
```

***

### Sending Full Trade Data

The `send_trade` method supports sending complete trade data based on the **R8fin Trade Data** schema.

```python
from blockhouse import TradeClient

# Initialize the client
client = TradeClient("f6d8d388f0c3c1479d5b30cb43d5346d")

# Send the trade data
response = client.send_trade(trade_data)
```

#### Input Schema

The `send_trade` method accepts a dictionary containing the following fields:

<table data-header-hidden><thead><tr><th width="270"></th><th width="236"></th><th></th></tr></thead><tbody><tr><td><strong>Column Name</strong></td><td><strong>Data Type</strong></td><td><strong>Description</strong></td></tr><tr><td><strong>trade_date</strong></td><td>DATE</td><td>The execution trade date.</td></tr><tr><td><strong>executiontime</strong></td><td>TIMESTAMP</td><td>Execution time logged in raw format.</td></tr><tr><td><strong>brokerexecutiontime</strong></td><td>TIMESTAMP</td><td>Time recorded by the broker.</td></tr><tr><td><strong>exec_time_et</strong></td><td>TIMESTAMP</td><td>Execution time in Eastern Time.</td></tr><tr><td><strong>recapid</strong></td><td>STRING</td><td>Record ID for this trade.</td></tr><tr><td><strong>orderid</strong></td><td>STRING</td><td>Order ID associated with the execution.</td></tr><tr><td><strong>parentcorrelationorderid</strong></td><td>STRING</td><td>Parent order ID that links multiple orders.</td></tr><tr><td><strong>executionid</strong></td><td>STRING</td><td>Unique ID for the execution.</td></tr><tr><td><strong>firm</strong></td><td>STRING</td><td>Firm identifier.</td></tr><tr><td><strong>client</strong></td><td>STRING</td><td>Client identifier.</td></tr><tr><td><strong>syntheticcontractidentifier</strong></td><td>STRING</td><td>Identifier for the synthetic contract.</td></tr><tr><td><strong>instrument</strong></td><td>STRING</td><td>Instrument or contract involved in the trade.</td></tr><tr><td><strong>syntheticpricemode</strong></td><td>STRING</td><td>Pricing mode (e.g., Yield).</td></tr><tr><td><strong>syntheticticksize</strong></td><td>FLOAT</td><td>Tick size for the synthetic contract.</td></tr><tr><td><strong>syntheticcontractdefinition</strong></td><td>STRING</td><td>Details of the synthetic contract (e.g., UST 10_YEAR, UST 30_YEAR).</td></tr><tr><td><strong>security_type</strong></td><td>STRING</td><td>Type of security (e.g., C for Cash).</td></tr><tr><td><strong>symbol</strong></td><td>STRING</td><td>The symbol of the product that was executed.</td></tr><tr><td><strong>cusip</strong></td><td>STRING</td><td>CUSIP identifier for the security.</td></tr><tr><td><strong>side</strong></td><td>STRING</td><td>Trade side (B for Buy, S for Sell).</td></tr><tr><td><strong>quantity</strong></td><td>INT</td><td>Quantity of the trade (e.g., 1, 2).</td></tr><tr><td><strong>price</strong></td><td>FLOAT</td><td>Price of the trade.</td></tr><tr><td><strong>order_source</strong></td><td>STRING</td><td>Source of the order (e.g., Other-Core).</td></tr><tr><td><strong>broker_id</strong></td><td>STRING</td><td>Broker identifier.</td></tr><tr><td><strong>exchange</strong></td><td>STRING</td><td>Exchange where the trade was executed.</td></tr><tr><td><strong>exchange_route</strong></td><td>STRING</td><td>Route taken at the exchange.</td></tr><tr><td><strong>exchange_endpoint</strong></td><td>STRING</td><td>Endpoint for the exchange.</td></tr><tr><td><strong>exchange_lp</strong></td><td>STRING</td><td>Liquidity provider at the exchange.</td></tr><tr><td><strong>is_aggressive</strong></td><td>BOOLEAN</td><td>Indicator if the trade was aggressive.</td></tr><tr><td><strong>destination</strong></td><td>STRING</td><td>Destination type (e.g., ICEBERG, SOR).</td></tr><tr><td><strong>order_text</strong></td><td>STRING</td><td>Additional text for the order (e.g., Quote or Hedge description).</td></tr><tr><td><strong>quote_or_hedge</strong></td><td>STRING</td><td>Indicates if the trade is a Quote or Hedge.</td></tr><tr><td><strong>hedge_target_price</strong></td><td>FLOAT</td><td>Target price for the hedge.</td></tr><tr><td><strong>cash_exchange_trade_id</strong></td><td>STRING</td><td>ID of the cash exchange trade.</td></tr><tr><td><strong>timestamp</strong></td><td>FLOAT</td><td>Timestamp of the trade.</td></tr><tr><td><strong>build_id</strong></td><td>STRING</td><td>Build ID associated with the execution.</td></tr><tr><td><strong>build_name</strong></td><td>STRING</td><td>Name of the build.</td></tr><tr><td><strong>hide_duration</strong></td><td>FLOAT</td><td>Duration for which the order was hidden.</td></tr><tr><td><strong>pop_ticks</strong></td><td>STRING</td><td>Ticks associated with the trade population.</td></tr><tr><td><strong>label</strong></td><td>STRING</td><td>Label for the trade (e.g., comp_0: 0.0).</td></tr><tr><td><strong>strategy</strong></td><td>STRING</td><td>The trading strategy applied (e.g., Curve).</td></tr></tbody></table>

#### Example Usage

```python
from blockhouse import TradeClient

# Initialize the client
client = TradeClient("d713bb69cbdb9c15c2b30c388ebbaf6a")

# Define the full trade data schema
trade_data = {
    "trade_date": "2025-01-15",
    "executiontime": "2025-01-15T10:30:45Z",
    "brokerexecutiontime": "2025-01-15T10:30:50Z",
    "exec_time_et": "2025-01-15T05:30:45-05:00",
    "recapid": "abcd1234",
    "orderid": "12345",
    "parentcorrelationorderid": "67890",
    "executionid": "xyz9876",
    "firm": "BlockhouseTrading",
    "client": "Client123",
    "syntheticcontractidentifier": "Synthetic01",
    "instrument": "UST 10_YEAR",
    "syntheticpricemode": "Yield",
    "syntheticticksize": 0.01,
    "syntheticcontractdefinition": "UST 10_YEAR Synthetic Contract",
    "security_type": "C",
    "symbol": "AAPL",
    "cusip": "037833100",
    "side": "buy",
    "quantity": 100,
    "price": 150.50,
    "order_source": "Other-Core",
    "broker_id": "BRK123",
    "exchange": "NASDAQ",
    "exchange_route": "Direct",
    "exchange_endpoint": "Endpoint123",
    "exchange_lp": "LiquidityProvider1",
    "is_aggressive": True,
    "destination": "SOR",
    "order_text": "Quote description",
    "quote_or_hedge": "Quote",
    "hedge_target_price": 150.00,
    "cash_exchange_trade_id": "CASH123",
    "timestamp": 1673881845.123,
    "build_id": "Build123",
    "build_name": "Release_1.0",
    "hide_duration": 0.5,
    "pop_ticks": "Tick123",
    "label": "comp_0: 0.0",
    "strategy": "Curve"
}

# Send the trade data
response = client.send_trade(trade_data)

# Print the response
print(response)
```

***

#### Response Schema

The `send_trade` method returns a structured response, adhering to the following schema:

| **Field Name** | **Data Type** | **Description**                                |
| -------------- | ------------- | ---------------------------------------------- |
| `status`       | `STRING`      | Indicates success or failure of the operation. |
| `message`      | `STRING`      | Additional information or status message.      |

#### Example Response

Successful API calls return a response similar to the following:

```json
{
    "status": "success",
    "message": "Trade successfully sent to Blockhouse API."
}
```

{% embed url="<https://www.loom.com/share/9e3457b05cf74cf3a5524cf756f8b80b?sid=7b6ee2c4-e874-4577-8c18-1b9d3b8780aa>" %}
