# Data Types (/scripting-v2/data-types)



Python V2 receives normal dictionaries and lists:

```python
candles = history.source("btc@candles@binancef:timeframe=60")
book = history.source("btc@orderbook@bulkf:depth=20", 0)
trade = history.source("btc@trades@bulkf", 0)
oi = history.source("btc@oi@binancef@mmt:timeframe=60", 0)
```

Without an index, records are ordered oldest to newest. With an index, `0` is newest and `1` is previous.

The hook context describes the source rather than duplicating its record:

```python
ctx.source
ctx.source_type
ctx.provider
ctx.exchange
ctx.symbol
ctx.source_configs
ctx.positions().open
```

## Open Positions [#open-positions]

`ctx.positions().open` contains main-account positions for declared symbols. Pass a configured name to read a subaccount instead:

```python
ctx.positions("trading-2").open
```

Analysis-only jobs return an empty list.

Common fields:

| Field            | Meaning                           |
| ---------------- | --------------------------------- |
| `id`             | Stable local position identity.   |
| `symbol`         | Normalized symbol.                |
| `side`           | `long` or `short`.                |
| `entry_price`    | Average entry price.              |
| `mark_price`     | Current reference price.          |
| `notional`       | Current notional value.           |
| `margin`         | Allocated margin.                 |
| `leverage`       | Position leverage for perpetuals. |
| `qty`            | Base quantity.                    |
| `unrealized_pnl` | Current unrealized PnL.           |
| `realized_pnl`   | Realized PnL when available.      |
| `fees`           | Accrued fees when available.      |
| `funding`        | Accrued funding when available.   |

Backtest positions can also include simulated timestamps, protection prices, `events_held`, and `reason`.

Record references:

* [Candles](/scripting-v2/data-types/candles)
* [Orderbook](/scripting-v2/data-types/orderbook)
* [Trades](/scripting-v2/data-types/trades)
* [Volume Delta](/scripting-v2/data-types/vd)
* [Open Interest](/scripting-v2/data-types/oi)
* [Volumes](/scripting-v2/data-types/volumes)
