mtcli 3.2.0.dev0__tar.gz → 3.2.0.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/PKG-INFO +1 -1
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/commands/bars.py +118 -126
- mtcli-3.2.0.dev2/mtcli/conecta.py +41 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/data/mt5.py +18 -20
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/mt5_context.py +3 -3
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/pyproject.toml +1 -1
- mtcli-3.2.0.dev0/mtcli/conecta.py +0 -18
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/LICENSE +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/README.md +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/commands/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/commands/conf.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/commands/logs.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/conf.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/data/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/data/base.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/data/csv.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/logger.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/bar_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/bars_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/chart_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/conf_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/consecutive_bars_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/rates_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/signals_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/models/unconsecutive_bar_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/mt.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugin.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/agressao/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/agressao/command.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/agressao/conf.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/agressao/models/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/agressao/models/model_agressao.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/agressao/views/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/agressao/views/view_agressao.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/command.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/conf.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/models/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/models/model_media_movel.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/tests/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/tests/test_mm.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/tests/test_model_media_movel.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/command.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/conf.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/models/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/models/average_range_model.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/tests/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/tests/test_rm.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/command.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/conf.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/models/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/models/model_average_volume.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/tests/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/tests/test_vm.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/__init__.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/close_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/full_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/high_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/low_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/min_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/open_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/ranges_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/rates_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/vars_view.py +0 -0
- {mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/views/volumes_view.py +0 -0
|
@@ -1,126 +1,118 @@
|
|
|
1
|
-
"""Exibe o gráfico de barras."""
|
|
2
|
-
|
|
3
|
-
import click
|
|
4
|
-
|
|
5
|
-
from mtcli import conf
|
|
6
|
-
from mtcli.models.rates_model import RatesModel
|
|
7
|
-
from mtcli.models.bars_model import BarsModel
|
|
8
|
-
from mtcli.views.full_view import FullView
|
|
9
|
-
from mtcli.views.min_view import MinView
|
|
10
|
-
from mtcli.views.ranges_view import RangesView
|
|
11
|
-
from mtcli.views.volumes_view import VolumesView
|
|
12
|
-
from mtcli.views.vars_view import VarsView
|
|
13
|
-
from mtcli.views.rates_view import RatesView
|
|
14
|
-
from mtcli.views.open_view import OpenView
|
|
15
|
-
from mtcli.views.high_view import HighView
|
|
16
|
-
from mtcli.views.low_view import LowView
|
|
17
|
-
from mtcli.views.close_view import CloseView
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@click.
|
|
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
|
-
default=conf.
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
@click.option(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
view
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if views:
|
|
120
|
-
for view in views:
|
|
121
|
-
click.echo(view)
|
|
122
|
-
logger.info("Exibição do gráfico MT5 finalizada.")
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if __name__ == "__main__":
|
|
126
|
-
bars()
|
|
1
|
+
"""Exibe o gráfico de barras."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from mtcli import conf
|
|
6
|
+
from mtcli.models.rates_model import RatesModel
|
|
7
|
+
from mtcli.models.bars_model import BarsModel
|
|
8
|
+
from mtcli.views.full_view import FullView
|
|
9
|
+
from mtcli.views.min_view import MinView
|
|
10
|
+
from mtcli.views.ranges_view import RangesView
|
|
11
|
+
from mtcli.views.volumes_view import VolumesView
|
|
12
|
+
from mtcli.views.vars_view import VarsView
|
|
13
|
+
from mtcli.views.rates_view import RatesView
|
|
14
|
+
from mtcli.views.open_view import OpenView
|
|
15
|
+
from mtcli.views.high_view import HighView
|
|
16
|
+
from mtcli.views.low_view import LowView
|
|
17
|
+
from mtcli.views.close_view import CloseView
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@click.command(
|
|
21
|
+
"bars",
|
|
22
|
+
help="Mostra o gráfico de candles em texto para o ativo e período especificados.",
|
|
23
|
+
)
|
|
24
|
+
@click.argument("symbol")
|
|
25
|
+
@click.option(
|
|
26
|
+
"--view",
|
|
27
|
+
"-v",
|
|
28
|
+
type=click.Choice(
|
|
29
|
+
[
|
|
30
|
+
"ch",
|
|
31
|
+
"m",
|
|
32
|
+
"hl",
|
|
33
|
+
"f",
|
|
34
|
+
"full",
|
|
35
|
+
"r",
|
|
36
|
+
"range",
|
|
37
|
+
"v",
|
|
38
|
+
"volume",
|
|
39
|
+
"va",
|
|
40
|
+
"percentual",
|
|
41
|
+
"oh",
|
|
42
|
+
"ohlc",
|
|
43
|
+
"o",
|
|
44
|
+
"open",
|
|
45
|
+
"h",
|
|
46
|
+
"high",
|
|
47
|
+
"l",
|
|
48
|
+
"low",
|
|
49
|
+
"c",
|
|
50
|
+
"close",
|
|
51
|
+
],
|
|
52
|
+
case_sensitive=False,
|
|
53
|
+
),
|
|
54
|
+
default=conf.view,
|
|
55
|
+
help="Formato de exibicao, default m. Opcoes: ch ou m - minima; f - completa; r - ranges; v - volumes; va - variações percentuais; oh - OHLC; o - aberturas; h - maximas; l - minimas; c - fechamentos",
|
|
56
|
+
)
|
|
57
|
+
@click.option(
|
|
58
|
+
"--period",
|
|
59
|
+
"-p",
|
|
60
|
+
type=click.Choice(conf.timeframes, case_sensitive=False),
|
|
61
|
+
default=conf.period,
|
|
62
|
+
help="Tempo grafico, default D1.",
|
|
63
|
+
)
|
|
64
|
+
@click.option(
|
|
65
|
+
"--count",
|
|
66
|
+
"-c",
|
|
67
|
+
type=int,
|
|
68
|
+
default=conf.periodos,
|
|
69
|
+
help="Quantidade de barras, default 20.",
|
|
70
|
+
)
|
|
71
|
+
@click.option(
|
|
72
|
+
"--date", "-d", default=conf.date, help="Data para intraday, formato AAAA-MM-DD."
|
|
73
|
+
)
|
|
74
|
+
@click.option("--numerator", "-n", is_flag=True, help="Ativa a numeracao das barras.")
|
|
75
|
+
@click.option("--show-date", "-sd", is_flag=True, help="Ativa a datacao das barras.")
|
|
76
|
+
@click.option(
|
|
77
|
+
"--volume",
|
|
78
|
+
"-vo",
|
|
79
|
+
type=click.Choice(["tick", "real"], case_sensitive=False),
|
|
80
|
+
default=conf.volume,
|
|
81
|
+
help="Tipo de volume, default tick.",
|
|
82
|
+
)
|
|
83
|
+
def bars(symbol, view, period, count, date, numerator, show_date, volume):
|
|
84
|
+
"""Exibe o grafico do MetaTrader 5."""
|
|
85
|
+
period = period.lower()
|
|
86
|
+
view = view.lower()
|
|
87
|
+
rates = RatesModel(symbol, period, count).get_data()
|
|
88
|
+
bars = BarsModel(rates, date).get_bars()
|
|
89
|
+
views = []
|
|
90
|
+
if view in ["m", "ch", "hl"]: # máximas e mínimas
|
|
91
|
+
views = MinView(bars, count, period, date, numerator, show_date).views()
|
|
92
|
+
elif view in ["r", "range"]: # ranges
|
|
93
|
+
views = RangesView(bars, count, period, date, numerator, show_date).views()
|
|
94
|
+
elif view in ["oh", "ohlc"]: # OHLC
|
|
95
|
+
views = RatesView(bars, count, period, date, numerator, show_date).views()
|
|
96
|
+
elif view in ["va", "percentual"]: # variações percentuais
|
|
97
|
+
views = VarsView(bars, count, period, date, numerator, show_date).views()
|
|
98
|
+
elif view in ["o", "open"]: # abertura
|
|
99
|
+
views = OpenView(bars, count, period, date, numerator, show_date).views()
|
|
100
|
+
elif view in ["h", "high"]: # máximas
|
|
101
|
+
views = HighView(bars, count, period, date, numerator, show_date).views()
|
|
102
|
+
elif view in ["l", "low"]: # mínimas
|
|
103
|
+
views = LowView(bars, count, period, date, numerator, show_date).views()
|
|
104
|
+
elif view in ["c", "close"]: # fechamentos
|
|
105
|
+
views = CloseView(bars, count, period, date, numerator, show_date).views()
|
|
106
|
+
elif view in ["v", "volume"]: # volumes
|
|
107
|
+
views = VolumesView(
|
|
108
|
+
bars, count, period, date, numerator, show_date, volume
|
|
109
|
+
).views()
|
|
110
|
+
else: # completo
|
|
111
|
+
views = FullView(bars, count, period, date, numerator, show_date).views()
|
|
112
|
+
if views:
|
|
113
|
+
for view in views:
|
|
114
|
+
click.echo(view)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
bars()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Gerencia a conexão direta com o terminal MetaTrader 5.
|
|
3
|
+
Usado internamente pelo contexto mt5_conexao().
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import MetaTrader5 as mt5
|
|
7
|
+
from mtcli.logger import setup_logger
|
|
8
|
+
|
|
9
|
+
log = setup_logger()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def conectar() -> bool:
|
|
13
|
+
"""
|
|
14
|
+
Inicializa a conexão com o MetaTrader 5.
|
|
15
|
+
|
|
16
|
+
Retorna:
|
|
17
|
+
bool: True se conectado com sucesso, False caso contrário.
|
|
18
|
+
|
|
19
|
+
Levanta:
|
|
20
|
+
ConnectionError: se a inicialização do MT5 falhar.
|
|
21
|
+
"""
|
|
22
|
+
log.debug("Tentando inicializar conexao com MetaTrader 5...")
|
|
23
|
+
|
|
24
|
+
if not mt5.initialize():
|
|
25
|
+
erro = mt5.last_error()
|
|
26
|
+
log.error(f"Erro ao conectar ao MetaTrader 5: {erro}")
|
|
27
|
+
raise ConnectionError(f"Falha ao conectar ao MetaTrader 5: {erro}")
|
|
28
|
+
|
|
29
|
+
log.info("Conexao com MetaTrader 5 estabelecida com sucesso.")
|
|
30
|
+
return True
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def shutdown():
|
|
34
|
+
"""
|
|
35
|
+
Encerra a conexão com o MetaTrader 5 de forma segura.
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
mt5.shutdown()
|
|
39
|
+
log.debug("Conexao com MetaTrader 5 encerrada.")
|
|
40
|
+
except Exception as e:
|
|
41
|
+
log.error(f"Erro ao encerrar conexao com MetaTrader 5: {e}")
|
|
@@ -5,11 +5,11 @@ from datetime import datetime
|
|
|
5
5
|
import MetaTrader5 as mt5
|
|
6
6
|
|
|
7
7
|
from mtcli.logger import setup_logger
|
|
8
|
-
from mtcli.
|
|
8
|
+
from mtcli.mt5_context import mt5_conexao
|
|
9
9
|
|
|
10
10
|
from .base import DataSourceBase
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
log = setup_logger()
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class MT5DataSource(DataSourceBase):
|
|
@@ -18,8 +18,8 @@ class MT5DataSource(DataSourceBase):
|
|
|
18
18
|
def get_data(self, symbol, period, count=100):
|
|
19
19
|
"""Retorna uma lista de lista de cotações do MetaTrader."""
|
|
20
20
|
period = period.upper()
|
|
21
|
-
|
|
22
|
-
f"Iniciando coleta de dados via API MT5: {symbol} no
|
|
21
|
+
log.info(
|
|
22
|
+
f"Iniciando coleta de dados via API MT5: {symbol} no timeframe {period}"
|
|
23
23
|
)
|
|
24
24
|
tf_map = {
|
|
25
25
|
"M1": mt5.TIMEFRAME_M1,
|
|
@@ -46,12 +46,9 @@ class MT5DataSource(DataSourceBase):
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
if period.upper() not in tf_map:
|
|
49
|
-
|
|
49
|
+
log.error(f"Timeframe inválido: {period}.")
|
|
50
50
|
raise ValueError(f"Timeframe '{period}' inválido.")
|
|
51
51
|
|
|
52
|
-
conectar()
|
|
53
|
-
|
|
54
|
-
# Verifica corretoras B3 e aplica tratamento a symbol
|
|
55
52
|
corretoras_b3 = [
|
|
56
53
|
"clear",
|
|
57
54
|
"xp",
|
|
@@ -61,21 +58,22 @@ class MT5DataSource(DataSourceBase):
|
|
|
61
58
|
"btg",
|
|
62
59
|
"toro",
|
|
63
60
|
]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
|
|
62
|
+
with mt5_conexao():
|
|
63
|
+
for corretora in corretoras_b3:
|
|
64
|
+
symbol = (
|
|
65
|
+
symbol.upper()
|
|
66
|
+
if corretora in mt5.account_info().company.lower()
|
|
67
|
+
else symbol
|
|
68
|
+
)
|
|
69
|
+
log.info(
|
|
70
|
+
f"Finalizada verificacao da corretora para tratar symbol: {symbol}."
|
|
69
71
|
)
|
|
70
|
-
logger.info(
|
|
71
|
-
f"Finalizada verificação da corretora para tratar symbol: {symbol}."
|
|
72
|
-
)
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
shutdown()
|
|
73
|
+
rates = mt5.copy_rates_from_pos(symbol, tf_map[period], 0, count)
|
|
76
74
|
|
|
77
75
|
if rates is None:
|
|
78
|
-
|
|
76
|
+
log.warning("Nenum dado retornado da API MT5.")
|
|
79
77
|
raise ValueError("Nenhum dado retornado da API MT5.")
|
|
80
78
|
|
|
81
79
|
result = []
|
|
@@ -95,5 +93,5 @@ class MT5DataSource(DataSourceBase):
|
|
|
95
93
|
]
|
|
96
94
|
)
|
|
97
95
|
|
|
98
|
-
|
|
96
|
+
log.info("Coleta de dados via API MT5 finalizada.")
|
|
99
97
|
return result
|
|
@@ -19,7 +19,7 @@ def mt5_conexao():
|
|
|
19
19
|
- Loga falhas e garante fechamento seguro.
|
|
20
20
|
"""
|
|
21
21
|
try:
|
|
22
|
-
log.debug("Inicializando
|
|
22
|
+
log.debug("Inicializando conexao com MetaTrader 5...")
|
|
23
23
|
conectar()
|
|
24
24
|
yield
|
|
25
25
|
except Exception as e:
|
|
@@ -28,6 +28,6 @@ def mt5_conexao():
|
|
|
28
28
|
finally:
|
|
29
29
|
try:
|
|
30
30
|
shutdown()
|
|
31
|
-
log.debug("
|
|
31
|
+
log.debug("Conexao com MetaTrader 5 encerrada.")
|
|
32
32
|
except Exception as e:
|
|
33
|
-
log.error(f"Erro ao encerrar
|
|
33
|
+
log.error(f"Erro ao encerrar conexao MT5: {e}")
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"""Módulo de conexão com o MetaTrader 5."""
|
|
2
|
-
|
|
3
|
-
import MetaTrader5 as mt5
|
|
4
|
-
from mtcli.logger import setup_logger
|
|
5
|
-
|
|
6
|
-
logger = setup_logger()
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def conectar():
|
|
10
|
-
if not mt5.initialize():
|
|
11
|
-
click.echo(f"❌ Erro ao conectar ao MT5: {mt5.last_error()}")
|
|
12
|
-
logger.error(f"Erro ao conectar ao MT5: {mt5.last_error()}")
|
|
13
|
-
exit()
|
|
14
|
-
return True
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def shutdown():
|
|
18
|
-
mt5.shutdown()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/media_movel/tests/test_model_media_movel.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/range_medio/models/average_range_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mtcli-3.2.0.dev0 → mtcli-3.2.0.dev2}/mtcli/plugins/volume_medio/models/model_average_volume.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|