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

# Horizon + Robinhood

> Trade crypto on Robinhood for commission-free execution alongside prediction markets.

[Robinhood](https://robinhood.com) offers commission-free crypto trading. Horizon connects to Robinhood's crypto trading API for spot execution alongside prediction market strategies.

## Quick Setup

```python theme={null}
hz.run(
    name="rh_crypto",
    exchange=hz.Robinhood(api_key="..."),
    mode="live",
    ...
)
```

## Credentials

<Tabs>
  <Tab title="Explicit">
    ```python theme={null}
    hz.Robinhood(api_key="rh_xxxxxxxx...")
    ```
  </Tab>

  <Tab title="Environment variables">
    ```bash theme={null}
    export ROBINHOOD_API_KEY="rh_xxxxxxxx..."
    ```

    ```python theme={null}
    hz.Robinhood()  # reads from env
    ```
  </Tab>
</Tabs>

## Robinhood Configuration

```python theme={null}
@dataclass
class Robinhood:
    api_key: str | None = None
    api_url: str = "https://trading.robinhood.com/api/v1"
```

| Field     | Default                                | Description                                  |
| --------- | -------------------------------------- | -------------------------------------------- |
| `api_key` | `None`                                 | Robinhood API key (env: `ROBINHOOD_API_KEY`) |
| `api_url` | `https://trading.robinhood.com/api/v1` | Override API base URL                        |

## Authentication

Robinhood uses Bearer token auth:

* `Authorization: Bearer {api_key}`

## Market Data Feed

Robinhood uses REST polling (no public WebSocket):

```python theme={null}
hz.run(
    feeds={
        "btc": hz.RobinhoodFeed(symbols=["BTC-USD"]),
        "eth": hz.RobinhoodFeed(symbols=["ETH-USD"], interval=3.0),
    },
    ...
)
```

The feed polls Robinhood's quote endpoint at the configured interval for each symbol.

| Field      | Type        | Default  | Description                                |
| ---------- | ----------- | -------- | ------------------------------------------ |
| `symbols`  | `list[str]` | required | Crypto pairs to poll (e.g., `["BTC-USD"]`) |
| `api_key`  | `str`       | `None`   | Override API key (defaults to env vars)    |
| `interval` | `float`     | `5.0`    | Polling interval in seconds                |

## Symbol Mapping

Robinhood uses `BASE-QUOTE` format for crypto:

```python theme={null}
market = hz.Market(id="BTC-USD", name="Bitcoin / USD")
```

| Horizon Field             | Robinhood Field | Notes                      |
| ------------------------- | --------------- | -------------------------- |
| `OrderRequest.market_id`  | `symbol`        | e.g., "BTC-USD", "ETH-USD" |
| `OrderRequest.order_side` | `side`          | `"buy"` or `"sell"`        |
| `OrderRequest.price`      | `limit_price`   | Limit order price          |
| `OrderRequest.size`       | `quantity`      | Base currency quantity     |

<Note>
  Robinhood uses `Side.Long` for all positions. Prediction market concepts like `Side.Yes` / `Side.No` do not apply to crypto orders.
</Note>

## Multi-Exchange

```python theme={null}
hz.run(
    name="rh_hedge",
    exchange=[
        hz.Kalshi(),       # prediction market
        hz.Robinhood(),    # crypto hedge
    ],
    feeds={
        "btc_event": hz.KalshiBook("KXBTC-25MAR15"),
        "btc_spot": hz.RobinhoodFeed(symbols=["BTC-USD"]),
    },
    pipeline=[my_strategy],
)
```

## Getting API Keys

1. Open the [Robinhood app](https://robinhood.com) or website
2. Navigate to **Account** > **Settings** > **API Trading**
3. Generate a new API key
4. Store the key securely
