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

# Trade

> Trade the vault subaccount like any other subaccount.

There is no vault-specific trading & market data API. The vault **is** a subaccount owned by your
wallet, so you run your strategy on it with the normal trading methods — orders, RFQs,
transfers — passing the vault's subaccount id. The `managerId` you chose at
[creation](/vaults/create-a-vault) is the margin manager that governs what it can
trade.

<Check>All of the steps in this guide can be done through the UX or programmatically.</Check>

<CodeGroup>
  ```typescript TypeScript (SDK) theme={null}
  await client.orders.place({
    subaccountId: vaultId, // the vault subaccount — that's the whole trick
    instrumentName: 'ETH-PERP',
    direction: 'buy',
    amount: '2',
    limitPrice: '2500',
  });
  ```

  ```python Python (SDK) theme={null}
  import asyncio
  from decimal import Decimal

  from derive_py import WebSocketClient
  from derive_py.data_types import Direction


  async def main():
      client = WebSocketClient.from_env()
      await client.connect()

      vault = await client.fetch_subaccount(vault_id)

      await vault.orders.create(
          instrument_name="ETH-PERP",
          direction=Direction.buy,
          amount=Decimal("2"),
          limit_price=Decimal("2500"),
      )

      await client.disconnect()


  asyncio.run(main())
  ```

  ```rust Rust (SDK) theme={null}
  use bigdecimal::BigDecimal;
  use derive_rs::{
      Environment, WsClient,
      actions::OrderArgs,
      models::{Direction, OrderType, TimeInForce},
  };

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      // Bind the client to the VAULT subaccount — that's the whole trick.
      // derive-rs takes the subaccount at construction, not per order.
      let client = WsClient::new(
          Environment::Mainnet,
          Some(std::env::var("DERIVE_PRIVATE_KEY")?),
          Some(std::env::var("DERIVE_WALLET")?),
          Some(5678),
      )
      .await?;
      client.login().await?;

      let order = OrderArgs::builder()
          .instrument_name("ETH-PERP".to_string())
          .direction(Direction::Buy)
          .order_type(OrderType::Limit)
          .time_in_force(TimeInForce::Gtc)
          .amount(BigDecimal::from(2))
          .limit_price(BigDecimal::from(2500))
          .build();

      client.orders().place(order).await?;
      Ok(())
  }
  ```

  ```bash cURL theme={null}
  # Body nonce/signature: EIP-712 trade signing (see /action-signing).
  curl -X POST https://api.derive.xyz/v3/private/order \
    -H "Content-Type: application/json" \
    -H "X-DeriveWallet: $WALLET_ADDRESS" \
    -H "X-DeriveTimestamp: $TS" \
    -H "X-DeriveSignature: $SIG" \
    -d '{
      "subaccount_id": 42,
      "instrument_name": "ETH-PERP",
      "direction": "buy",
      "order_type": "limit",
      "time_in_force": "gtc",
      "amount": "2",
      "limit_price": "2500",
      "max_fee": "10",
      "mmp": false,
      "nonce": "1751558400000123000",
      "signature_expiry_sec": 1751558700,
      "signer": "0xCURATOR…",
      "signature": "0x…"
    }'
  ```
</CodeGroup>

## How trading moves the share price

NAV is the vault subaccount's live mark-to-market value from the risk engine, and
`share price ≈ NAV / total_shares`. As you trade on behalf of the vault, the vault
subaccount's position values change.

On each withdrawal, a management fee is charged, as well as a performance fee on any
profits since the last withdrawal. The share price is computed after these fees are applied.
The protocol ensures that deposits and withdrawals are never settled with a slippage to the
mtm beyond `maxSlippageBps` set at vault creation.

<CodeGroup>
  ```typescript TypeScript (SDK) theme={null}
  const { nav_usd, simulated_share_price_usd } = await client.vaults.getVault(
    vaultId
  );
  console.log(
    `NAV $${nav_usd ?? '?'}, share price $${simulated_share_price_usd ?? '?'}`
  );
  ```

  ```python Python (SDK) theme={null}
  import asyncio

  from derive_py import WebSocketClient


  async def main():
      client = WebSocketClient.from_env()
      await client.connect()

      vault = await client.vaults.get(vault_subaccount_id=vault_id)
      print(f"NAV ${vault.nav_usd or '?'}, share price ${vault.simulated_share_price_usd or '?'}")

      await client.disconnect()


  asyncio.run(main())
  ```

  ```rust Rust (SDK) theme={null}
  use derive_rs::{Environment, WsClient, models::GetVaultRequest};

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = WsClient::new_public(Environment::Mainnet).await?;

      let params = GetVaultRequest::builder().subaccount_id(5678).try_into()?;
      let vault = client.rpc().vault_shareholders().get_vault(params).await?;

      println!("{:?} {:?}", vault.nav_usd, vault.simulated_share_price_usd);
      Ok(())
  }
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.derive.xyz/v3/public/get_vault \
    -H "Content-Type: application/json" \
    -d '{ "subaccount_id": 42 }'
  ```
</CodeGroup>

Nothing is stored or settled per-trade — pricing is computed live, and hourly
snapshots accumulate in `getPerformanceHistory` for the track record shareholders see.

## Trading while requests are queued

Your positions and the [settle loop](/vaults/deposits-withdrawals) interact in three
ways worth engineering around:

**Redemption liquidity.** Withdrawals pay out in the vault's deposit asset. A vault that is fully deployed into
positions cannot settle a large burn — unwind first, then settle.

**Curator stake floor.** The protocol requires you to keep minimum skin-in-the-game. A withdrawal that would drop your
own stake below the deployment-set floor is rejected (`vault_curator_stake_below_min`, 18013) — you cannot drain your
seed while shareholders remain. See [Winddowns](/vaults/winddowns) for the exit order this implies.

<CardGroup cols={2}>
  <Card title="Order types" icon="list" href="/trading/order-types">
    Everything the normal trading API supports, the vault subaccount supports.
  </Card>

  <Card title="Process Deposits & Withdrawals" icon="rotate" href="/vaults/deposits-withdrawals">
    The settle loop your trading has to leave room for.
  </Card>
</CardGroup>


## Related topics

- [Trades by instrument](/api-reference/channels/tradesbyinstrument.md)
- [Subaccount trades](/api-reference/channels/subaccounttrades.md)
- [private/get_trade_history](/api-reference/history/privateget_trade_history.md)
