2026-02-21 07:43:33 +01:00
|
|
|
# trader
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
`aiomql.lib.trader` — Trader base class for order management.
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
## Overview
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
The `Trader` class is the base for creating and managing trade orders. It brings together
|
|
|
|
|
`Symbol`, `RAM`, `Order`, and `Result` to provide a complete workflow for placing trades
|
|
|
|
|
with risk management and result recording.
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
Inherits from [`_Base`](../core/base.md).
|
2024-01-01 05:25:41 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
## Classes
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
### `Trader`
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
> Base class for placing risk-managed trades.
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Attribute | Type | Description |
|
|
|
|
|
|-----------|------|-------------|
|
|
|
|
|
| `symbol` | `Symbol` | The trading instrument |
|
|
|
|
|
| `ram` | `RAM` | Risk Assessment and Money manager |
|
|
|
|
|
| `order` | `Order` | The current trade order |
|
|
|
|
|
| `result` | `Result` | Trade result recorder |
|
|
|
|
|
| `parameters` | `dict` | Strategy parameters to record |
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
#### Lifecycle
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Method | Description |
|
|
|
|
|
|--------|-------------|
|
|
|
|
|
| `__init__(symbol, ram, params, …)` | Initialises with a symbol and risk parameters |
|
|
|
|
|
| `create_order(order_type, …)` | Creates an `Order` with calculated volume and stops |
|
|
|
|
|
| `set_stop_levels(order_type, sl, tp)` | Sets stop loss and take profit prices |
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
#### Trade Placement
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Method | Description |
|
|
|
|
|
|--------|-------------|
|
|
|
|
|
| `place_trade(*, order_type, sl, tp, …)` | **Abstract** — subclasses implement to place trades |
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
## Synchronous API
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
Available in `aiomql.lib.sync.trader`.
|