Ticks¶
Raw tick data retrieval services.
Models¶
Tick¶
Tick
¶
Bases: BaseModel
A single price tick from the MT5 market data feed.
Wraps the raw tick struct returned by mt5.copy_ticks_from() and
mt5.copy_ticks_range(). Each tick represents one price update
event; not all fields are updated on every tick β the flags
bitmask indicates which prices changed.
| ATTRIBUTE | DESCRIPTION |
|---|---|
time |
Tick time as a Unix timestamp (seconds).
TYPE:
|
bid |
Current bid price.
TYPE:
|
ask |
Current ask price.
TYPE:
|
last |
Last trade price (exchange instruments only; 0.0 for Forex).
TYPE:
|
volume |
Last trade volume (exchange instruments only; 0 for Forex).
TYPE:
|
time_msc |
Tick time in milliseconds.
TYPE:
|
flags |
Bitmask of
TYPE:
|
volume_real |
Last trade volume as a fractional value.
TYPE:
|
has_last
property
¶
Whether this tick carries a last trade price update (TICK_FLAG_LAST).
Service¶
TickService¶
TickService
¶
Retrieves tick data from the MT5 terminal.
Wraps mt5.copy_ticks_from() and mt5.copy_ticks_range() via
call_mt5, parses the raw tick structs (which may arrive as either
attribute-bearing objects or plain dicts depending on the MT5 build)
into Tick models, and returns Result[list[Tick]].
Usage¶
from datetime import datetime, timezone
from syntiq_mt5 import constants
date_from = datetime(2024, 1, 1, 9, 0, tzinfo=timezone.utc)
# Get ticks from a date
res = mt5.copy_ticks_from(
"EURUSD",
date_from,
count=1000,
flags=constants.COPY_TICKS_ALL,
)
# Get ticks in a range
date_to = datetime(2024, 1, 1, 10, 0, tzinfo=timezone.utc)
res = mt5.copy_ticks_range(
"EURUSD",
date_from,
date_to,
flags=constants.COPY_TICKS_INFO,
)