mtcli 3.4.0.dev0__tar.gz → 3.5.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.
- mtcli-3.5.0.dev0/LICENSE +21 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/PKG-INFO +12 -8
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/README.md +145 -145
- mtcli-3.5.0.dev0/mtcli/database.py +54 -0
- mtcli-3.5.0.dev0/mtcli/domain/timeframe.py +87 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/logger.py +47 -47
- mtcli-3.5.0.dev0/mtcli/marketdata/tick_cache.py +24 -0
- mtcli-3.5.0.dev0/mtcli/marketdata/tick_repository.py +116 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/mt.py +1 -1
- mtcli-3.5.0.dev0/mtcli/mt5_context.py +62 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/__init__.py +3 -3
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/conf.py +4 -4
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/models/__init__.py +1 -1
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/tests/test_mm.py +13 -13
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/tests/test_model_media_movel.py +9 -9
- mtcli-3.5.0.dev0/mtcli/plugins/range_medio/tests/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/volume_medio/__init__.py +3 -3
- mtcli-3.5.0.dev0/mtcli/plugins/volume_medio/tests/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/pyproject.toml +27 -5
- mtcli-3.4.0.dev0/LICENSE +0 -17
- mtcli-3.4.0.dev0/mtcli/mt5_context.py +0 -36
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/commands/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/commands/bars.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/commands/conf.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/commands/logs.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/conecta.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/conf.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/data/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/data/base.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/data/csv.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/data/mt5.py +0 -0
- {mtcli-3.4.0.dev0/mtcli/plugins → mtcli-3.5.0.dev0/mtcli/domain}/__init__.py +0 -0
- {mtcli-3.4.0.dev0/mtcli/plugins/media_movel/tests → mtcli-3.5.0.dev0/mtcli/marketdata}/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/bar_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/bars_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/chart_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/conf_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/consecutive_bars_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/rates_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/signals_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/models/unconsecutive_bar_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugin.py +0 -0
- {mtcli-3.4.0.dev0/mtcli/plugins/range_medio/models → mtcli-3.5.0.dev0/mtcli/plugins}/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/command.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/models/model_media_movel.py +0 -0
- {mtcli-3.4.0.dev0/mtcli/plugins/range_medio → mtcli-3.5.0.dev0/mtcli/plugins/media_movel}/tests/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/range_medio/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/range_medio/command.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/range_medio/conf.py +0 -0
- {mtcli-3.4.0.dev0/mtcli/plugins/volume_medio/tests → mtcli-3.5.0.dev0/mtcli/plugins/range_medio/models}/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/range_medio/models/average_range_model.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/range_medio/tests/test_rm.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/volume_medio/command.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/volume_medio/conf.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/volume_medio/models/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/volume_medio/models/model_average_volume.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/volume_medio/tests/test_vm.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/__init__.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/close_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/full_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/high_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/low_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/min_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/open_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/ranges_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/rates_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/vars_view.py +0 -0
- {mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/views/volumes_view.py +0 -0
mtcli-3.5.0.dev0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Valmir França
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mtcli
|
|
3
|
-
Version: 3.
|
|
4
|
-
Summary: Aplicativo CLI para exibir gráficos do MetaTrader 5
|
|
5
|
-
License:
|
|
6
|
-
|
|
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
|
|
7
8
|
Author: Valmir França da Silva
|
|
8
9
|
Author-email: vfranca3@gmail.com
|
|
9
10
|
Requires-Python: >=3.10,<3.14.0
|
|
10
|
-
Classifier:
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
11
13
|
Classifier: Programming Language :: Python :: 3
|
|
12
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
16
20
|
Requires-Dist: click (>=8.2.1,<9.0.0)
|
|
17
21
|
Requires-Dist: metatrader5 (>=5.0.5260,<6.0.0)
|
|
18
22
|
Project-URL: Documentation, https://mtcli.readthedocs.io/pt-br/latest
|
|
19
|
-
Project-URL: Homepage, https://
|
|
23
|
+
Project-URL: Homepage, https://github.com:vfranca/mtcli
|
|
20
24
|
Project-URL: Repository, https://github.com/vfranca/mtcli
|
|
21
25
|
Project-URL: issues, https://github.com/vfranca/mtcli/issues
|
|
22
26
|
Description-Content-Type: text/markdown
|
|
@@ -165,5 +169,5 @@ GitHub: [@vfranca](https://github.com/vfranca)
|
|
|
165
169
|
|
|
166
170
|
## Licença
|
|
167
171
|
|
|
168
|
-
Distribuído sob a licença
|
|
172
|
+
Distribuído sob a licença MIT. Veja `LICENSE` para mais informações.
|
|
169
173
|
|
|
@@ -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
|
|
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.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Database core para mtcli.
|
|
3
|
+
|
|
4
|
+
Responsável por:
|
|
5
|
+
- Criar conexão SQLite
|
|
6
|
+
- Ativar WAL
|
|
7
|
+
- Garantir schema
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sqlite3
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
DB_PATH = Path.home() / ".mtcli" / "marketdata.db"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def get_connection():
|
|
18
|
+
"""
|
|
19
|
+
Retorna conexão SQLite configurada.
|
|
20
|
+
"""
|
|
21
|
+
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
|
|
23
|
+
conn = sqlite3.connect(DB_PATH)
|
|
24
|
+
conn.execute("PRAGMA journal_mode=WAL;")
|
|
25
|
+
conn.execute("PRAGMA synchronous=NORMAL;")
|
|
26
|
+
|
|
27
|
+
_ensure_schema(conn)
|
|
28
|
+
return conn
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _ensure_schema(conn):
|
|
32
|
+
conn.execute(
|
|
33
|
+
"""
|
|
34
|
+
CREATE TABLE IF NOT EXISTS ticks (
|
|
35
|
+
symbol TEXT NOT NULL,
|
|
36
|
+
time INTEGER NOT NULL,
|
|
37
|
+
bid REAL,
|
|
38
|
+
ask REAL,
|
|
39
|
+
last REAL,
|
|
40
|
+
volume REAL,
|
|
41
|
+
flags INTEGER,
|
|
42
|
+
PRIMARY KEY (symbol, time)
|
|
43
|
+
);
|
|
44
|
+
"""
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
conn.execute(
|
|
48
|
+
"""
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_ticks_symbol_time
|
|
50
|
+
ON ticks(symbol, time);
|
|
51
|
+
"""
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
conn.commit()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Enum de Timeframes suportados pelo MTCLI Renko.
|
|
3
|
+
|
|
4
|
+
Fornece:
|
|
5
|
+
- Conversão amigável (m5, 5m, h1, 1h)
|
|
6
|
+
- Mapeamento para constante MT5
|
|
7
|
+
- Lista de valores válidos para CLI
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from enum import Enum
|
|
11
|
+
import MetaTrader5 as mt5
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Timeframe(Enum):
|
|
15
|
+
"""
|
|
16
|
+
Representa timeframes suportados pelo MT5.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
M1 = ("m1", mt5.TIMEFRAME_M1)
|
|
20
|
+
M2 = ("m2", mt5.TIMEFRAME_M2)
|
|
21
|
+
M3 = ("m3", mt5.TIMEFRAME_M3)
|
|
22
|
+
M4 = ("m4", mt5.TIMEFRAME_M4)
|
|
23
|
+
M5 = ("m5", mt5.TIMEFRAME_M5)
|
|
24
|
+
M10 = ("m10", mt5.TIMEFRAME_M10)
|
|
25
|
+
M15 = ("m15", mt5.TIMEFRAME_M15)
|
|
26
|
+
M30 = ("m30", mt5.TIMEFRAME_M30)
|
|
27
|
+
|
|
28
|
+
H1 = ("h1", mt5.TIMEFRAME_H1)
|
|
29
|
+
H2 = ("h2", mt5.TIMEFRAME_H2)
|
|
30
|
+
H3 = ("h3", mt5.TIMEFRAME_H3)
|
|
31
|
+
H4 = ("h4", mt5.TIMEFRAME_H4)
|
|
32
|
+
H6 = ("h6", mt5.TIMEFRAME_H6)
|
|
33
|
+
H8 = ("h8", mt5.TIMEFRAME_H8)
|
|
34
|
+
H12 = ("h12", mt5.TIMEFRAME_H12)
|
|
35
|
+
|
|
36
|
+
D1 = ("d1", mt5.TIMEFRAME_D1)
|
|
37
|
+
W1 = ("w1", mt5.TIMEFRAME_W1)
|
|
38
|
+
MN1 = ("mn1", mt5.TIMEFRAME_MN1)
|
|
39
|
+
|
|
40
|
+
def __init__(self, label: str, mt5_const: int):
|
|
41
|
+
self.label = label
|
|
42
|
+
self.mt5_const = mt5_const
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def from_string(cls, value: str) -> "Timeframe":
|
|
46
|
+
"""
|
|
47
|
+
Converte string amigável para Enum Timeframe.
|
|
48
|
+
|
|
49
|
+
Aceita:
|
|
50
|
+
m5, 5m
|
|
51
|
+
h1, 1h
|
|
52
|
+
d1, 1d
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
value = value.strip().lower()
|
|
56
|
+
|
|
57
|
+
# Aliases humanos
|
|
58
|
+
aliases = {
|
|
59
|
+
"1m": "m1",
|
|
60
|
+
"5m": "m5",
|
|
61
|
+
"15m": "m15",
|
|
62
|
+
"30m": "m30",
|
|
63
|
+
"1h": "h1",
|
|
64
|
+
"4h": "h4",
|
|
65
|
+
"1d": "d1",
|
|
66
|
+
"1w": "w1",
|
|
67
|
+
"1mo": "mn1",
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if value in aliases:
|
|
71
|
+
value = aliases[value]
|
|
72
|
+
|
|
73
|
+
for tf in cls:
|
|
74
|
+
if tf.label == value:
|
|
75
|
+
return tf
|
|
76
|
+
|
|
77
|
+
raise ValueError(
|
|
78
|
+
f"Timeframe inválido: {value}. "
|
|
79
|
+
f"Use: {', '.join(cls.valid_labels())}"
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def valid_labels(cls):
|
|
84
|
+
"""
|
|
85
|
+
Retorna lista de labels válidos.
|
|
86
|
+
"""
|
|
87
|
+
return [tf.label for tf in cls]
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from logging.handlers import RotatingFileHandler
|
|
3
|
-
import os
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
base_dir = os.getenv("APPDATA", os.path.expanduser("~"))
|
|
7
|
-
LOG_DIR = os.path.join(base_dir, "mtcli", "logs")
|
|
8
|
-
os.makedirs(LOG_DIR, exist_ok=True)
|
|
9
|
-
LOG_FILE = os.path.join(LOG_DIR, "mtcli.log")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def setup_logger(name: str = "mtcli") -> logging.Logger:
|
|
13
|
-
"""Configura logger rotativo com saída em arquivo e console.
|
|
14
|
-
|
|
15
|
-
- Escreve logs em ~/.mtcli/mtcli.log (máx. 2 MB, 3 backups).
|
|
16
|
-
- Mostra logs também no console (stdout), capturáveis via pytest/caplog.
|
|
17
|
-
- Evita duplicar handlers.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
logger = logging.getLogger(name)
|
|
21
|
-
logger.setLevel(logging.DEBUG)
|
|
22
|
-
|
|
23
|
-
formatter = logging.Formatter(
|
|
24
|
-
"%(asctime)s | %(levelname)-8s | %(name)s | %(message)s",
|
|
25
|
-
datefmt="%Y-%m-%d %H:%M:%S",
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
# === File handler rotativo ===
|
|
29
|
-
if not any(isinstance(h, RotatingFileHandler) for h in logger.handlers):
|
|
30
|
-
file_handler = RotatingFileHandler(LOG_FILE, maxBytes=2_000_000, backupCount=3)
|
|
31
|
-
file_handler.setFormatter(formatter)
|
|
32
|
-
logger.addHandler(file_handler)
|
|
33
|
-
|
|
34
|
-
# === Stream handler (console) ===
|
|
35
|
-
if not any(isinstance(h, logging.StreamHandler) for h in logger.handlers):
|
|
36
|
-
console_handler = logging.StreamHandler()
|
|
37
|
-
console_handler.setFormatter(formatter)
|
|
38
|
-
logger.addHandler(console_handler)
|
|
39
|
-
|
|
40
|
-
# Permite que pytest caplog capture logs
|
|
41
|
-
logger.propagate = True
|
|
42
|
-
|
|
43
|
-
return logger
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# Inicializa logger padrão
|
|
47
|
-
log = setup_logger()
|
|
1
|
+
import logging
|
|
2
|
+
from logging.handlers import RotatingFileHandler
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
base_dir = os.getenv("APPDATA", os.path.expanduser("~"))
|
|
7
|
+
LOG_DIR = os.path.join(base_dir, "mtcli", "logs")
|
|
8
|
+
os.makedirs(LOG_DIR, exist_ok=True)
|
|
9
|
+
LOG_FILE = os.path.join(LOG_DIR, "mtcli.log")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def setup_logger(name: str = "mtcli") -> logging.Logger:
|
|
13
|
+
"""Configura logger rotativo com saída em arquivo e console.
|
|
14
|
+
|
|
15
|
+
- Escreve logs em ~/.mtcli/mtcli.log (máx. 2 MB, 3 backups).
|
|
16
|
+
- Mostra logs também no console (stdout), capturáveis via pytest/caplog.
|
|
17
|
+
- Evita duplicar handlers.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(name)
|
|
21
|
+
logger.setLevel(logging.DEBUG)
|
|
22
|
+
|
|
23
|
+
formatter = logging.Formatter(
|
|
24
|
+
"%(asctime)s | %(levelname)-8s | %(name)s | %(message)s",
|
|
25
|
+
datefmt="%Y-%m-%d %H:%M:%S",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# === File handler rotativo ===
|
|
29
|
+
if not any(isinstance(h, RotatingFileHandler) for h in logger.handlers):
|
|
30
|
+
file_handler = RotatingFileHandler(LOG_FILE, maxBytes=2_000_000, backupCount=3)
|
|
31
|
+
file_handler.setFormatter(formatter)
|
|
32
|
+
logger.addHandler(file_handler)
|
|
33
|
+
|
|
34
|
+
# === Stream handler (console) ===
|
|
35
|
+
if not any(isinstance(h, logging.StreamHandler) for h in logger.handlers):
|
|
36
|
+
console_handler = logging.StreamHandler()
|
|
37
|
+
console_handler.setFormatter(formatter)
|
|
38
|
+
logger.addHandler(console_handler)
|
|
39
|
+
|
|
40
|
+
# Permite que pytest caplog capture logs
|
|
41
|
+
logger.propagate = True
|
|
42
|
+
|
|
43
|
+
return logger
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Inicializa logger padrão
|
|
47
|
+
log = setup_logger()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cache de ticks em memória.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from collections import deque
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TickCache:
|
|
9
|
+
"""
|
|
10
|
+
Mantém janela recente de ticks em memória.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, max_size=10000):
|
|
14
|
+
self.buffer = deque(maxlen=max_size)
|
|
15
|
+
|
|
16
|
+
def add_many(self, ticks):
|
|
17
|
+
for t in ticks:
|
|
18
|
+
self.buffer.append(t)
|
|
19
|
+
|
|
20
|
+
def get_all(self):
|
|
21
|
+
return list(self.buffer)
|
|
22
|
+
|
|
23
|
+
def clear(self):
|
|
24
|
+
self.buffer.clear()
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TickRepository centralizado.
|
|
3
|
+
|
|
4
|
+
Responsável por:
|
|
5
|
+
- Sincronizar com MT5
|
|
6
|
+
- Persistir ticks
|
|
7
|
+
- Fornecer ticks para modelos
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import MetaTrader5 as mt5
|
|
11
|
+
from datetime import datetime, timedelta
|
|
12
|
+
|
|
13
|
+
from ..database import get_connection
|
|
14
|
+
from .tick_cache import TickCache
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TickRepository:
|
|
18
|
+
|
|
19
|
+
def __init__(self):
|
|
20
|
+
self.conn = get_connection()
|
|
21
|
+
self.cache = TickCache()
|
|
22
|
+
|
|
23
|
+
# =========================
|
|
24
|
+
# SINCRONIZAÇÃO INCREMENTAL
|
|
25
|
+
# =========================
|
|
26
|
+
|
|
27
|
+
def sync(self, symbol: str, days_back: int = 1):
|
|
28
|
+
"""
|
|
29
|
+
Sincroniza banco com MT5.
|
|
30
|
+
|
|
31
|
+
Busca apenas ticks após o último armazenado.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
last_time = self._get_last_tick_time(symbol)
|
|
35
|
+
|
|
36
|
+
if last_time:
|
|
37
|
+
start = datetime.fromtimestamp(last_time)
|
|
38
|
+
else:
|
|
39
|
+
start = datetime.now() - timedelta(days=days_back)
|
|
40
|
+
|
|
41
|
+
ticks = mt5.copy_ticks_from(
|
|
42
|
+
symbol,
|
|
43
|
+
start,
|
|
44
|
+
100000,
|
|
45
|
+
mt5.COPY_TICKS_ALL,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
if ticks is None or len(ticks) == 0:
|
|
49
|
+
return 0
|
|
50
|
+
|
|
51
|
+
inserted = self._insert_ticks(symbol, ticks)
|
|
52
|
+
self.cache.add_many(ticks)
|
|
53
|
+
|
|
54
|
+
return inserted
|
|
55
|
+
|
|
56
|
+
# =========================
|
|
57
|
+
# INSERÇÃO
|
|
58
|
+
# =========================
|
|
59
|
+
|
|
60
|
+
def _insert_ticks(self, symbol, ticks):
|
|
61
|
+
cursor = self.conn.cursor()
|
|
62
|
+
|
|
63
|
+
data = [
|
|
64
|
+
(
|
|
65
|
+
symbol,
|
|
66
|
+
int(t.time),
|
|
67
|
+
float(t.bid),
|
|
68
|
+
float(t.ask),
|
|
69
|
+
float(t.last),
|
|
70
|
+
float(t.volume),
|
|
71
|
+
int(t.flags),
|
|
72
|
+
)
|
|
73
|
+
for t in ticks
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
cursor.executemany(
|
|
77
|
+
"""
|
|
78
|
+
INSERT OR IGNORE INTO ticks
|
|
79
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
80
|
+
""",
|
|
81
|
+
data,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
self.conn.commit()
|
|
85
|
+
return cursor.rowcount
|
|
86
|
+
|
|
87
|
+
# =========================
|
|
88
|
+
# CONSULTAS
|
|
89
|
+
# =========================
|
|
90
|
+
|
|
91
|
+
def get_ticks_between(self, symbol, start_ts, end_ts):
|
|
92
|
+
cursor = self.conn.cursor()
|
|
93
|
+
cursor.execute(
|
|
94
|
+
"""
|
|
95
|
+
SELECT time, bid, ask, last, volume, flags
|
|
96
|
+
FROM ticks
|
|
97
|
+
WHERE symbol = ?
|
|
98
|
+
AND time BETWEEN ? AND ?
|
|
99
|
+
ORDER BY time ASC
|
|
100
|
+
""",
|
|
101
|
+
(symbol, start_ts, end_ts),
|
|
102
|
+
)
|
|
103
|
+
return cursor.fetchall()
|
|
104
|
+
|
|
105
|
+
def _get_last_tick_time(self, symbol):
|
|
106
|
+
cursor = self.conn.cursor()
|
|
107
|
+
cursor.execute(
|
|
108
|
+
"""
|
|
109
|
+
SELECT MAX(time)
|
|
110
|
+
FROM ticks
|
|
111
|
+
WHERE symbol = ?
|
|
112
|
+
""",
|
|
113
|
+
(symbol,),
|
|
114
|
+
)
|
|
115
|
+
result = cursor.fetchone()
|
|
116
|
+
return result[0] if result and result[0] else None
|
|
@@ -11,7 +11,7 @@ except ImportError:
|
|
|
11
11
|
@click.group(context_settings={"max_content_width": 120})
|
|
12
12
|
@click.version_option(package_name="mtcli")
|
|
13
13
|
def mt():
|
|
14
|
-
"""Exibe o grafico
|
|
14
|
+
"""Exibe o grafico candlestick screen reader friendly."""
|
|
15
15
|
pass
|
|
16
16
|
|
|
17
17
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Gerencia o ciclo de conexão com o MetaTrader 5.
|
|
3
|
+
Fornece o contexto 'mt5_conexao' para uso seguro em blocos with.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from contextlib import contextmanager
|
|
7
|
+
import MetaTrader5 as mt5
|
|
8
|
+
from mtcli.logger import setup_logger
|
|
9
|
+
|
|
10
|
+
log = setup_logger()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@contextmanager
|
|
14
|
+
def mt5_conexao(login: int | None = None, password: str | None = None, server: str | None = None):
|
|
15
|
+
"""
|
|
16
|
+
Context manager para conexão direta com o MetaTrader 5.
|
|
17
|
+
|
|
18
|
+
Parâmetros opcionais:
|
|
19
|
+
- login (int): número da conta MT5.
|
|
20
|
+
- password (str): senha da conta.
|
|
21
|
+
- server (str): nome do servidor.
|
|
22
|
+
|
|
23
|
+
Uso:
|
|
24
|
+
>>> with mt5_conexao(login=123456, password="senha", server="ClearInvestimentos-Real"):
|
|
25
|
+
... info = mt5.account_info()
|
|
26
|
+
... print(info)
|
|
27
|
+
|
|
28
|
+
Comportamento:
|
|
29
|
+
- Se as credenciais forem fornecidas, tenta autenticar a conta.
|
|
30
|
+
- Caso contrário, conecta-se à sessão já ativa do terminal MT5.
|
|
31
|
+
- Garante encerramento seguro da conexão.
|
|
32
|
+
"""
|
|
33
|
+
try:
|
|
34
|
+
log.info("Inicializando conexão com MetaTrader 5 via API oficial...")
|
|
35
|
+
|
|
36
|
+
if login and password and server:
|
|
37
|
+
if not mt5.initialize(login=login, password=password, server=server):
|
|
38
|
+
error = mt5.last_error()
|
|
39
|
+
log.error(f"Falha ao conectar ao MetaTrader 5: {error}")
|
|
40
|
+
raise RuntimeError(f"Erro ao conectar ao MT5: {error}")
|
|
41
|
+
else:
|
|
42
|
+
log.info(f"Conectado à conta MT5 {login} ({server}).")
|
|
43
|
+
else:
|
|
44
|
+
if not mt5.initialize():
|
|
45
|
+
error = mt5.last_error()
|
|
46
|
+
log.error(f"Falha ao inicializar MetaTrader 5: {error}")
|
|
47
|
+
raise RuntimeError(f"Erro ao conectar ao MT5: {error}")
|
|
48
|
+
else:
|
|
49
|
+
log.info("Conectado à sessão ativa do MetaTrader 5.")
|
|
50
|
+
|
|
51
|
+
yield
|
|
52
|
+
|
|
53
|
+
except Exception as e:
|
|
54
|
+
log.error(f"Erro durante o uso da conexão MT5: {e}")
|
|
55
|
+
raise
|
|
56
|
+
|
|
57
|
+
finally:
|
|
58
|
+
try:
|
|
59
|
+
mt5.shutdown()
|
|
60
|
+
log.info("Conexão com MetaTrader 5 encerrada com sucesso.")
|
|
61
|
+
except Exception as e:
|
|
62
|
+
log.error(f"Erro ao encerrar conexão MT5: {e}")
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from . import command, conf
|
|
2
|
-
from .command import mm
|
|
3
|
-
from .models.model_media_movel import MediaMovelModel
|
|
1
|
+
from . import command, conf
|
|
2
|
+
from .command import mm
|
|
3
|
+
from .models.model_media_movel import MediaMovelModel
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from mtcli.conf import *
|
|
2
|
-
|
|
3
|
-
periodos = 14
|
|
4
|
-
limite_linhas = 5
|
|
1
|
+
from mtcli.conf import *
|
|
2
|
+
|
|
3
|
+
periodos = 14
|
|
4
|
+
limite_linhas = 5
|
|
@@ -1 +1 @@
|
|
|
1
|
-
from . import model_media_movel
|
|
1
|
+
from . import model_media_movel
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from click.testing import CliRunner
|
|
2
|
-
|
|
3
|
-
from mtcli.mt import mt
|
|
4
|
-
|
|
5
|
-
run = CliRunner()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_exibe_a_media_movel_simples():
|
|
9
|
-
res = run.invoke(
|
|
10
|
-
mt, ["mm", "BBDC4", "--period", "D1", "--periodos", "20", "--limit", "1"]
|
|
11
|
-
)
|
|
12
|
-
assert res.output == "11.98 2025.02.27 00:00:00\n"
|
|
13
|
-
assert res.exit_code == 0
|
|
1
|
+
from click.testing import CliRunner
|
|
2
|
+
|
|
3
|
+
from mtcli.mt import mt
|
|
4
|
+
|
|
5
|
+
run = CliRunner()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_exibe_a_media_movel_simples():
|
|
9
|
+
res = run.invoke(
|
|
10
|
+
mt, ["mm", "BBDC4", "--period", "D1", "--periodos", "20", "--limit", "1"]
|
|
11
|
+
)
|
|
12
|
+
assert res.output == "11.98 2025.02.27 00:00:00\n"
|
|
13
|
+
assert res.exit_code == 0
|
{mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/mtcli/plugins/media_movel/tests/test_model_media_movel.py
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from ..models.model_media_movel import MediaMovelModel
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def test_sma():
|
|
5
|
-
assert MediaMovelModel([10, 20, 30], 3).calcula_sma() == [20.0]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_ema():
|
|
9
|
-
assert MediaMovelModel([10, 20, 30], 3).calcula_ema() == [20.0]
|
|
1
|
+
from ..models.model_media_movel import MediaMovelModel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_sma():
|
|
5
|
+
assert MediaMovelModel([10, 20, 30], 3).calcula_sma() == [20.0]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_ema():
|
|
9
|
+
assert MediaMovelModel([10, 20, 30], 3).calcula_ema() == [20.0]
|
|
File without changes
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from . import command, conf
|
|
2
|
-
from .command import vm
|
|
3
|
-
from .models import model_average_volume
|
|
1
|
+
from . import command, conf
|
|
2
|
+
from .command import vm
|
|
3
|
+
from .models import model_average_volume
|
|
File without changes
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mtcli"
|
|
3
|
-
version = "3.
|
|
4
|
-
description = "Aplicativo CLI para exibir gráficos do MetaTrader 5
|
|
3
|
+
version = "3.5.0.dev0"
|
|
4
|
+
description = "Aplicativo CLI para exibir gráficos do MetaTrader 5 screen reader friendly"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Valmir França da Silva",email = "vfranca3@gmail.com"}
|
|
7
7
|
]
|
|
8
|
-
license = "
|
|
8
|
+
license = "MIT"
|
|
9
|
+
license-files = ["LICENSE"]
|
|
9
10
|
readme = "README.md"
|
|
10
|
-
keywords = ["MetaTrader 5", "trading", "CLI"]
|
|
11
11
|
requires-python = ">=3.10,<3.14.0"
|
|
12
|
+
|
|
13
|
+
keywords = [
|
|
14
|
+
"trading",
|
|
15
|
+
"candlestick",
|
|
16
|
+
"metatrader5",
|
|
17
|
+
"mt5",
|
|
18
|
+
"cli",
|
|
19
|
+
"price-action"
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 4 - Beta",
|
|
24
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.10",
|
|
27
|
+
"Programming Language :: Python :: 3.11",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Operating System :: OS Independent",
|
|
31
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
32
|
+
]
|
|
33
|
+
|
|
12
34
|
dependencies = [
|
|
13
35
|
"click (>=8.2.1,<9.0.0)",
|
|
14
36
|
"metatrader5 (>=5.0.5260,<6.0.0)",
|
|
15
37
|
]
|
|
16
38
|
|
|
17
39
|
[project.urls]
|
|
18
|
-
homepage = "https://
|
|
40
|
+
homepage = "https://github.com:vfranca/mtcli"
|
|
19
41
|
repository = "https://github.com/vfranca/mtcli"
|
|
20
42
|
documentation = "https://mtcli.readthedocs.io/pt-br/latest"
|
|
21
43
|
issues = "https://github.com/vfranca/mtcli/issues"
|
mtcli-3.4.0.dev0/LICENSE
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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,36 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Gerencia o ciclo de conexão com o MetaTrader 5.
|
|
3
|
-
Fornece o contexto 'mt5_conexao' para uso seguro em blocos with.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from contextlib import contextmanager
|
|
7
|
-
import MetaTrader5 as mt5
|
|
8
|
-
from mtcli.logger import setup_logger
|
|
9
|
-
|
|
10
|
-
log = setup_logger()
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@contextmanager
|
|
14
|
-
def mt5_conexao():
|
|
15
|
-
"""
|
|
16
|
-
Context manager para conexão direta com o MetaTrader 5.
|
|
17
|
-
- Chama `mt5.initialize()` ao entrar no contexto.
|
|
18
|
-
- Chama `mt5.shutdown()` ao sair.
|
|
19
|
-
- Loga falhas e garante fechamento seguro.
|
|
20
|
-
"""
|
|
21
|
-
try:
|
|
22
|
-
log.info("Inicializando conexão com MetaTrader 5 via API oficial...")
|
|
23
|
-
if not mt5.initialize():
|
|
24
|
-
error = mt5.last_error()
|
|
25
|
-
log.error(f"Falha ao inicializar MetaTrader 5: {error}")
|
|
26
|
-
raise RuntimeError(f"Erro ao conectar ao MT5: {error}")
|
|
27
|
-
yield
|
|
28
|
-
except Exception as e:
|
|
29
|
-
log.error(f"Erro durante o uso da conexão MT5: {e}")
|
|
30
|
-
raise
|
|
31
|
-
finally:
|
|
32
|
-
try:
|
|
33
|
-
mt5.shutdown()
|
|
34
|
-
log.info("Conexão com MetaTrader 5 encerrada com sucesso.")
|
|
35
|
-
except Exception as e:
|
|
36
|
-
log.error(f"Erro ao encerrar conexão MT5: {e}")
|
|
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.4.0.dev0/mtcli/plugins/media_movel/tests → mtcli-3.5.0.dev0/mtcli/marketdata}/__init__.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
|
{mtcli-3.4.0.dev0/mtcli/plugins/range_medio/models → mtcli-3.5.0.dev0/mtcli/plugins}/__init__.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
|
{mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/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
|
{mtcli-3.4.0.dev0 → mtcli-3.5.0.dev0}/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
|