mtcli-volume 2.5.1__tar.gz → 2.5.2__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 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,21 +1,27 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mtcli-volume
3
- Version: 2.5.1
3
+ Version: 2.5.2
4
4
  Summary: Plugin mtcli para cálculo e exibição de Volume Profile no terminal
5
+ License-Expression: MIT
5
6
  License-File: LICENSE
7
+ Keywords: trading,volume-profile,volume,metatrader5,mt5,cli,acessibilidade,screen reader friendly
6
8
  Author: Valmir França
7
9
  Author-email: vfranca3@gmail.com
8
10
  Maintainer: Valmir França
9
11
  Maintainer-email: vfranca3@gmail.com
10
12
  Requires-Python: >=3.10,<3.14
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
11
15
  Classifier: Programming Language :: Python :: 3
12
16
  Classifier: Programming Language :: Python :: 3.10
13
17
  Classifier: Programming Language :: Python :: 3.11
14
18
  Classifier: Programming Language :: Python :: 3.12
15
19
  Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Topic :: Office/Business :: Financial :: Investment
16
22
  Requires-Dist: click (>=8.3.0,<9.0.0)
17
23
  Requires-Dist: metatrader5 (>=5.0.5370,<6.0.0)
18
- Requires-Dist: mtcli (>=3.2.0)
24
+ Requires-Dist: mtcli (>=3.7.0)
19
25
  Requires-Dist: tzdata (>=2025.2)
20
26
  Project-URL: Documentation, https://mtcli-volume.readthedocs.io
21
27
  Project-URL: Homepage, https://github.com/vfranca/mtcli-volume
@@ -215,5 +221,5 @@ Pull requests são bem-vindos, especialmente para:
215
221
 
216
222
  ## Licença
217
223
 
218
- GPL License
224
+ MIT License
219
225
 
@@ -1,193 +1,193 @@
1
- # mtcli-volume
2
-
3
- Plugin do **mtcli** para cálculo e visualização de **Volume Profile** diretamente no terminal, com foco em:
4
-
5
- - Precisão técnica (distribuição High–Low)
6
- - Leitura profissional de mercado
7
- - Total acessibilidade (screen reader friendly)
8
- - Integração com MetaTrader 5
9
-
10
- ---
11
-
12
- ## Principais recursos
13
-
14
- - **Volume Profile por faixa High–Low**
15
- - O volume de cada candle é distribuído uniformemente entre todas as faixas de preço tocadas entre o **LOW** e o **HIGH**
16
- - Modelo mais próximo do Volume Profile clássico (VAP)
17
-
18
- - **Estatísticas de Market Profile**
19
- - POC (Point of Control)
20
- - Área de Valor (70%)
21
- - HVNs e LVNs com critérios profissionais
22
-
23
- - ⚙️ **Critérios avançados para HVN/LVN**
24
- - Baseado na média (multiplicadores)
25
- - Baseado em percentis (ex: 80% / 20%)
26
-
27
- - **100% acessível**
28
- - Saída textual linear
29
- - Compatível com NVDA, JAWS e leitores de tela
30
- - Sem dependência de cores ou gráficos visuais
31
-
32
- - **Arquitetura MVC**
33
- - Model: cálculos e dados
34
- - Controller: fluxo de negócio
35
- - View: apresentação no terminal
36
- - CLI: interface de linha de comando
37
-
38
- ---
39
-
40
- ## Instalação
41
-
42
- Via PyPI:
43
-
44
- ```bash
45
- pip install mtcli-volume
46
- ````
47
-
48
- Ou com Poetry:
49
-
50
- ```bash
51
- poetry add mtcli-volume
52
- ```
53
-
54
- > ⚠️ Requer MetaTrader 5 instalado e configurado corretamente no sistema.
55
-
56
- ---
57
-
58
- ## Uso básico
59
-
60
- Após a instalação, o comando é registrado automaticamente no `mtcli`:
61
-
62
- ```bash
63
- mt vp
64
- ```
65
-
66
- Exemplo completo:
67
-
68
- ```bash
69
- mt vp \
70
- --symbol WING26 \
71
- --period m1 \
72
- --limit 500 \
73
- --range 100 \
74
- --volume tick \
75
- --hvn-criterio media \
76
- --verbose
77
- ```
78
-
79
- ---
80
-
81
- ## 🔧 Opções disponíveis
82
-
83
- | Opção | Descrição |
84
- | ------------------- | -------------------------------------------- |
85
- | `--symbol`, `-s` | Símbolo do ativo (ex: WIN, WDO, PETR4) |
86
- | `--period`, `-p` | Timeframe (m1, m5, m15, h1, etc.) |
87
- | `--limit`, `-l` | Quantidade de candles analisados |
88
- | `--range`, `-r` | Tamanho da faixa de preço |
89
- | `--volume`, `-v` | Tipo de volume (`tick` ou `real`) |
90
- | `--inicio`, `-i` | Data/hora inicial (`YYYY-MM-DD HH:MM`) |
91
- | `--fim`, `-f` | Data/hora final (`YYYY-MM-DD HH:MM`) |
92
- | `--timezone`, `-tz` | Fuso horário para exibição |
93
- | `--hvn-criterio` | Critério de HVN/LVN (`media` ou `percentil`) |
94
- | `--verbose`, `-vv` | Exibe informações detalhadas |
95
-
96
- ---
97
-
98
- ## Metodologia de cálculo
99
-
100
- ### Volume Profile
101
-
102
- * Cada candle contribui volume para **todas as faixas de preço** entre seu `low` e `high`
103
- * O volume é distribuído **uniformemente**
104
- * Evita o viés de concentrar volume apenas no preço de fechamento
105
-
106
- ### HVN / LVN
107
-
108
- Critérios disponíveis:
109
-
110
- * **Média**
111
-
112
- * HVN: volume ≥ média × multiplicador
113
- * LVN: volume ≤ média × multiplicador
114
-
115
- * **Percentil**
116
-
117
- * HVN: acima do percentil superior (ex: 80%)
118
- * LVN: abaixo do percentil inferior (ex: 20%)
119
-
120
- ---
121
-
122
- ## Acessibilidade
123
-
124
- Este plugin foi projetado para uso total com leitores de tela:
125
-
126
- * Tabelas em texto puro
127
- * Distribuição expressa em percentuais
128
- * Estatísticas narráveis
129
- * Sem gráficos ASCII ruidosos
130
-
131
- Funciona corretamente com:
132
-
133
- * NVDA
134
- * JAWS
135
- * VoiceOver (terminal)
136
-
137
- ---
138
-
139
- ## Arquitetura
140
-
141
- ```text
142
- mtcli_volume/
143
- ├── cli.py # Interface de linha de comando
144
- ├── controller.py # Orquestração do fluxo
145
- ├── model.py # Cálculos e acesso ao MT5
146
- ├── view.py # Apresentação acessível
147
- ├── conf.py # Configurações padrão
148
- └── plugin.py # Registro no mtcli
149
- ```
150
-
151
- ---
152
-
153
- ## Exemplo de saída
154
-
155
- ```text
156
- Volume Profile — WING26
157
-
158
- Preço | Volume | Distribuição
159
- -------------------------------------------------------
160
- 186300.00 | 18.250 | 72.4% do máximo
161
- 186200.00 | 25.190 | 100.0% do máximo
162
- 186100.00 | 14.880 | 59.1% do máximo
163
-
164
- Estatísticas
165
- POC : 186200.00
166
- Área de Valor : 185900.00 → 186300.00
167
- HVNs : 186200.00, 186100.00
168
- LVNs : 185700.00
169
- ```
170
-
171
- ---
172
-
173
- ## Testes
174
-
175
- O plugin foi projetado para facilitar testes unitários do cálculo no `model.py`,
176
- permitindo validação independente do MetaTrader 5.
177
-
178
- ---
179
-
180
- ## Contribuição
181
-
182
- Pull requests são bem-vindos, especialmente para:
183
-
184
- * Novos critérios de HVN/LVN
185
- * Value Area expandida a partir do POC
186
- * Modo TPO
187
- * Integração com VWAP e Footprint
188
-
189
- ---
190
-
191
- ## Licença
192
-
193
- GPL License
1
+ # mtcli-volume
2
+
3
+ Plugin do **mtcli** para cálculo e visualização de **Volume Profile** diretamente no terminal, com foco em:
4
+
5
+ - Precisão técnica (distribuição High–Low)
6
+ - Leitura profissional de mercado
7
+ - Total acessibilidade (screen reader friendly)
8
+ - Integração com MetaTrader 5
9
+
10
+ ---
11
+
12
+ ## Principais recursos
13
+
14
+ - **Volume Profile por faixa High–Low**
15
+ - O volume de cada candle é distribuído uniformemente entre todas as faixas de preço tocadas entre o **LOW** e o **HIGH**
16
+ - Modelo mais próximo do Volume Profile clássico (VAP)
17
+
18
+ - **Estatísticas de Market Profile**
19
+ - POC (Point of Control)
20
+ - Área de Valor (70%)
21
+ - HVNs e LVNs com critérios profissionais
22
+
23
+ - ⚙️ **Critérios avançados para HVN/LVN**
24
+ - Baseado na média (multiplicadores)
25
+ - Baseado em percentis (ex: 80% / 20%)
26
+
27
+ - **100% acessível**
28
+ - Saída textual linear
29
+ - Compatível com NVDA, JAWS e leitores de tela
30
+ - Sem dependência de cores ou gráficos visuais
31
+
32
+ - **Arquitetura MVC**
33
+ - Model: cálculos e dados
34
+ - Controller: fluxo de negócio
35
+ - View: apresentação no terminal
36
+ - CLI: interface de linha de comando
37
+
38
+ ---
39
+
40
+ ## Instalação
41
+
42
+ Via PyPI:
43
+
44
+ ```bash
45
+ pip install mtcli-volume
46
+ ````
47
+
48
+ Ou com Poetry:
49
+
50
+ ```bash
51
+ poetry add mtcli-volume
52
+ ```
53
+
54
+ > ⚠️ Requer MetaTrader 5 instalado e configurado corretamente no sistema.
55
+
56
+ ---
57
+
58
+ ## Uso básico
59
+
60
+ Após a instalação, o comando é registrado automaticamente no `mtcli`:
61
+
62
+ ```bash
63
+ mt vp
64
+ ```
65
+
66
+ Exemplo completo:
67
+
68
+ ```bash
69
+ mt vp \
70
+ --symbol WING26 \
71
+ --period m1 \
72
+ --limit 500 \
73
+ --range 100 \
74
+ --volume tick \
75
+ --hvn-criterio media \
76
+ --verbose
77
+ ```
78
+
79
+ ---
80
+
81
+ ## 🔧 Opções disponíveis
82
+
83
+ | Opção | Descrição |
84
+ | ------------------- | -------------------------------------------- |
85
+ | `--symbol`, `-s` | Símbolo do ativo (ex: WIN, WDO, PETR4) |
86
+ | `--period`, `-p` | Timeframe (m1, m5, m15, h1, etc.) |
87
+ | `--limit`, `-l` | Quantidade de candles analisados |
88
+ | `--range`, `-r` | Tamanho da faixa de preço |
89
+ | `--volume`, `-v` | Tipo de volume (`tick` ou `real`) |
90
+ | `--inicio`, `-i` | Data/hora inicial (`YYYY-MM-DD HH:MM`) |
91
+ | `--fim`, `-f` | Data/hora final (`YYYY-MM-DD HH:MM`) |
92
+ | `--timezone`, `-tz` | Fuso horário para exibição |
93
+ | `--hvn-criterio` | Critério de HVN/LVN (`media` ou `percentil`) |
94
+ | `--verbose`, `-vv` | Exibe informações detalhadas |
95
+
96
+ ---
97
+
98
+ ## Metodologia de cálculo
99
+
100
+ ### Volume Profile
101
+
102
+ * Cada candle contribui volume para **todas as faixas de preço** entre seu `low` e `high`
103
+ * O volume é distribuído **uniformemente**
104
+ * Evita o viés de concentrar volume apenas no preço de fechamento
105
+
106
+ ### HVN / LVN
107
+
108
+ Critérios disponíveis:
109
+
110
+ * **Média**
111
+
112
+ * HVN: volume ≥ média × multiplicador
113
+ * LVN: volume ≤ média × multiplicador
114
+
115
+ * **Percentil**
116
+
117
+ * HVN: acima do percentil superior (ex: 80%)
118
+ * LVN: abaixo do percentil inferior (ex: 20%)
119
+
120
+ ---
121
+
122
+ ## Acessibilidade
123
+
124
+ Este plugin foi projetado para uso total com leitores de tela:
125
+
126
+ * Tabelas em texto puro
127
+ * Distribuição expressa em percentuais
128
+ * Estatísticas narráveis
129
+ * Sem gráficos ASCII ruidosos
130
+
131
+ Funciona corretamente com:
132
+
133
+ * NVDA
134
+ * JAWS
135
+ * VoiceOver (terminal)
136
+
137
+ ---
138
+
139
+ ## Arquitetura
140
+
141
+ ```text
142
+ mtcli_volume/
143
+ ├── cli.py # Interface de linha de comando
144
+ ├── controller.py # Orquestração do fluxo
145
+ ├── model.py # Cálculos e acesso ao MT5
146
+ ├── view.py # Apresentação acessível
147
+ ├── conf.py # Configurações padrão
148
+ └── plugin.py # Registro no mtcli
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Exemplo de saída
154
+
155
+ ```text
156
+ Volume Profile — WING26
157
+
158
+ Preço | Volume | Distribuição
159
+ -------------------------------------------------------
160
+ 186300.00 | 18.250 | 72.4% do máximo
161
+ 186200.00 | 25.190 | 100.0% do máximo
162
+ 186100.00 | 14.880 | 59.1% do máximo
163
+
164
+ Estatísticas
165
+ POC : 186200.00
166
+ Área de Valor : 185900.00 → 186300.00
167
+ HVNs : 186200.00, 186100.00
168
+ LVNs : 185700.00
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Testes
174
+
175
+ O plugin foi projetado para facilitar testes unitários do cálculo no `model.py`,
176
+ permitindo validação independente do MetaTrader 5.
177
+
178
+ ---
179
+
180
+ ## Contribuição
181
+
182
+ Pull requests são bem-vindos, especialmente para:
183
+
184
+ * Novos critérios de HVN/LVN
185
+ * Value Area expandida a partir do POC
186
+ * Modo TPO
187
+ * Integração com VWAP e Footprint
188
+
189
+ ---
190
+
191
+ ## Licença
192
+
193
+ MIT License
@@ -1,102 +1,102 @@
1
- """
2
- Controller do plugin mtcli-volume.
3
- """
4
-
5
- from datetime import datetime, timedelta, timezone
6
- import zoneinfo
7
- import numpy as np
8
-
9
- from mtcli.logger import setup_logger
10
- from .model import calcular_profile, calcular_estatisticas, obter_rates
11
-
12
- log = setup_logger()
13
-
14
-
15
- def resolver_inicio_ancorado(anchor: str, tz):
16
- """
17
- Resolve a data-base da ancoragem (sem forçar horário fixo).
18
- """
19
- agora = datetime.now(tz)
20
-
21
- if anchor == "day":
22
- return agora.replace(hour=0, minute=0, second=0, microsecond=0)
23
-
24
- if anchor == "week":
25
- inicio_semana = agora - timedelta(days=agora.weekday())
26
- return inicio_semana.replace(hour=0, minute=0, second=0, microsecond=0)
27
-
28
- if anchor == "month":
29
- return agora.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
30
-
31
- return None
32
-
33
-
34
- def calcular_volume_profile(
35
- symbol,
36
- period,
37
- limit,
38
- step,
39
- volume,
40
- inicio=None,
41
- fim=None,
42
- anchor="day",
43
- verbose=False,
44
- timezone_str="America/Sao_Paulo",
45
- criterio_hvn="media",
46
- ):
47
- volume = volume.lower().strip()
48
- if volume not in ("tick", "real"):
49
- raise ValueError("Tipo de volume inválido. Use 'tick' ou 'real'.")
50
-
51
- try:
52
- fuso = zoneinfo.ZoneInfo(timezone_str)
53
- except Exception:
54
- fuso = timezone(timedelta(hours=-3))
55
-
56
- # Resolve ancoragem se --inicio não foi informado
57
- if inicio is None:
58
- inicio = resolver_inicio_ancorado(anchor, fuso)
59
-
60
- rates = None
61
- tentativas = 0
62
- max_tentativas = 7
63
-
64
- while tentativas < max_tentativas:
65
- rates = obter_rates(symbol, period, limit, inicio, fim)
66
- if rates is not None and isinstance(rates, np.ndarray) and len(rates) > 0:
67
- break
68
-
69
- inicio -= timedelta(days=1)
70
- tentativas += 1
71
-
72
- if rates is None or len(rates) == 0:
73
- log.error("Nenhum dado retornado após fallback de ancoragem.")
74
- return {}, {}, {}
75
-
76
- profile = calcular_profile(rates, step, volume)
77
- stats = calcular_estatisticas(profile, criterio=criterio_hvn)
78
-
79
- try:
80
- inicio_real = datetime.utcfromtimestamp(
81
- float(rates[0]["time"])
82
- ).astimezone(fuso)
83
-
84
- fim_real = datetime.utcfromtimestamp(
85
- float(rates[-1]["time"])
86
- ).astimezone(fuso)
87
-
88
- except Exception:
89
- inicio_real = fim_real = "?"
90
-
91
- info = {
92
- "symbol": symbol,
93
- "period": period,
94
- "candles": len(rates),
95
- "inicio": str(inicio_real),
96
- "fim": str(fim_real),
97
- "timezone": timezone_str,
98
- "anchor": anchor,
99
- "fallback_days": tentativas,
100
- }
101
-
102
- return profile, stats, info
1
+ """
2
+ Controller do plugin mtcli-volume.
3
+ """
4
+
5
+ from datetime import datetime, timedelta, timezone
6
+ import zoneinfo
7
+ import numpy as np
8
+
9
+ from mtcli.logger import setup_logger
10
+ from .model import calcular_profile, calcular_estatisticas, obter_rates
11
+
12
+ log = setup_logger()
13
+
14
+
15
+ def resolver_inicio_ancorado(anchor: str, tz):
16
+ """
17
+ Resolve a data-base da ancoragem (sem forçar horário fixo).
18
+ """
19
+ agora = datetime.now(tz)
20
+
21
+ if anchor == "day":
22
+ return agora.replace(hour=0, minute=0, second=0, microsecond=0)
23
+
24
+ if anchor == "week":
25
+ inicio_semana = agora - timedelta(days=agora.weekday())
26
+ return inicio_semana.replace(hour=0, minute=0, second=0, microsecond=0)
27
+
28
+ if anchor == "month":
29
+ return agora.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
30
+
31
+ return None
32
+
33
+
34
+ def calcular_volume_profile(
35
+ symbol,
36
+ period,
37
+ limit,
38
+ step,
39
+ volume,
40
+ inicio=None,
41
+ fim=None,
42
+ anchor="day",
43
+ verbose=False,
44
+ timezone_str="America/Sao_Paulo",
45
+ criterio_hvn="media",
46
+ ):
47
+ volume = volume.lower().strip()
48
+ if volume not in ("tick", "real"):
49
+ raise ValueError("Tipo de volume inválido. Use 'tick' ou 'real'.")
50
+
51
+ try:
52
+ fuso = zoneinfo.ZoneInfo(timezone_str)
53
+ except Exception:
54
+ fuso = timezone(timedelta(hours=-3))
55
+
56
+ # Resolve ancoragem se --inicio não foi informado
57
+ if inicio is None:
58
+ inicio = resolver_inicio_ancorado(anchor, fuso)
59
+
60
+ rates = None
61
+ tentativas = 0
62
+ max_tentativas = 7
63
+
64
+ while tentativas < max_tentativas:
65
+ rates = obter_rates(symbol, period, limit, inicio, fim)
66
+ if rates is not None and isinstance(rates, np.ndarray) and len(rates) > 0:
67
+ break
68
+
69
+ inicio -= timedelta(days=1)
70
+ tentativas += 1
71
+
72
+ if rates is None or len(rates) == 0:
73
+ log.error("Nenhum dado retornado após fallback de ancoragem.")
74
+ return {}, {}, {}
75
+
76
+ profile = calcular_profile(rates, step, volume)
77
+ stats = calcular_estatisticas(profile, criterio=criterio_hvn)
78
+
79
+ try:
80
+ inicio_real = datetime.utcfromtimestamp(
81
+ float(rates[0]["time"])
82
+ ).astimezone(fuso)
83
+
84
+ fim_real = datetime.utcfromtimestamp(
85
+ float(rates[-1]["time"])
86
+ ).astimezone(fuso)
87
+
88
+ except Exception:
89
+ inicio_real = fim_real = "?"
90
+
91
+ info = {
92
+ "symbol": symbol,
93
+ "period": period,
94
+ "candles": len(rates),
95
+ "inicio": str(inicio_real),
96
+ "fim": str(fim_real),
97
+ "timezone": timezone_str,
98
+ "anchor": anchor,
99
+ "fallback_days": tentativas,
100
+ }
101
+
102
+ return profile, stats, info