> ## Documentation Index
> Fetch the complete documentation index at: https://docs.allium.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Trades

> Raw trade records.

The `lighter_robinhood.raw.trades` table contains raw trade records.

## Table Columns

**Unique key:** `timestamp`, `trade_id`

| Column Name                            | Data Type          | Description                                                |
| -------------------------------------- | ------------------ | ---------------------------------------------------------- |
| `trade_id`                             | `NUMBER(38,0)`     | Unique identifier for the trade.                           |
| `tx_hash`                              | `VARCHAR`          | On-chain transaction hash.                                 |
| `type`                                 | `VARCHAR`          | Trade event type: `trade`, `liquidation`, or `deleverage`. |
| `market_id`                            | `NUMBER(38,0)`     | Market this trade belongs to.                              |
| `size`                                 | `VARCHAR`          | Trade size in base asset units.                            |
| `price`                                | `VARCHAR`          | Execution price.                                           |
| `usd_amount`                           | `VARCHAR`          | USD value of the trade.                                    |
| `ask_id`                               | `NUMBER(38,0)`     | Order ID of the ask side.                                  |
| `bid_id`                               | `NUMBER(38,0)`     | Order ID of the bid side.                                  |
| `ask_client_id`                        | `NUMBER(38,0)`     | Client-assigned order ID for ask side.                     |
| `bid_client_id`                        | `NUMBER(38,0)`     | Client-assigned order ID for bid side.                     |
| `ask_account_id`                       | `NUMBER(38,0)`     | Account ID of the ask (sell) side.                         |
| `bid_account_id`                       | `NUMBER(38,0)`     | Account ID of the bid (buy) side.                          |
| `is_maker_ask`                         | `BOOLEAN`          | True if the maker is on the ask side.                      |
| `block_height`                         | `NUMBER(38,0)`     | Block height of the trade.                                 |
| `timestamp`                            | `TIMESTAMP_NTZ(9)` | UTC timestamp of the trade.                                |
| `taker_position_size_before`           | `VARCHAR`          | Taker's position size before this trade.                   |
| `taker_entry_quote_before`             | `VARCHAR`          | Taker's entry quote before this trade.                     |
| `taker_initial_margin_fraction_before` | `NUMBER(38,0)`     | Taker's initial margin fraction before this trade.         |
| `maker_fee`                            | `NUMBER(38,0)`     | Maker fee in ppm.                                          |
| `maker_position_size_before`           | `VARCHAR`          | Maker's position size before this trade.                   |
| `maker_entry_quote_before`             | `VARCHAR`          | Maker's entry quote before this trade.                     |
| `maker_initial_margin_fraction_before` | `NUMBER(38,0)`     | Maker's initial margin fraction before this trade.         |
| `transaction_time`                     | `NUMBER(38,0)`     | Unix transaction timestamp in microseconds.                |
| `_created_at`                          | `TIMESTAMP_NTZ(9)` | Timestamp when the row was first recorded.                 |
| `_updated_at`                          | `TIMESTAMP_NTZ(9)` | Timestamp when the row was last updated.                   |
| `transaction_time_ts`                  | `TIMESTAMP_NTZ(9)` | UTC transaction timestamp.                                 |
| `taker_fee`                            | `NUMBER(38,0)`     | Taker fee in ppm.                                          |
| `taker_position_sign_changed`          | `BOOLEAN`          | Whether taker's position sign changed.                     |
| `maker_position_sign_changed`          | `BOOLEAN`          | Whether maker's position sign changed.                     |

### Sample Query

```sql theme={null}
SELECT
    trade_id,
    timestamp,
    market_id,
    type,
    size,
    price,
    usd_amount
FROM lighter_robinhood.raw.trades
WHERE timestamp >= CURRENT_DATE - 1
ORDER BY timestamp DESC
LIMIT 100;
```
