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.Closing a Position
To close a trade, you must reference the specificpositionId 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
UnitsToDeductparameter or set it tonull. 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)
Important Considerations
- Instrument IDs: You must know the numeric
instrumentIdbefore placing an order. Use the Search endpoint to resolve tickers (e.g., AAPL) to IDs. - Demo Environment: When testing, ensure you use the demo endpoints (e.g.,
/api/v1/trading/execution/demo/...) to avoid risking real capital. - Market Rates: It is recommended to check current rates using
GET /instruments/ratesbefore executing orders to ensure price accuracy.