> For AI agents: the complete documentation index is available at [llms.txt](https://docs.snaptrade.com/llms.txt), and the full documentation text is available at [llms-full.txt](https://docs.snaptrade.com/llms-full.txt). Markdown versions of documentation pages are available by appending .md to the URL path.

# Preview crypto order

POST https://api.snaptrade.com/accounts/{accountId}/trading/crypto/preview

Previews an order using the specified account.


Reference: https://docs.snaptrade.com/reference/Trading/Trading_previewCryptoOrder

## Code Examples

### TypeScript

```typescript

import {
  Snaptrade,
  SnaptradeAuth,
} from "snaptrade-typescript-sdk";

const snaptrade = new Snaptrade({
  auth: SnaptradeAuth.commercialApiKey({
    consumerKey: "CONSUMER_KEY",
    clientId: "CLIENT_ID",
  }),
});

const response =
  await snaptrade.trading.previewCryptoOrder({
    accountId:
      "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    userId: "USER_ID",
    userSecret: "XXXXXXXXXXX",
    instrument: { symbol: "BTC", type: "TYPE" },
    side: "SIDE",
    type: "TYPE",
    time_in_force: "TIME_IN_FORCE",
    amount: "123.45",
  });
console.log(response.data);

```

### Python

```python

from pprint import pprint
from snaptrade_client import SnapTrade, SnapTradeAuth

snaptrade = SnapTrade(
    auth=SnapTradeAuth.commercial_api_key(
        consumer_key="CONSUMER_KEY",
        client_id="CLIENT_ID",
    )
)

response = snaptrade.trading.preview_crypto_order(
    account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
    instrument={
        "symbol": "BTC",
        "type": "TYPE"
    },
    side="SIDE",
    type="TYPE",
    time_in_force="TIME_IN_FORCE",
    amount="123.45",
    user_id="USER_ID",
    user_secret="XXXXXXXXXXX"
)
pprint(response.body)

```

## OpenAPI Specification

```yaml

openapi: 3.0.0
info:
  description: Connect brokerage accounts to your app for live positions and trading
  version: 1.0.0
  title: SnapTrade
  termsOfService: N/A
  contact:
    email: api@snaptrade.com
  x-konfig-ignore:
    potential-incorrect-type: true
  x-readme:
    explorer-enabled: false
paths:
  /accounts/{accountId}/trading/crypto/preview:
    post:
      tags:
        - Trading
      summary: Preview crypto order
      description: |
        Previews an order using the specified account.
      operationId: Trading_previewCryptoOrder
      parameters:
        - in: path
          required: true
          name: accountId
          schema:
            description: >-
              Unique identifier for the connected brokerage account. This is the
              UUID used to reference the account in SnapTrade.
            type: string
            format: uuid
            example: 917c8734-8470-4a3e-a18f-57c3f2ee6631
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - instrument
                - side
                - type
                - time_in_force
                - amount
              properties:
                instrument:
                  type: object
                  required:
                    - symbol
                    - type
                  properties:
                    symbol:
                      description: The instrument's trading ticker symbol
                      type: string
                      example: BTC
                    type:
                      description: The instrument's type
                      type: string
                      enum:
                        - CRYPTOCURRENCY
                        - CRYPTOCURRENCY_PAIR
                side:
                  description: >-
                    The action describes the intent or side of a trade. This is
                    either `BUY` or `SELL`.
                  type: string
                  enum:
                    - BUY
                    - SELL
                type:
                  type: string
                  enum:
                    - MARKET
                    - LIMIT
                    - STOP_LOSS_MARKET
                    - STOP_LOSS_LIMIT
                    - TAKE_PROFIT_MARKET
                    - TAKE_PROFIT_LIMIT
                  description: The type of order to place.
                time_in_force:
                  description: >
                    The Time in Force type for the order. This field indicates
                    how long the order will remain active before it is executed
                    or expires.
                      - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled.
                      - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely.
                      - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
                      - `GTD` - Good Til Date. The order is valid until the specified date.
                  type: string
                  enum:
                    - GTC
                    - FOK
                    - IOC
                    - GTD
                amount:
                  description: The amount of the base currency to buy or sell.
                  type: string
                  format: decimal
                  example: '123.45'
                limit_price:
                  description: >-
                    The limit price. Required if the order type is `LIMIT`,
                    `STOP_LOSS_LIMIT` or `TAKE_PROFIT_LIMIT`.
                  type: string
                  format: decimal
                  example: '123.45'
                stop_price:
                  description: >-
                    The stop price. Required if the order type is
                    `STOP_LOSS_MARKET`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT_MARKET`
                    or `TAKE_PROFIT_LIMIT`.
                  type: string
                  format: decimal
                  example: '123.45'
                post_only:
                  type: boolean
                  example: false
                  description: >
                    Valid and required only for order type `LIMIT`. If true
                    orders that would be filled immediately are rejected to
                    avoid incurring TAKER fees.
                expiration_date:
                  type: string
                  format: date-time
                  example: '2024-01-01T00:00:00.000Z'
                  description: >-
                    The expiration date of the order. Required if the
                    time_in_force is `GTD`.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                description: Preview of an order.
                type: object
                properties:
                  estimated_fee:
                    type: object
                    required:
                      - currency
                      - amount
                    description: The estimated order fee.
                    properties:
                      currency:
                        description: >-
                          Symbol to identify a cryptocurrency or fiat currency
                          on a crypto exchange. Fiat currencies symbols are
                          ISO-4217 codes.
                        type: string
                        example: BTC
                      amount:
                        type: string
                        format: decimal
                        example: '123.45'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                description: Example for failed request response
                type: object
                properties:
                  default_detail:
                    example: Unable to verify data sent
                  default_code:
                    example: 1076
        '500':
          description: Unexpected Error
      security:
        - PartnerSignature: []
          PartnerClientId: []
          PartnerTimestamp: []
          userId: []
          userSecret: []
        - PersonalSignature: []
          PersonalClientId: []
          PersonalTimestamp: []

```