Skip to main content
Once you have resolved your target asset’s instrumentId, you can begin executing trades. The eToro API separates trading logic into two distinct phases: opening a new position and closing an existing one.

Opening a Position

There are two ways to open a market position: by specifying the cash amount you wish to invest, or by specifying the number of units you wish to buy.

Method 1: By Amount (Cash)

This is the most common method for dollar-cost averaging or fixed-budget strategies. You specify the cash value (e.g., $1,000) and the API calculates the units based on the current market price. Endpoint: POST /api/v1/trading/execution/market-open-orders/by-amount
Note: You can apply additional settings such as leverage, stop-loss, and take-profit during this request.

Method 2: By Units (Volume)

Use this method when you need to control the exact volume of the asset (e.g., buying exactly 1.5 Bitcoin or 10 shares of Apple). Endpoint: POST /api/v1/trading/execution/market-open-orders/by-units

Example Request (Open by Amount)

The following examples demonstrate the full flow: Search for ‘BTC’ to get its ID, then Buy $1,000 worth of it.
# 1. Search for the Instrument ID (Symbol: BTC)
# Returns a JSON object containing the "InstrumentID" (e.g., 100000)
curl -X GET "https://public-api.etoro.com/api/v1/market-data/search?internalSymbolFull=BTC" \
  -H "x-api-key: <YOUR_PUBLIC_KEY>" \
  -H "x-user-key: <YOUR_USER_KEY>" \
  -H "x-request-id: <UUID>"

# 2. Use the ID from step 1 (e.g., 100000) to place the order
curl -X POST "https://public-api.etoro.com/api/v1/trading/execution/market-open-orders/by-amount" \
  -H "x-api-key: <YOUR_PUBLIC_KEY>" \
  -H "x-user-key: <YOUR_USER_KEY>" \
  -H "x-request-id: <UUID>" \
  -H "Content-Type: application/json" \
  -d '{
        "InstrumentId": 100000,
        "Amount": 1000,
        "Leverage": 1,
        "IsBuy": true
      }'

Closing a Position

To close a trade, you must reference the specific positionId of the open position. You cannot simply “sell” the instrument; you must close the specific line item in your portfolio. Endpoint: POST /api/v1/trading/execution/market-close-orders/positions/{positionId}

Full vs. Partial Close

You can choose to close the entire position or just a portion of it.
  • Full Close: Omit the UnitsToDeduct parameter or set it to null. This liquidates the entire position.
  • Partial Close: Provide a specific value for UnitsToDeduct. Only that portion of the position will be closed, leaving the remainder active.

Example Request (Close Position)

# Closing position ID 12345678
curl -X POST "https://public-api.etoro.com/api/v1/trading/execution/market-close-orders/positions/12345678" \
  -H "x-api-key: <YOUR_PUBLIC_KEY>" \
  -H "x-user-key: <YOUR_USER_KEY>" \
  -H "x-request-id: <UUID>" \
  -H "Content-Type: application/json" \
  -d '{
        "UnitsToDeduct": null
      }'

Important Considerations

  1. Instrument IDs: You must know the numeric instrumentId before placing an order. Use the Search endpoint to resolve tickers (e.g., AAPL) to IDs.
  2. Demo Environment: When testing, ensure you use the demo endpoints (e.g., /api/v1/trading/execution/demo/...) to avoid risking real capital.
  3. Market Rates: It is recommended to check current rates using GET /instruments/rates before executing orders to ensure price accuracy.