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

# openTrade

> Open market, limit, or stop trades on Ostium with the Builder SDK.

```ts theme={null}
const result = await client.openTrade({
  pairId: 0,
  buy: true,
  price: '65000',
  collateral: '100',
  leverage: '10',
  type: OrderType.Market,
});
```

Override the client-level builder fee for one trade:

```ts theme={null}
const result = await client.openTrade({
  pairId: 0,
  buy: true,
  price: '65000',
  collateral: '100',
  leverage: '10',
  type: OrderType.Market,
  builder: {
    address: '0xBuilderAddress',
    feeBps: 20,
  },
});
```

## Important behavior

* `pairId` comes from `getPairs()`
* collateral has a fixed minimum open size of `MIN_OPEN_SIZE_USD` (`5`)
* market orders respect slippage
* limit and stop orders do not use slippage
* the SDK does not cap leverage locally; contract-side limits are authoritative
* `isDayTrade` may be required when leverage exceeds a pair's overnight limit
* `builder.address` and `builder.feeBps` can be overridden per trade; omitted fields fall back to the client builder config
* successful SDK submissions to the Trading contract report `{ hash }` to `POST /v1/trade` in the background for attribution

## Parameters

```ts theme={null}
interface OpenTradeParams {
  pairId: string | number;
  buy: boolean;
  price: string;
  collateral: string;
  leverage: string;
  type: OrderType;
  takeProfit?: string;
  stopLoss?: string;
  slippage?: number;
  isDayTrade?: boolean;
  builder?: {
    address?: `0x${string}`;
    feeBps?: number;
  };
}
```

## Response schema

```ts theme={null}
interface Response {
  txHash: `0x${string}`;
  smartAccountAddress?: `0x${string}`;
}
```
