# Your trading behaviour

`GET https://app.skylit.ai/api/nexus/v1/journal/behaviour`

API: Nexus.

How you manage trades on one of your accounts, all time: how much of each trade's best return you kept, how far winners ran after you sold, how much you gave back from the peak, how far trades went against you, how long you hold and how soon you first trim. The Journal's Behaviour panel, by key. Read only.

Each figure comes with the number of trades it was measured on. `captureRate` is a mean; `averageMissedUpside`, `averageApexGiveback` and `averageDrawdown` are the median trade's (the middle one, so one outlier can't move them). A figure with a sample of `0` is `null`: nothing was measured, which is not the same as a measured `0`. `avgHoldTime` and `avgTimeToFirstTrim` are `null` when there is nothing to average.

`account` is `main` (your simulated wallet) or `agent` (your bot's account); `port` is one of your ports. `meta` says which account and port were read.

```bash
curl -s "https://app.skylit.ai/api/nexus/v1/journal/behaviour?account=agent" \
  -H "Authorization: Bearer $SKYLIT_API_KEY"
```

## Authentication

Send your Skylit API key as a bearer token: `Authorization: Bearer <key>`. No other header is accepted.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `account` | query | string | no | Which of your accounts. Left out, your default account. (one of `main`, `agent`) |
| `port` | query | string | no | One of your port ids (GET /v1/trading/ports). An account sent beside it must agree with it. |

## Example request

```bash
curl "https://app.skylit.ai/api/nexus/v1/journal/behaviour" \
  -H "Authorization: Bearer $SKYLIT_API_KEY"
```

## Responses

### 200

Your behaviour figures on that account.

One closed trade on the bot's account:

```json
{
  "data": {
    "timeframe": "all-time",
    "captureRate": 30,
    "captureSample": 1,
    "averageMissedUpside": 15,
    "missedUpsideSample": 1,
    "averageApexGiveback": 70,
    "apexGivebackSample": 1,
    "averageDrawdown": 25,
    "drawdownSample": 1,
    "avgHoldTime": "1m",
    "avgTimeToFirstTrim": null
  },
  "meta": {
    "account": "agent",
    "port": null
  }
}
```

A port with no closed trades:

```json
{
  "data": {
    "timeframe": "all-time",
    "captureRate": null,
    "captureSample": 0,
    "averageMissedUpside": null,
    "missedUpsideSample": 0,
    "averageApexGiveback": null,
    "apexGivebackSample": 0,
    "averageDrawdown": null,
    "drawdownSample": 0,
    "avgHoldTime": null,
    "avgTimeToFirstTrim": null
  },
  "meta": {
    "account": "agent",
    "port": "7d1c0e7e-0000-4000-8000-000000000000"
  }
}
```

### 400

`bad_request`: account is not main or agent, or it does not agree with the port.

### 401

Missing or invalid key.

### 404

`port_not_found`: that port is not one of yours. `user_not_found`: this account has not used Nexus yet.

### 503

`behaviour_unavailable`: not available on this server yet.
