# Placing trades

_Source: https://docs.neurotrading.io/en/api/trading_

You trade by telling the API **which of your wallets**, **which token** and **how much**. The platform finds the venue, builds and signs the transaction with that wallet, and submits it — the same path as pressing **Buy** on the dashboard. You never sign anything yourself, and there is no endpoint for submitting a transaction you signed elsewhere.

The network follows the wallet: a Solana wallet trades on Solana, a Robinhood Chain wallet on Robinhood Chain. Get your wallet addresses from `GET /wallets` ([Authentication](/api/authentication#finding-your-wallets)).

> **Warning**
>
> Every call here moves real funds unless the account is in [Paper Trading](/api/paper-trading). Test in Paper Trading first, and in your script check `GET /demo/status` before you trade, so you always know which mode you are in.

## Buying

```bash
curl -s -X POST "$NEURO_API/tradings/buy" \
  -H "Authorization: Bearer $NEURO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "walletAddress": "7xKX...yourWallet",
        "tokenAddress": "Bp8m...pump",
        "amount": 0.1,
        "slippage": 15
      }'
```

| Field | Type | Notes |
| --- | --- | --- |
| `walletAddress` | string | Required. One of your wallets. |
| `tokenAddress` | string | Required. The token to buy. |
| `amount` | number | Required. How much to **spend**: SOL on Solana (at least 0.00001), or the network's coin on an EVM network (ETH on Robinhood Chain). |
| `slippage` | number | Percent, 0–100. Defaults to your account setting. |
| `antiMev` | boolean | Solana only. `true` sends through a Jito bundle with a tip, which protects against sandwich attacks; `false` pays a priority fee instead. Defaults to your account setting. |
| `jitoTip` | number | Solana only, in **SOL**, used when `antiMev` is `true`. At most 0.1. A tip below the relay's minimum is raised to it. Defaults to your account setting. |
| `priorityLevel` | `"Medium"` \| `"High"` \| `"VeryHigh"` | Solana only, used when `antiMev` is `false`. Defaults to your account setting. |
| `shouldValidateBalance` | boolean | Check the wallet can afford the trade before submitting. |

Anything you leave out comes from your account's trading settings (**Settings → Fee & Slippage** on the dashboard, `config.trading` on `GET /user`). Values you send apply to this trade only and do not change your settings.

## Selling

A sell is sized as a **percentage of what the wallet holds** of that token, so you do not need to know the exact balance:

```bash
curl -s -X POST "$NEURO_API/tradings/sell" \
  -H "Authorization: Bearer $NEURO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "walletAddress": "7xKX...yourWallet",
        "tokenAddress": "Bp8m...pump",
        "amount": 50
      }'
```

| Field | Type | Notes |
| --- | --- | --- |
| `walletAddress`, `tokenAddress` | string | Required. |
| `amount` | number | Required. Percent of the holding to sell, 1–100. |
| `slippage`, `antiMev`, `jitoTip`, `priorityLevel`, `shouldValidateBalance` | | As for buying. |

Selling 100% also cancels that token's take-profit, stop-loss and other pending orders.

> **Info**
>
> On EVM networks, a token near the end of its launch curve briefly cannot be sold while it moves to a pool. The [price stream](/api/price-stream) tells you when: don't send a sell while `sellsClosed` is `true`.

## Selling everything

`POST /tradings/sell-all` sells 100% of every token held across your active wallets, as a background job:

```bash
curl -s -X POST "$NEURO_API/tradings/sell-all" \
  -H "Authorization: Bearer $NEURO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "slippage": 20 }'
# → { "data": { "jobId": "0f5c2a6e-..." } }
```

It accepts `slippage`, `priorityLevel` and `shouldValidateBalance`. Follow the job with `GET /tradings/sell-all//status`, which reports `status` (`pending`, `running`, `completed`, `failed`), `total`, `processed`, and the `results` and `errors` per position. `POST /tradings/sell-all//cancel` stops it before the remaining sells go out.

## What comes back

### Solana

A Solana buy or sell answers **as soon as the transaction is submitted**, not when it is confirmed:

```json
{
  "code": 200,
  "message": "Success",
  "data": {
    "txId": "5h3Y...signature",
    "tokenSymbol": "EXM",
    "solAmount": 0.1,
    "tokenAmount": 2427184.4,
    "marketCap": 7360.11
  }
}
```

`txId` is the transaction signature. The amounts are **estimates** made at submission. A sell also returns `amountSoldInPercentage`, and where available `usdValue` and `solPriceInUsd`.

> **Warning**
>
> A `200` means the transaction was sent, **not** that it succeeded. It can still fail on-chain — for example, when the price moves past your slippage. Always confirm it.

To confirm, poll `GET /tradings//status` every second or two:

```json
{ "code": 200, "message": "Success", "data": { "status": "pending" } }
```

`status` is `pending`, `success` or `failed`. A failed transaction also carries `onChainError`. For the settled amounts — what you actually paid and received, net of fees — read the trade from your history once it is confirmed.

### EVM networks

An EVM buy or sell waits for the network to confirm, and returns the result under `data.evm`:

```json
{
  "code": 200,
  "message": "Success",
  "data": {
    "txId": "0x9a1f...",
    "tokenSymbol": "EXM",
    "evm": {
      "chainId": 4663,
      "side": "BUY",
      "txHash": "0x9a1f...",
      "txHashes": ["0x9a1f..."],
      "tokenAddress": "0x6e2c...a41f",
      "tokenDecimals": 18,
      "tokenAmount": "43290043290043290043290",
      "payAsset": { "address": "0x...", "symbol": "ETH", "decimals": 18, "isNative": true },
      "payAmount": "100000000000000000",
      "platformFee": "1000000000000000",
      "referralFee": "0",
      "gasFee": "21000000000000",
      "priceUsd": 0.0000071
    }
  }
}
```

EVM amounts are **strings in base units** — divide by `10^tokenDecimals` (or `10^payAsset.decimals`) for whole units. `payAsset` names what was paid; it is not always ETH.

If the network has not confirmed by the end of the request, `evm.status` is `"PENDING"` and the amounts are `"0"`. The trade settles in the background; check it in your EVM trade history.

## Trade history

```bash
# Solana trades, newest first
curl -s "$NEURO_API/tradings?page=1&limit=20&walletAddress=7xKX...yourWallet" \
  -H "Authorization: Bearer $NEURO_TOKEN"

# EVM trades on Robinhood Chain
curl -s "$NEURO_API/tradings/evm/trades?chainId=4663" \
  -H "Authorization: Bearer $NEURO_TOKEN"
```

`GET /tradings` filters by `type` (`BUY` or `SELL`), `walletAddress`, `page`, `limit` and `excludeFailed=true`. Each row has `txHash`, `status` (`PENDING`, `COMPLETED` or `FAILED`), `amount` (SOL), `tokenAmount`, `price` and, for a failed trade, `failedReason`.

`GET /tradings` answers `{ data, total, totalPages }`.

## Positions and PnL

| What | Endpoint |
| --- | --- |
| Solana PnL per token in one wallet | `GET /wallets/{walletId}/tokens-pnl?page=1&limit=20`, where `walletId` is the wallet's `_id` from `GET /wallets` |
| Solana open positions | `GET /trading-summary/positions?page=1&limit=20` |
| Realized PnL and volume, last 24 hours | `GET /realized-pnl` |
| One EVM position | `GET /tradings/evm/position?chainId=4663&walletAddress=…&tokenAddress=…` |
| EVM totals, last 24 hours | `GET /tradings/evm/summary?chainId=4663` |

Each `tokens-pnl` row has the token's `balance`, its value now (`balanceInSOL`, `balanceInUSD`), what you put in and took out (`solSpent`, `solEarned`), and `pnlInSOL`, `pnlInUSD` and `pnlPercentage`. A position you have just bought shows a small loss straight away: it is valued at what selling it now would return, after price impact.

The EVM position has `realizedPnl` and `unrealizedPnl` in base units of `payAsset`, with USD equivalents and `pnlPercent`.

`/realized-pnl` and the EVM summary count **closed** positions only. Half of a position that you have sold shows in the per-token and per-position PnL, not in these totals, until the position is fully closed.

## Common errors

| Error | What to do |
| --- | --- |
| `400` `Amount must be greater than or equals to 0.00001` | Spend more. |
| `400` `Slippage must be between 0 and 100` | Send slippage as a percent. |
| `400` `Jito tip cannot be greater than 0.1` | `jitoTip` is in SOL, not lamports. |
| `400` ` Balance's not enough` | Top up the wallet, or buy less. On EVM networks, leave room for gas. |
| `400` `You don't have any balance of this token…` | A sell for a token this wallet does not hold. |
| `404` `Wallet not found` | The address is not one of your wallets in the current mode. Fetch `GET /wallets` again — paper and real wallets differ. |
| `401` | The session token is missing or expired. |
| `5xx` or a timeout on a buy | Do **not** retry straight away. Check `GET /tradings` first: the buy may have gone through. |

## Fees

A real trade pays the platform's trading fee for your plan, plus network costs — the priority fee or Jito tip on Solana, gas on EVM networks. Trades placed through the API are charged the same as trades placed by hand. Paper trades pay nothing.
