mtcli 3.2.0.dev0__py3-none-any.whl → 3.2.0.dev1__py3-none-any.whl

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/conecta.py CHANGED
@@ -1,18 +1,41 @@
1
- """Módulo de conexão com o MetaTrader 5."""
1
+ """
2
+ Gerencia a conexão direta com o terminal MetaTrader 5.
3
+ Usado internamente pelo contexto mt5_conexao().
4
+ """
2
5
 
3
6
  import MetaTrader5 as mt5
4
7
  from mtcli.logger import setup_logger
5
8
 
6
- logger = setup_logger()
9
+ log = setup_logger()
7
10
 
8
11
 
9
- def conectar():
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 conexão com MetaTrader 5...")
23
+
10
24
  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()
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("Conexão com MetaTrader 5 estabelecida com sucesso.")
14
30
  return True
15
31
 
16
32
 
17
33
  def shutdown():
18
- mt5.shutdown()
34
+ """
35
+ Encerra a conexão com o MetaTrader 5 de forma segura.
36
+ """
37
+ try:
38
+ mt5.shutdown()
39
+ log.debug("Conexão com MetaTrader 5 encerrada.")
40
+ except Exception as e:
41
+ log.error(f"Erro ao encerrar conexão com MetaTrader 5: {e}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mtcli
3
- Version: 3.2.0.dev0
3
+ Version: 3.2.0.dev1
4
4
  Summary: Aplicativo CLI para exibir gráficos do MetaTrader 5 em texto acessível ao leitor de telas
5
5
  License: GPL-3.0
6
6
  Keywords: MetaTrader 5,trading,CLI
@@ -3,7 +3,7 @@ mtcli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  mtcli/commands/bars.py,sha256=BxhrN_EQY9ummTHhav7gX7HrJCE7t5ltcI-Ld88TPJ0,4274
4
4
  mtcli/commands/conf.py,sha256=25YGs4laxx8Ss85LRST90QDehCMPomhz6U8Qb9aVwak,1549
5
5
  mtcli/commands/logs.py,sha256=yTg9dOvzw2iK6fhasd34ZNhcUfWRf7DKk86vxDILAqw,1349
6
- mtcli/conecta.py,sha256=XmW5f-JqjTXhj4cWm4KISoo69KMVZ7lRTHfBoynVtsk,409
6
+ mtcli/conecta.py,sha256=LHesQwxRRzvP5rpZ_4b9tpNERDwHSoPD-cM2vfQMJmM,1118
7
7
  mtcli/conf.py,sha256=wvgCirMKnrmhknwGrvAIp9DOOz3LR8xCGvUYHdLnUck,3057
8
8
  mtcli/data/__init__.py,sha256=NMzgUoiyY5OUFJkmR-OCFF2fOTY9vp-64z8-bh7HEcs,64
9
9
  mtcli/data/base.py,sha256=Hv1r1IlIhFVEhINWz90FZptYIdhyBKxhMBn5odJfT_8,314
@@ -63,8 +63,8 @@ mtcli/views/ranges_view.py,sha256=FmRUhq_8JSPODv3wT7Jlvh9p9TWSJpDtj4WNfFBVQZQ,13
63
63
  mtcli/views/rates_view.py,sha256=vaWIa9oPeIR2mdouyFCU1pk-T1Zc4eiK17LFsqldDQs,1214
64
64
  mtcli/views/vars_view.py,sha256=wQ1-gJYFii2w0BDt10y9Cgw-y0iqVjDKbLvhcOH-zus,1770
65
65
  mtcli/views/volumes_view.py,sha256=dk_CMATbnQdHGuNuZ1xONToC31eUhLCbuXtewZ9FE-w,1602
66
- mtcli-3.2.0.dev0.dist-info/entry_points.txt,sha256=5R3VOurhCTctnZKSA673LWLkB2mklJl_PobPwpe35EM,204
67
- mtcli-3.2.0.dev0.dist-info/LICENSE,sha256=vZGn4wXWr9Tty92CJcj-dxw_S6mjZAhtsYVJ5VLSTUg,726
68
- mtcli-3.2.0.dev0.dist-info/METADATA,sha256=LxcghdeRdkLFA2I7BJdaImEGPzCJ8Gu1y65JmXa_eWQ,3468
69
- mtcli-3.2.0.dev0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
70
- mtcli-3.2.0.dev0.dist-info/RECORD,,
66
+ mtcli-3.2.0.dev1.dist-info/entry_points.txt,sha256=5R3VOurhCTctnZKSA673LWLkB2mklJl_PobPwpe35EM,204
67
+ mtcli-3.2.0.dev1.dist-info/LICENSE,sha256=vZGn4wXWr9Tty92CJcj-dxw_S6mjZAhtsYVJ5VLSTUg,726
68
+ mtcli-3.2.0.dev1.dist-info/METADATA,sha256=DZTkCwNnxCET4Kx5zjiSuYw5oTYc-4H0rc5gC-w7Mik,3468
69
+ mtcli-3.2.0.dev1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
70
+ mtcli-3.2.0.dev1.dist-info/RECORD,,