forked from Joaopeuko/Mql5-Python-Integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtick.py
74 lines (58 loc) · 1.71 KB
/
tick.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from typing import Optional
import MetaTrader5 as Mt5
class Tick:
"""Represents real-time tick data for a financial instrument."""
def __init__(self, symbol: str) -> None:
"""
Initializes a Tick object.
Args:
symbol (str): The financial instrument symbol.
Returns:
None
"""
tick_info = Mt5.symbol_info_tick(symbol)
self._symbol = symbol
self._time = tick_info.time
self._bid = tick_info.bid
self._ask = tick_info.ask
self._last = tick_info.last
self._volume = tick_info.volume
self._time_msc = tick_info.time_msc
self._flags = tick_info.flags
self._volume_real = tick_info.volume_real
@property
def symbol(self) -> str:
"""The financial instrument symbol."""
return self._symbol
@property
def time(self) -> int:
"""Timestamp of the tick data."""
return self._time
@property
def bid(self) -> float:
"""Current bid price."""
return self._bid
@property
def ask(self) -> float:
"""Current ask price."""
return self._ask
@property
def last(self) -> float:
"""Last traded price."""
return self._last
@property
def volume(self) -> int:
"""Tick volume."""
return self._volume
@property
def time_msc(self) -> int:
"""Timestamp in milliseconds."""
return self._time_msc
@property
def flags(self) -> int:
"""Flags indicating tick data attributes."""
return self._flags
@property
def volume_real(self) -> Optional[float]:
"""Real volume (if available)."""
return self._volume_real