Files

42 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2026-02-21 07:43:33 +01:00
# executor
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
`aiomql.lib.executor` — Strategy and task executor.
2024-02-12 21:09:28 +01:00
2026-02-21 07:43:33 +01:00
## Overview
2024-02-12 21:09:28 +01:00
2026-02-21 07:43:33 +01:00
The `Executor` manages the lifecycle of trading strategies and background tasks. It collects
functions, coroutines, and `Strategy` instances, then runs them via a `TaskQueue`.
2023-10-16 15:36:31 +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
### `Executor`
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
> Executes strategies and tasks using a `TaskQueue`.
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
| Attribute | Type | Description |
|-----------|------|-------------|
| `config` | `Config` | Global configuration |
| `task_queue` | `TaskQueue` | The underlying task queue |
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
#### Adding Tasks
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
| Method | Description |
|--------|-------------|
| `add_function(func, *args, **kwargs)` | Registers a regular callable |
| `add_coroutine(coro, *args, **kwargs)` | Registers an async coroutine |
| `add_strategy(strategy)` | Registers a `Strategy` instance |
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
#### Execution
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
| Method | Description |
|--------|-------------|
| `execute()` | Starts all registered tasks and strategies via the queue |
| `run_coroutine_task(coro, *args, **kwargs)` | Runs a single coroutine task |
#### Shutdown
| Method | Description |
|--------|-------------|
| `sigint_handle(sig, frame)` | Handles SIGINT for graceful shutdown |
| `exit()` | Sets the shutdown flag and stops the queue |