2026-02-21 07:43:33 +01:00
|
|
|
# ram
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
`aiomql.lib.ram` — Risk Assessment and Money management.
|
2024-02-12 21:09:28 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
## Overview
|
2024-05-05 00:08:57 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
The `RAM` class calculates position sizes based on risk parameters and account balance.
|
|
|
|
|
It checks open positions against configured limits and determines the volume for new trades.
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
Inherits from [`_Base`](../core/base.md).
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
## Classes
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
### `RAM`
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
> Calculates trade volumes using risk-based sizing.
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Attribute | Type | Default | Description |
|
|
|
|
|
|-----------|------|---------|-------------|
|
|
|
|
|
| `risk_to_reward` | `float` | `2` | Risk-to-reward ratio |
|
|
|
|
|
| `risk` | `float` | `0.01` | Risk per trade as a fraction of balance |
|
|
|
|
|
| `min_amount` | `float` | `0` | Minimum trade amount in account currency |
|
|
|
|
|
| `max_amount` | `float` | `0` | Maximum trade amount (0 = unlimited) |
|
|
|
|
|
| `max_open_positions` | `int` | `0` | Maximum concurrent positions (0 = unlimited) |
|
|
|
|
|
| `fixed_amount` | `float` | `0` | Fixed trade amount (overrides risk calculation) |
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
#### Methods
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Method | Returns | Description |
|
|
|
|
|
|--------|---------|-------------|
|
|
|
|
|
| `check_open_positions()` | `bool` | `True` if under the open-position limit |
|
|
|
|
|
| `get_amount()` | `float` | Calculates the trade amount based on risk parameters |
|
|
|
|
|
| `calc_volume(symbol, amount, pips, …)` | `float` | Calculates lot size from amount and stop distance |
|
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.ram`.
|