mtcli 3.5.0.dev0__tar.gz → 4.0.0.dev0__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.
Files changed (71) hide show
  1. mtcli-4.0.0.dev0/LICENSE +17 -0
  2. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/PKG-INFO +8 -12
  3. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/README.md +145 -145
  4. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/commands/bars.py +153 -147
  5. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/conf.py +96 -102
  6. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/logger.py +46 -47
  7. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/bar_model.py +105 -105
  8. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/consecutive_bars_model.py +75 -77
  9. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/unconsecutive_bar_model.py +67 -67
  10. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/mt.py +1 -1
  11. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/mt5_context.py +5 -1
  12. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/media_movel/__init__.py +3 -3
  13. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/media_movel/command.py +99 -99
  14. mtcli-4.0.0.dev0/mtcli/plugins/media_movel/conf.py +4 -0
  15. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/media_movel/models/__init__.py +1 -1
  16. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/media_movel/tests/test_mm.py +13 -13
  17. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/media_movel/tests/test_model_media_movel.py +9 -9
  18. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/range_medio/command.py +33 -33
  19. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/range_medio/models/average_range_model.py +29 -29
  20. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/volume_medio/__init__.py +3 -3
  21. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/volume_medio/command.py +42 -42
  22. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/volume_medio/models/model_average_volume.py +31 -31
  23. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/close_view.py +37 -37
  24. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/full_view.py +69 -65
  25. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/high_view.py +37 -37
  26. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/low_view.py +37 -37
  27. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/min_view.py +42 -42
  28. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/open_view.py +37 -37
  29. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/ranges_view.py +43 -41
  30. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/rates_view.py +41 -41
  31. mtcli-4.0.0.dev0/mtcli/views/utils.py +37 -0
  32. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/volumes_view.py +55 -51
  33. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/pyproject.toml +21 -43
  34. mtcli-3.5.0.dev0/LICENSE +0 -21
  35. mtcli-3.5.0.dev0/mtcli/database.py +0 -54
  36. mtcli-3.5.0.dev0/mtcli/domain/timeframe.py +0 -87
  37. mtcli-3.5.0.dev0/mtcli/marketdata/tick_cache.py +0 -24
  38. mtcli-3.5.0.dev0/mtcli/marketdata/tick_repository.py +0 -116
  39. mtcli-3.5.0.dev0/mtcli/plugins/media_movel/conf.py +0 -4
  40. mtcli-3.5.0.dev0/mtcli/plugins/range_medio/tests/__init__.py +0 -0
  41. mtcli-3.5.0.dev0/mtcli/plugins/volume_medio/tests/__init__.py +0 -0
  42. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/__init__.py +0 -0
  43. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/commands/__init__.py +0 -0
  44. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/commands/conf.py +0 -0
  45. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/commands/logs.py +0 -0
  46. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/conecta.py +0 -0
  47. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/data/__init__.py +0 -0
  48. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/data/base.py +0 -0
  49. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/data/csv.py +0 -0
  50. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/data/mt5.py +0 -0
  51. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/__init__.py +0 -0
  52. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/bars_model.py +0 -0
  53. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/chart_model.py +0 -0
  54. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/conf_model.py +0 -0
  55. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/rates_model.py +0 -0
  56. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/models/signals_model.py +0 -0
  57. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugin.py +0 -0
  58. {mtcli-3.5.0.dev0/mtcli/domain → mtcli-4.0.0.dev0/mtcli/plugins}/__init__.py +0 -0
  59. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/media_movel/models/model_media_movel.py +0 -0
  60. {mtcli-3.5.0.dev0/mtcli/marketdata → mtcli-4.0.0.dev0/mtcli/plugins/media_movel/tests}/__init__.py +0 -0
  61. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/range_medio/__init__.py +0 -0
  62. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/range_medio/conf.py +0 -0
  63. {mtcli-3.5.0.dev0/mtcli/plugins → mtcli-4.0.0.dev0/mtcli/plugins/range_medio/models}/__init__.py +0 -0
  64. {mtcli-3.5.0.dev0/mtcli/plugins/media_movel → mtcli-4.0.0.dev0/mtcli/plugins/range_medio}/tests/__init__.py +0 -0
  65. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/range_medio/tests/test_rm.py +0 -0
  66. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/volume_medio/conf.py +0 -0
  67. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/volume_medio/models/__init__.py +0 -0
  68. {mtcli-3.5.0.dev0/mtcli/plugins/range_medio/models → mtcli-4.0.0.dev0/mtcli/plugins/volume_medio/tests}/__init__.py +0 -0
  69. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/plugins/volume_medio/tests/test_vm.py +0 -0
  70. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/__init__.py +0 -0
  71. {mtcli-3.5.0.dev0 → mtcli-4.0.0.dev0}/mtcli/views/vars_view.py +0 -0
@@ -0,0 +1,17 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2025 Valmir França da Silva
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
@@ -1,26 +1,22 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: mtcli
3
- Version: 3.5.0.dev0
4
- Summary: Aplicativo CLI para exibir gráficos do MetaTrader 5 screen reader friendly
5
- License-Expression: MIT
6
- License-File: LICENSE
7
- Keywords: trading,candlestick,metatrader5,mt5,cli,price-action
3
+ Version: 4.0.0.dev0
4
+ Summary: Aplicativo CLI para exibir gráficos do MetaTrader 5 em texto acessível ao leitor de telas
5
+ License: GPL-3.0
6
+ Keywords: MetaTrader 5,trading,CLI
8
7
  Author: Valmir França da Silva
9
8
  Author-email: vfranca3@gmail.com
10
9
  Requires-Python: >=3.10,<3.14.0
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Financial and Insurance Industry
10
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
11
  Classifier: Programming Language :: Python :: 3
14
12
  Classifier: Programming Language :: Python :: 3.10
15
13
  Classifier: Programming Language :: Python :: 3.11
16
14
  Classifier: Programming Language :: Python :: 3.12
17
15
  Classifier: Programming Language :: Python :: 3.13
18
- Classifier: Operating System :: OS Independent
19
- Classifier: Topic :: Office/Business :: Financial :: Investment
20
16
  Requires-Dist: click (>=8.2.1,<9.0.0)
21
17
  Requires-Dist: metatrader5 (>=5.0.5260,<6.0.0)
22
18
  Project-URL: Documentation, https://mtcli.readthedocs.io/pt-br/latest
23
- Project-URL: Homepage, https://github.com:vfranca/mtcli
19
+ Project-URL: Homepage, https://pypi.org/project/mtcli
24
20
  Project-URL: Repository, https://github.com/vfranca/mtcli
25
21
  Project-URL: issues, https://github.com/vfranca/mtcli/issues
26
22
  Description-Content-Type: text/markdown
@@ -169,5 +165,5 @@ GitHub: [@vfranca](https://github.com/vfranca)
169
165
 
170
166
  ## Licença
171
167
 
172
- Distribuído sob a licença MIT. Veja `LICENSE` para mais informações.
168
+ Distribuído sob a licença GPL-3.0. Veja `LICENSE` para mais informações.
173
169
 
@@ -1,145 +1,145 @@
1
- # mtcli
2
-
3
- *mtcli* é um aplicativo de linha de comando (CLI) acessível para leitura e análise de gráficos do MetaTrader 5, desenvolvido com foco em acessibilidade para usuários com deficiência visual.
4
-
5
- O projeto é modular e extensível por meio de plugins.
6
-
7
- ---
8
-
9
- ## Instalação
10
-
11
- Você pode instalar o `mtcli` diretamente via *pip*:
12
-
13
- ```bash
14
- pip install mtcli
15
- ```
16
-
17
- Ou diretamente a partir do código-fonte:
18
-
19
- ```bash
20
- git clone https://github.com/vfranca/mtcli.git
21
- cd mtcli
22
- pip install .
23
- ```
24
-
25
- ---
26
-
27
- ## Como usar
28
-
29
- Após a instalação, o comando principal é:
30
-
31
- ```bash
32
- mt
33
- ```
34
-
35
- Você verá uma lista de comandos e plugins disponíveis.
36
-
37
- Para executar um plugin específico, use:
38
-
39
- ```bash
40
- mt nome-do-plugin [opções]
41
- ```
42
-
43
- Exemplo com o plugin de média móvel:
44
-
45
- ```bash
46
- mt mm --symbol WIN$N --periodo 14
47
- ```
48
-
49
- ---
50
-
51
- ## Documentação
52
-
53
- A documentação completa está disponível em:
54
-
55
- *https://vfranca.github.io/mtcli*
56
-
57
- Inclui guias de uso, instalação de plugins, exemplos e estrutura do projeto.
58
-
59
- ---
60
-
61
- ## Como contribuir
62
-
63
- Contribuições são bem-vindas!
64
-
65
- Clonar o repositório
66
-
67
- ```bash
68
- git clone https://github.com/vfranca/mtcli.git
69
- cd mtcli
70
- ```
71
-
72
- Instalar dependências para desenvolvimento
73
-
74
- ```bash
75
- pip install -e ".[dev]"
76
- ```
77
- Rodar os testes
78
-
79
- ```bash
80
- pymake test
81
- ```
82
-
83
- Estilo de código
84
-
85
- - `black` para formatação
86
- - `isort` para ordenação de imports
87
- - `pydocstyle` para formatação de docstrings
88
- - `ruff` e `mypy` para linting e verificação estática
89
-
90
- ---
91
-
92
- ## Criando plugins para o mtcli
93
-
94
- Plugins permitem estender a funcionalidade do `mtcli`.
95
-
96
- Estrutura básica de um plugin
97
-
98
- ```toml
99
- pyproject.toml
100
- [project.entry-points."mtcli.plugins"]
101
- nome_do_plugin = "modulo.caminho:funcao_principal"
102
- ```
103
-
104
- Exemplo
105
-
106
- ```toml
107
- [project.entry-points."mtcli.plugins"]
108
- volume_medio = "mtcli.plugins.volume_medio:vm"
109
- ```
110
-
111
- No código Python:
112
-
113
- ```python
114
-
115
- def vm():
116
- print("Plugin de volume médio executado.")
117
- ```
118
-
119
- Como empacotar
120
-
121
- Crie um projeto separado com sua lógica e registre o plugin no `pyproject.toml` ou `setup.py` como acima.
122
-
123
- Depois, instale com:
124
-
125
- ```bash
126
- pip install .
127
- ```
128
-
129
- O `mtcli` reconhecerá o plugin automaticamente.
130
-
131
- ---
132
-
133
- ## Contato
134
-
135
- Autor: *Valmir França da Silva*
136
-
137
- Email: vfranca3@gmail.com
138
-
139
- GitHub: [@vfranca](https://github.com/vfranca)
140
-
141
- ---
142
-
143
- ## Licença
144
-
145
- Distribuído sob a licença MIT. Veja `LICENSE` para mais informações.
1
+ # mtcli
2
+
3
+ *mtcli* é um aplicativo de linha de comando (CLI) acessível para leitura e análise de gráficos do MetaTrader 5, desenvolvido com foco em acessibilidade para usuários com deficiência visual.
4
+
5
+ O projeto é modular e extensível por meio de plugins.
6
+
7
+ ---
8
+
9
+ ## Instalação
10
+
11
+ Você pode instalar o `mtcli` diretamente via *pip*:
12
+
13
+ ```bash
14
+ pip install mtcli
15
+ ```
16
+
17
+ Ou diretamente a partir do código-fonte:
18
+
19
+ ```bash
20
+ git clone https://github.com/vfranca/mtcli.git
21
+ cd mtcli
22
+ pip install .
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Como usar
28
+
29
+ Após a instalação, o comando principal é:
30
+
31
+ ```bash
32
+ mt
33
+ ```
34
+
35
+ Você verá uma lista de comandos e plugins disponíveis.
36
+
37
+ Para executar um plugin específico, use:
38
+
39
+ ```bash
40
+ mt nome-do-plugin [opções]
41
+ ```
42
+
43
+ Exemplo com o plugin de média móvel:
44
+
45
+ ```bash
46
+ mt mm --symbol WIN$N --periodo 14
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Documentação
52
+
53
+ A documentação completa está disponível em:
54
+
55
+ *https://vfranca.github.io/mtcli*
56
+
57
+ Inclui guias de uso, instalação de plugins, exemplos e estrutura do projeto.
58
+
59
+ ---
60
+
61
+ ## Como contribuir
62
+
63
+ Contribuições são bem-vindas!
64
+
65
+ Clonar o repositório
66
+
67
+ ```bash
68
+ git clone https://github.com/vfranca/mtcli.git
69
+ cd mtcli
70
+ ```
71
+
72
+ Instalar dependências para desenvolvimento
73
+
74
+ ```bash
75
+ pip install -e ".[dev]"
76
+ ```
77
+ Rodar os testes
78
+
79
+ ```bash
80
+ pymake test
81
+ ```
82
+
83
+ Estilo de código
84
+
85
+ - `black` para formatação
86
+ - `isort` para ordenação de imports
87
+ - `pydocstyle` para formatação de docstrings
88
+ - `ruff` e `mypy` para linting e verificação estática
89
+
90
+ ---
91
+
92
+ ## Criando plugins para o mtcli
93
+
94
+ Plugins permitem estender a funcionalidade do `mtcli`.
95
+
96
+ Estrutura básica de um plugin
97
+
98
+ ```toml
99
+ pyproject.toml
100
+ [project.entry-points."mtcli.plugins"]
101
+ nome_do_plugin = "modulo.caminho:funcao_principal"
102
+ ```
103
+
104
+ Exemplo
105
+
106
+ ```toml
107
+ [project.entry-points."mtcli.plugins"]
108
+ volume_medio = "mtcli.plugins.volume_medio:vm"
109
+ ```
110
+
111
+ No código Python:
112
+
113
+ ```python
114
+
115
+ def vm():
116
+ print("Plugin de volume médio executado.")
117
+ ```
118
+
119
+ Como empacotar
120
+
121
+ Crie um projeto separado com sua lógica e registre o plugin no `pyproject.toml` ou `setup.py` como acima.
122
+
123
+ Depois, instale com:
124
+
125
+ ```bash
126
+ pip install .
127
+ ```
128
+
129
+ O `mtcli` reconhecerá o plugin automaticamente.
130
+
131
+ ---
132
+
133
+ ## Contato
134
+
135
+ Autor: *Valmir França da Silva*
136
+
137
+ Email: vfranca3@gmail.com
138
+
139
+ GitHub: [@vfranca](https://github.com/vfranca)
140
+
141
+ ---
142
+
143
+ ## Licença
144
+
145
+ Distribuído sob a licença GPL-3.0. Veja `LICENSE` para mais informações.
@@ -1,147 +1,153 @@
1
- """Exibe o gráfico de barras."""
2
-
3
- import click
4
-
5
- from mtcli.conf import (
6
- BARS,
7
- DATE,
8
- PERIOD,
9
- TIMEFRAMES,
10
- VIEW,
11
- VOLUME,
12
- )
13
- from mtcli.models.bars_model import BarsModel
14
- from mtcli.models.rates_model import RatesModel
15
- from mtcli.views.close_view import CloseView
16
- from mtcli.views.full_view import FullView
17
- from mtcli.views.high_view import HighView
18
- from mtcli.views.low_view import LowView
19
- from mtcli.views.min_view import MinView
20
- from mtcli.views.open_view import OpenView
21
- from mtcli.views.ranges_view import RangesView
22
- from mtcli.views.rates_view import RatesView
23
- from mtcli.views.vars_view import VarsView
24
- from mtcli.views.volumes_view import VolumesView
25
-
26
-
27
- @click.command(
28
- "bars",
29
- help="Mostra o gráfico de candles em texto para o ativo e período especificados.",
30
- )
31
- @click.argument("symbol")
32
- @click.option(
33
- "--view",
34
- "-v",
35
- type=click.Choice(
36
- [
37
- "ch",
38
- "m",
39
- "hl",
40
- "f",
41
- "full",
42
- "r",
43
- "range",
44
- "v",
45
- "volume",
46
- "va",
47
- "percentual",
48
- "oh",
49
- "ohlc",
50
- "o",
51
- "open",
52
- "h",
53
- "high",
54
- "l",
55
- "low",
56
- "c",
57
- "close",
58
- ],
59
- case_sensitive=False,
60
- ),
61
- default=VIEW,
62
- show_default=True,
63
- help="Formato de exibicao. Opcoes: minima ou HL - minima; f - completa; r - ranges; v - volumes; va - variações percentuais; oh - OHLC; o - aberturas; h - maximas; l - minimas; c - fechamentos.",
64
- )
65
- @click.option(
66
- "--period",
67
- "-p",
68
- type=click.Choice(TIMEFRAMES, case_sensitive=False),
69
- default=PERIOD,
70
- show_default=True,
71
- help="Timeframe das barras.",
72
- )
73
- @click.option(
74
- "--count",
75
- "-c",
76
- type=int,
77
- default=BARS,
78
- show_default=True,
79
- help="Numero de barras.",
80
- )
81
- @click.option(
82
- "--date",
83
- "-d",
84
- default=DATE,
85
- show_default=True,
86
- help="Data para intraday, formato AAAA-MM-DD.",
87
- )
88
- @click.option(
89
- "--numerator",
90
- "-n",
91
- is_flag=True,
92
- default=False,
93
- show_default=True,
94
- help="Ativa a numeracao das barras.",
95
- )
96
- @click.option(
97
- "--show-date",
98
- "-sd",
99
- is_flag=True,
100
- default=False,
101
- show_default=True,
102
- help="Ativa a datacao das barras.",
103
- )
104
- @click.option(
105
- "--volume",
106
- "-vo",
107
- type=click.Choice(["tick", "real"], case_sensitive=False),
108
- default=VOLUME,
109
- show_default=True,
110
- help="Tipo de volume.",
111
- )
112
- def bars(symbol, view, period, count, date, numerator, show_date, volume):
113
- """Exibe o grafico do MetaTrader 5."""
114
- period = period.lower()
115
- view = view.lower()
116
- rates = RatesModel(symbol, period, count).get_data()
117
- bars = BarsModel(rates, date).get_bars()
118
- views = []
119
- if view in ["m", "ch", "hl"]: # máximas e mínimas
120
- views = MinView(bars, count, period, date, numerator, show_date).views()
121
- elif view in ["r", "range"]: # ranges
122
- views = RangesView(bars, count, period, date, numerator, show_date).views()
123
- elif view in ["oh", "ohlc"]: # OHLC
124
- views = RatesView(bars, count, period, date, numerator, show_date).views()
125
- elif view in ["va", "percentual"]: # variações percentuais
126
- views = VarsView(bars, count, period, date, numerator, show_date).views()
127
- elif view in ["o", "open"]: # abertura
128
- views = OpenView(bars, count, period, date, numerator, show_date).views()
129
- elif view in ["h", "high"]: # máximas
130
- views = HighView(bars, count, period, date, numerator, show_date).views()
131
- elif view in ["l", "low"]: # mínimas
132
- views = LowView(bars, count, period, date, numerator, show_date).views()
133
- elif view in ["c", "close"]: # fechamentos
134
- views = CloseView(bars, count, period, date, numerator, show_date).views()
135
- elif view in ["v", "volume"]: # volumes
136
- views = VolumesView(
137
- bars, count, period, date, numerator, show_date, volume
138
- ).views()
139
- else: # completo
140
- views = FullView(bars, count, period, date, numerator, show_date).views()
141
- if views:
142
- for view in views:
143
- click.echo(view)
144
-
145
-
146
- if __name__ == "__main__":
147
- bars()
1
+ """Exibe o gráfico de barras."""
2
+
3
+ import click
4
+
5
+ from mtcli.conf import (
6
+ DATE,
7
+ PERIOD,
8
+ PERIODOS,
9
+ SYMBOL,
10
+ TIMEFRAMES,
11
+ VIEW,
12
+ VOLUME,
13
+ )
14
+ from mtcli.models.bars_model import BarsModel
15
+ from mtcli.models.rates_model import RatesModel
16
+ from mtcli.views.close_view import CloseView
17
+ from mtcli.views.full_view import FullView
18
+ from mtcli.views.high_view import HighView
19
+ from mtcli.views.low_view import LowView
20
+ from mtcli.views.min_view import MinView
21
+ from mtcli.views.open_view import OpenView
22
+ from mtcli.views.ranges_view import RangesView
23
+ from mtcli.views.rates_view import RatesView
24
+ from mtcli.views.vars_view import VarsView
25
+ from mtcli.views.volumes_view import VolumesView
26
+
27
+
28
+ @click.command(
29
+ help="Mostra o gráfico de candles em texto para o ativo e período especificados.",
30
+ )
31
+ @click.option(
32
+ "--symbol",
33
+ "-s",
34
+ default=SYMBOL,
35
+ show_default=True,
36
+ help="Codigo ou ticker do ativo.",
37
+ )
38
+ @click.option(
39
+ "--view",
40
+ "-v",
41
+ type=click.Choice(
42
+ [
43
+ "ch",
44
+ "m",
45
+ "hl",
46
+ "f",
47
+ "full",
48
+ "r",
49
+ "range",
50
+ "v",
51
+ "volume",
52
+ "va",
53
+ "percentual",
54
+ "oh",
55
+ "ohlc",
56
+ "o",
57
+ "open",
58
+ "h",
59
+ "high",
60
+ "l",
61
+ "low",
62
+ "c",
63
+ "close",
64
+ ],
65
+ case_sensitive=False,
66
+ ),
67
+ default=VIEW,
68
+ show_default=True,
69
+ help="Formato de exibicao. Opcoes: minima ou HL - minima; f - completa; r - ranges; v - volumes; va - variações percentuais; oh - OHLC; o - aberturas; h - maximas; l - minimas; c - fechamentos.",
70
+ )
71
+ @click.option(
72
+ "--period",
73
+ "-p",
74
+ type=click.Choice(TIMEFRAMES, case_sensitive=False),
75
+ default=PERIOD,
76
+ show_default=True,
77
+ help="Timeframe do grafico.",
78
+ )
79
+ @click.option(
80
+ "--count",
81
+ "-c",
82
+ type=int,
83
+ default=PERIODOS,
84
+ show_default=True,
85
+ help="Quantidade de periodos a serem exibidos.",
86
+ )
87
+ @click.option(
88
+ "--date",
89
+ "-d",
90
+ default=DATE,
91
+ show_default=True,
92
+ help="Data para intraday, formato AAAA-MM-DD.",
93
+ )
94
+ @click.option(
95
+ "--numerator",
96
+ "-n",
97
+ is_flag=True,
98
+ default=False,
99
+ show_default=True,
100
+ help="Ativa a numeracao das barras.",
101
+ )
102
+ @click.option(
103
+ "--show-date",
104
+ "-sd",
105
+ is_flag=True,
106
+ default=False,
107
+ show_default=True,
108
+ help="Ativa a datacao das barras.",
109
+ )
110
+ @click.option(
111
+ "--volume",
112
+ "-vo",
113
+ type=click.Choice(["tick", "real"], case_sensitive=False),
114
+ default=VOLUME,
115
+ show_default=True,
116
+ help="Tipo de volume.",
117
+ )
118
+ def bars(symbol, view, period, count, date, numerator, show_date, volume):
119
+ """Exibe o grafico do MetaTrader 5."""
120
+ period = period.lower()
121
+ view = view.lower()
122
+ rates = RatesModel(symbol, period, count).get_data()
123
+ bars = BarsModel(rates, date).get_bars()
124
+ views = []
125
+ if view in ["m", "ch", "hl"]: # máximas e mínimas
126
+ views = MinView(bars, count, period, date, numerator, show_date).views()
127
+ elif view in ["r", "range"]: # ranges
128
+ views = RangesView(bars, count, period, date, numerator, show_date).views()
129
+ elif view in ["oh", "ohlc"]: # OHLC
130
+ views = RatesView(bars, count, period, date, numerator, show_date).views()
131
+ elif view in ["va", "percentual"]: # variações percentuais
132
+ views = VarsView(bars, count, period, date, numerator, show_date).views()
133
+ elif view in ["o", "open"]: # abertura
134
+ views = OpenView(bars, count, period, date, numerator, show_date).views()
135
+ elif view in ["h", "high"]: # máximas
136
+ views = HighView(bars, count, period, date, numerator, show_date).views()
137
+ elif view in ["l", "low"]: # mínimas
138
+ views = LowView(bars, count, period, date, numerator, show_date).views()
139
+ elif view in ["c", "close"]: # fechamentos
140
+ views = CloseView(bars, count, period, date, numerator, show_date).views()
141
+ elif view in ["v", "volume"]: # volumes
142
+ views = VolumesView(
143
+ bars, count, period, date, numerator, show_date, volume
144
+ ).views()
145
+ else: # completo
146
+ views = FullView(bars, count, period, date, numerator, show_date).views()
147
+ if views:
148
+ for view in views:
149
+ click.echo(view)
150
+
151
+
152
+ if __name__ == "__main__":
153
+ bars()