2026-02-21 07:43:33 +01:00
|
|
|
# trade_records
|
2024-05-05 00:08:57 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
`aiomql.lib.trade_records` — Trade record file 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 `TradeRecords` class manages trade record files in CSV, JSON, and SQL formats. It
|
|
|
|
|
provides methods for updating stored records with actual profit/loss data from completed
|
|
|
|
|
trades.
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
Inherits from [`_Base`](../core/base.md).
|
2024-05-05 00:08:57 +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
|
|
|
### `TradeRecords`
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
> Updates and manages trade record files.
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Attribute | Type | Description |
|
|
|
|
|
|-----------|------|-------------|
|
|
|
|
|
| `config` | `Config` | Global configuration |
|
2024-05-05 00:08:57 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
#### Methods
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Method | Description |
|
|
|
|
|
|--------|-------------|
|
|
|
|
|
| `update_rows(records_dir)` | Updates all record files in a directory |
|
|
|
|
|
| `update_row(file, row)` | Updates a single record row with actual P/L |
|
|
|
|
|
| `update_csv(file)` | Updates records in a CSV file |
|
|
|
|
|
| `update_json(file)` | Updates records in a JSON file |
|
|
|
|
|
| `update_sql()` | Updates records in the SQLite database |
|
|
|
|
|
| `get_actual_profit(order, symbol)` | Calculates actual P/L for a trade |
|
2024-11-10 12:25:50 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
#### Static Methods
|
2024-05-05 00:08:57 +01:00
|
|
|
|
2026-02-21 07:43:33 +01:00
|
|
|
| Method | Description |
|
|
|
|
|
|--------|-------------|
|
|
|
|
|
| `str_to_bool(val)` | Converts `"true"` / `"false"` strings to `bool` |
|