mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-19 06:48:06 +00:00
v4.1.0
This commit is contained in:
+55
-12
@@ -7,7 +7,7 @@
|
||||
The `Symbol` class represents a financial instrument (forex pair, stock, etc.) and provides
|
||||
methods for querying market data, selecting symbols, and retrieving rates and ticks.
|
||||
|
||||
Inherits from [`_Base`](../core/base.md).
|
||||
Inherits from [`_Base`](../core/base.md) and `SymbolInfo`.
|
||||
|
||||
## Classes
|
||||
|
||||
@@ -19,33 +19,76 @@ Inherits from [`_Base`](../core/base.md).
|
||||
|-----------|------|-------------|
|
||||
| `name` | `str` | Symbol name (e.g. `"EURUSD"`) |
|
||||
| `select` | `bool` | Whether the symbol is selected in Market Watch |
|
||||
| `tick` | `Tick` | Current price tick for the instrument |
|
||||
| `account` | `Account` | Trading account instance |
|
||||
| `initialized` | `bool` | Whether the symbol has been successfully initialized |
|
||||
|
||||
All `SymbolInfo` fields are available as instance attributes after initialisation.
|
||||
|
||||
#### Initialisation
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `init()` | Fetches symbol info from the terminal and sets all attributes |
|
||||
| Method | Returns | Description |
|
||||
|--------|---------|-------------|
|
||||
| `__init__(**kwargs)` | — | Requires `name` keyword argument |
|
||||
| `initialize()` | `bool` | Async. Fetches symbol info, tick, and selects the symbol |
|
||||
| `initialize_sync()` | `bool` | Synchronous version of `initialize()` |
|
||||
|
||||
#### Symbol Info
|
||||
|
||||
| Method | Returns | Description |
|
||||
|--------|---------|-------------|
|
||||
| `info()` | `SymbolInfo \| None` | Fetches and updates all symbol properties |
|
||||
| `info_tick(name="")` | `Tick \| None` | Gets the current price tick |
|
||||
| `symbol_select(enable=True)` | `bool` | Selects or removes the symbol from Market Watch |
|
||||
|
||||
#### Market Depth
|
||||
|
||||
| Method | Returns | Description |
|
||||
|--------|---------|-------------|
|
||||
| `book_add()` | `bool` | Subscribes to Market Depth events |
|
||||
| `book_get()` | `tuple[BookInfo, ...]` | Returns Market Depth entries |
|
||||
| `book_release()` | `bool` | Cancels Market Depth subscription |
|
||||
|
||||
#### Volume Helpers
|
||||
|
||||
| Method | Returns | Description |
|
||||
|--------|---------|-------------|
|
||||
| `check_volume(volume)` | `tuple[bool, float]` | Checks if volume is within min/max limits |
|
||||
| `round_off_volume(volume, round_down=False)` | `float` | Rounds volume to nearest volume step |
|
||||
| `compute_volume(*args, **kwargs)` | `float` | Returns `volume_min` (override in subclasses) |
|
||||
|
||||
#### Currency Conversion
|
||||
|
||||
| Method | Returns | Description |
|
||||
|--------|---------|-------------|
|
||||
| `amount_in_quote_currency(amount)` | `float` | Converts amount to the symbol's quote currency |
|
||||
| `convert_currency(amount, from_currency, to_currency)` | `float \| None` | Converts between two currencies via tick data |
|
||||
|
||||
#### Market Data
|
||||
|
||||
| Method | Returns | Description |
|
||||
|--------|---------|-------------|
|
||||
| `info_tick()` | `Tick` | Current tick for the symbol |
|
||||
| `copy_rates_from(timeframe, date_from, count)` | `Candles` | Historical bars from a date |
|
||||
| `copy_rates_from_pos(timeframe, start_pos, count)` | `Candles` | Historical bars from a position |
|
||||
| `copy_rates_range(timeframe, date_from, date_to)` | `Candles` | Historical bars in a range |
|
||||
| `copy_rates_from_pos(timeframe, count, start_position)` | `Candles` | Historical bars from a position |
|
||||
| `copy_rates_range(timeframe, date_from, date_to)` | `Candles` | Historical bars in a date range |
|
||||
| `copy_ticks_from(date_from, count, flags)` | `Ticks` | Historical ticks from a date |
|
||||
| `copy_ticks_range(date_from, date_to, flags)` | `Ticks` | Historical ticks in a range |
|
||||
| `copy_ticks_range(date_from, date_to, flags)` | `Ticks` | Historical ticks in a date range |
|
||||
|
||||
#### Helpers
|
||||
#### Properties
|
||||
|
||||
| Property | Returns | Description |
|
||||
|----------|---------|-------------|
|
||||
| `pip` | `float` | The pip size for the symbol |
|
||||
| `spread` | `float` | Current bid-ask spread |
|
||||
| `pip` | `float` | Pip size (`point * 10`) |
|
||||
|
||||
#### Overridable Methods
|
||||
|
||||
These methods raise `NotImplementedError` in the base `Symbol` and are meant to be implemented by subclasses such as [`ForexSymbol`](../contrib/symbols/forex_symbol.md).
|
||||
|
||||
| Method | Returns | Description |
|
||||
|--------|---------|-------------|
|
||||
| `compute_volume_sl(amount, price, sl, round_down)` | `float` | Compute volume from stop-loss distance |
|
||||
| `compute_volume_points(amount, points, round_down)` | `float` | Compute volume from point distance |
|
||||
|
||||
## Synchronous API
|
||||
|
||||
Available in `aiomql.lib.sync.symbol`.
|
||||
Available in `aiomql.lib.sync.symbol`. All async methods become synchronous with the same signatures.
|
||||
|
||||
Reference in New Issue
Block a user