mtcli-renko 1.0.0.dev3__tar.gz → 1.1.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_renko-1.1.0.dev0/LICENSE +21 -0
- mtcli_renko-1.1.0.dev0/PKG-INFO +240 -0
- mtcli_renko-1.1.0.dev0/README.md +211 -0
- mtcli_renko-1.1.0.dev0/mtcli_renko/commands/renko.py +77 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/conf.py +17 -0
- mtcli_renko-1.1.0.dev0/mtcli_renko/controllers/renko_controller.py +66 -0
- mtcli_renko-1.1.0.dev0/mtcli_renko/models/renko_model.py +276 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/plugin.py +1 -0
- mtcli_renko-1.1.0.dev0/pyproject.toml +80 -0
- mtcli_renko-1.0.0.dev3/LICENSE +0 -674
- mtcli_renko-1.0.0.dev3/PKG-INFO +0 -48
- mtcli_renko-1.0.0.dev3/README.md +0 -28
- mtcli_renko-1.0.0.dev3/mtcli_renko/commands/renko.py +0 -90
- mtcli_renko-1.0.0.dev3/mtcli_renko/controllers/renko_controller.py +0 -42
- mtcli_renko-1.0.0.dev3/mtcli_renko/models/renko_model.py +0 -160
- mtcli_renko-1.0.0.dev3/pyproject.toml +0 -58
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/__init__.py +0 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/commands/__init__.py +0 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/controllers/__init__.py +0 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/domain/__init__.py +0 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/domain/timeframe.py +0 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/models/__init__.py +0 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/views/__init__.py +0 -0
- {mtcli_renko-1.0.0.dev3 → mtcli_renko-1.1.0.dev0}/mtcli_renko/views/renko_view.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 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.
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mtcli-renko
|
|
3
|
+
Version: 1.1.0.dev0
|
|
4
|
+
Summary: Renko plugin institucional para mtcli (MetaTrader 5)
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: trading,renko,metatrader5,mt5,cli,price-action
|
|
8
|
+
Author: Valmir França
|
|
9
|
+
Author-email: vfranca3@gmail.com
|
|
10
|
+
Requires-Python: >=3.10,<3.14
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
20
|
+
Requires-Dist: click (>=8.3.0,<9.0.0)
|
|
21
|
+
Requires-Dist: metatrader5 (>=5.0.5370,<6.0.0)
|
|
22
|
+
Requires-Dist: mtcli (>=3.2.0)
|
|
23
|
+
Project-URL: Documentation, https://vfranca.github.io/mtcli-renko
|
|
24
|
+
Project-URL: Homepage, https://github.com/vfranca/mtcli-renko
|
|
25
|
+
Project-URL: Issues, https://github.com/vfranca/mtcli-renko/issues
|
|
26
|
+
Project-URL: Repository, https://github.com/vfranca/mtcli-renko
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# mtcli-renko
|
|
30
|
+
|
|
31
|
+
Renko institucional para MetaTrader 5 integrado ao ecossistema `mtcli`.
|
|
32
|
+
|
|
33
|
+
Geração de gráfico Renko em modo texto (terminal), com:
|
|
34
|
+
|
|
35
|
+
- Renko simples
|
|
36
|
+
- Renko clássico (reversão 2x)
|
|
37
|
+
- Ancoragem real no último pregão
|
|
38
|
+
- Controle de barras por sessão
|
|
39
|
+
- Compatível com B3, Forex e ativos 24h
|
|
40
|
+
- Ideal para uso via CLI e automação
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Instalação
|
|
45
|
+
|
|
46
|
+
Via pip:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install mtcli-renko
|
|
50
|
+
````
|
|
51
|
+
|
|
52
|
+
Ou via Poetry:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
poetry add mtcli-renko
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Requisitos
|
|
61
|
+
|
|
62
|
+
* Python 3.10+
|
|
63
|
+
* MetaTrader 5 instalado
|
|
64
|
+
* Conta conectada ao terminal MT5
|
|
65
|
+
* Plugin `mtcli` configurado
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Uso
|
|
70
|
+
|
|
71
|
+
Após instalar, o comando fica disponível dentro do `mt`:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mt renko --symbol WINJ26 --brick 50
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Parâmetros
|
|
80
|
+
|
|
81
|
+
| Opção | Descrição |
|
|
82
|
+
| -------------------- | --------------------------------- |
|
|
83
|
+
| `--symbol`, `-s` | Ativo (ex: WINJ26) |
|
|
84
|
+
| `--brick`, `-b` | Tamanho do brick |
|
|
85
|
+
| `--timeframe`, `-t` | Timeframe (m1, m5, m15, h1, etc.) |
|
|
86
|
+
| `--bars`, `-n` | Quantidade de barras base |
|
|
87
|
+
| `--modo` | `simples` ou `classico` |
|
|
88
|
+
| `--ancorar-abertura` | Ancora no último pregão |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Exemplos
|
|
93
|
+
|
|
94
|
+
### Renko simples padrão
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
mt renko -s WINJ26 -b 50
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Renko clássico (reversão 2x)
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
mt renko -s WINJ26 -b 50 --modo classico
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Ancorado no último pregão
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
mt renko -s WINJ26 -b 50 --ancorar-abertura
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Todas as barras do último pregão
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
mt renko -s WINJ26 -b 50 --ancorar-abertura --bars 0
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Últimas 20 barras do último pregão
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
mt renko -s WINJ26 -b 50 --ancorar-abertura --bars 20
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Timeframes aceitos
|
|
127
|
+
|
|
128
|
+
Use valores simplificados:
|
|
129
|
+
|
|
130
|
+
* m1
|
|
131
|
+
* m5
|
|
132
|
+
* m15
|
|
133
|
+
* m30
|
|
134
|
+
* h1
|
|
135
|
+
* h4
|
|
136
|
+
* d1
|
|
137
|
+
|
|
138
|
+
O sistema faz o mapeamento automático para as constantes do MetaTrader 5.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Ancoragem Institucional
|
|
143
|
+
|
|
144
|
+
Quando `--ancorar-abertura` é ativado:
|
|
145
|
+
|
|
146
|
+
* Detecta o último candle disponível
|
|
147
|
+
* Descobre a data do último pregão real
|
|
148
|
+
* Filtra manualmente apenas aquele dia
|
|
149
|
+
* Ignora histórico anterior
|
|
150
|
+
* Funciona inclusive em domingos e feriados
|
|
151
|
+
|
|
152
|
+
Comportamento:
|
|
153
|
+
|
|
154
|
+
* `--bars 0` → todas as barras do último pregão
|
|
155
|
+
* `--bars N` → últimas N barras daquele pregão
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Modos de Construção
|
|
160
|
+
|
|
161
|
+
### Simples
|
|
162
|
+
|
|
163
|
+
Cria bricks contínuos sem regra de reversão 2x.
|
|
164
|
+
|
|
165
|
+
### Clássico
|
|
166
|
+
|
|
167
|
+
Implementa reversão apenas quando o preço move 2x o tamanho do brick na direção oposta.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Estrutura do Projeto
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
mtcli_renko/
|
|
175
|
+
│
|
|
176
|
+
├── commands/
|
|
177
|
+
├── controllers/
|
|
178
|
+
├── models/
|
|
179
|
+
├── views/
|
|
180
|
+
├── conf.py
|
|
181
|
+
└── enums.py
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Arquitetura baseada em MVC, alinhada ao padrão do `mtcli-trade`.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Casos de Uso
|
|
189
|
+
|
|
190
|
+
* Leitura de estrutura (H1, H2, H3, L1, L2)
|
|
191
|
+
* Identificação de BRF / BLF
|
|
192
|
+
* Automação de análise
|
|
193
|
+
* Backtesting via script
|
|
194
|
+
* Operação institucional via terminal
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Compatibilidade
|
|
199
|
+
|
|
200
|
+
* B3 (ex: WIN, WDO)
|
|
201
|
+
* Forex
|
|
202
|
+
* Cripto
|
|
203
|
+
* Ativos 24h
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Roadmap
|
|
208
|
+
|
|
209
|
+
* [ ] Múltiplas sessões
|
|
210
|
+
* [ ] Filtro de horário (09:00–18:00)
|
|
211
|
+
* [ ] VWAP integrada
|
|
212
|
+
* [ ] Detecção automática de estrutura (H1/H2/L2)
|
|
213
|
+
* [ ] Exportação CSV
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Licença
|
|
218
|
+
|
|
219
|
+
MIT License
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Autor
|
|
224
|
+
|
|
225
|
+
Valmir França
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Contribuição
|
|
230
|
+
|
|
231
|
+
Pull requests são bem-vindos.
|
|
232
|
+
Para mudanças maiores, abra uma issue antes para discussão.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Aviso
|
|
237
|
+
|
|
238
|
+
Este software não constitui recomendação de investimento.
|
|
239
|
+
Uso por conta e risco do operador.
|
|
240
|
+
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# mtcli-renko
|
|
2
|
+
|
|
3
|
+
Renko institucional para MetaTrader 5 integrado ao ecossistema `mtcli`.
|
|
4
|
+
|
|
5
|
+
Geração de gráfico Renko em modo texto (terminal), com:
|
|
6
|
+
|
|
7
|
+
- Renko simples
|
|
8
|
+
- Renko clássico (reversão 2x)
|
|
9
|
+
- Ancoragem real no último pregão
|
|
10
|
+
- Controle de barras por sessão
|
|
11
|
+
- Compatível com B3, Forex e ativos 24h
|
|
12
|
+
- Ideal para uso via CLI e automação
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Instalação
|
|
17
|
+
|
|
18
|
+
Via pip:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install mtcli-renko
|
|
22
|
+
````
|
|
23
|
+
|
|
24
|
+
Ou via Poetry:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
poetry add mtcli-renko
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Requisitos
|
|
33
|
+
|
|
34
|
+
* Python 3.10+
|
|
35
|
+
* MetaTrader 5 instalado
|
|
36
|
+
* Conta conectada ao terminal MT5
|
|
37
|
+
* Plugin `mtcli` configurado
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Uso
|
|
42
|
+
|
|
43
|
+
Após instalar, o comando fica disponível dentro do `mt`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
mt renko --symbol WINJ26 --brick 50
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Parâmetros
|
|
52
|
+
|
|
53
|
+
| Opção | Descrição |
|
|
54
|
+
| -------------------- | --------------------------------- |
|
|
55
|
+
| `--symbol`, `-s` | Ativo (ex: WINJ26) |
|
|
56
|
+
| `--brick`, `-b` | Tamanho do brick |
|
|
57
|
+
| `--timeframe`, `-t` | Timeframe (m1, m5, m15, h1, etc.) |
|
|
58
|
+
| `--bars`, `-n` | Quantidade de barras base |
|
|
59
|
+
| `--modo` | `simples` ou `classico` |
|
|
60
|
+
| `--ancorar-abertura` | Ancora no último pregão |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Exemplos
|
|
65
|
+
|
|
66
|
+
### Renko simples padrão
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
mt renko -s WINJ26 -b 50
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Renko clássico (reversão 2x)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mt renko -s WINJ26 -b 50 --modo classico
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Ancorado no último pregão
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
mt renko -s WINJ26 -b 50 --ancorar-abertura
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Todas as barras do último pregão
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
mt renko -s WINJ26 -b 50 --ancorar-abertura --bars 0
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Últimas 20 barras do último pregão
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
mt renko -s WINJ26 -b 50 --ancorar-abertura --bars 20
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Timeframes aceitos
|
|
99
|
+
|
|
100
|
+
Use valores simplificados:
|
|
101
|
+
|
|
102
|
+
* m1
|
|
103
|
+
* m5
|
|
104
|
+
* m15
|
|
105
|
+
* m30
|
|
106
|
+
* h1
|
|
107
|
+
* h4
|
|
108
|
+
* d1
|
|
109
|
+
|
|
110
|
+
O sistema faz o mapeamento automático para as constantes do MetaTrader 5.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Ancoragem Institucional
|
|
115
|
+
|
|
116
|
+
Quando `--ancorar-abertura` é ativado:
|
|
117
|
+
|
|
118
|
+
* Detecta o último candle disponível
|
|
119
|
+
* Descobre a data do último pregão real
|
|
120
|
+
* Filtra manualmente apenas aquele dia
|
|
121
|
+
* Ignora histórico anterior
|
|
122
|
+
* Funciona inclusive em domingos e feriados
|
|
123
|
+
|
|
124
|
+
Comportamento:
|
|
125
|
+
|
|
126
|
+
* `--bars 0` → todas as barras do último pregão
|
|
127
|
+
* `--bars N` → últimas N barras daquele pregão
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Modos de Construção
|
|
132
|
+
|
|
133
|
+
### Simples
|
|
134
|
+
|
|
135
|
+
Cria bricks contínuos sem regra de reversão 2x.
|
|
136
|
+
|
|
137
|
+
### Clássico
|
|
138
|
+
|
|
139
|
+
Implementa reversão apenas quando o preço move 2x o tamanho do brick na direção oposta.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Estrutura do Projeto
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
mtcli_renko/
|
|
147
|
+
│
|
|
148
|
+
├── commands/
|
|
149
|
+
├── controllers/
|
|
150
|
+
├── models/
|
|
151
|
+
├── views/
|
|
152
|
+
├── conf.py
|
|
153
|
+
└── enums.py
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Arquitetura baseada em MVC, alinhada ao padrão do `mtcli-trade`.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Casos de Uso
|
|
161
|
+
|
|
162
|
+
* Leitura de estrutura (H1, H2, H3, L1, L2)
|
|
163
|
+
* Identificação de BRF / BLF
|
|
164
|
+
* Automação de análise
|
|
165
|
+
* Backtesting via script
|
|
166
|
+
* Operação institucional via terminal
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Compatibilidade
|
|
171
|
+
|
|
172
|
+
* B3 (ex: WIN, WDO)
|
|
173
|
+
* Forex
|
|
174
|
+
* Cripto
|
|
175
|
+
* Ativos 24h
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Roadmap
|
|
180
|
+
|
|
181
|
+
* [ ] Múltiplas sessões
|
|
182
|
+
* [ ] Filtro de horário (09:00–18:00)
|
|
183
|
+
* [ ] VWAP integrada
|
|
184
|
+
* [ ] Detecção automática de estrutura (H1/H2/L2)
|
|
185
|
+
* [ ] Exportação CSV
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Licença
|
|
190
|
+
|
|
191
|
+
MIT License
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Autor
|
|
196
|
+
|
|
197
|
+
Valmir França
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Contribuição
|
|
202
|
+
|
|
203
|
+
Pull requests são bem-vindos.
|
|
204
|
+
Para mudanças maiores, abra uma issue antes para discussão.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Aviso
|
|
209
|
+
|
|
210
|
+
Este software não constitui recomendação de investimento.
|
|
211
|
+
Uso por conta e risco do operador.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Comando CLI para geração de gráfico Renko.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from ..controllers.renko_controller import RenkoController
|
|
8
|
+
from ..views.renko_view import exibir_renko
|
|
9
|
+
from ..domain.timeframe import Timeframe
|
|
10
|
+
from mtcli.logger import setup_logger
|
|
11
|
+
from ..conf import SYMBOL, BRICK, PERIOD, BARS, DATA_MODE, MAX_TICKS
|
|
12
|
+
|
|
13
|
+
log = setup_logger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@click.command()
|
|
17
|
+
@click.version_option(package_name="mtcli-renko")
|
|
18
|
+
@click.option("--symbol", "-s", default=SYMBOL, show_default=True)
|
|
19
|
+
@click.option("--brick", "-b", default=BRICK, show_default=True, type=float)
|
|
20
|
+
@click.option("--timeframe", "-t", default=PERIOD, show_default=True)
|
|
21
|
+
@click.option("--bars", "-n", default=BARS, show_default=True, type=int)
|
|
22
|
+
@click.option("--numerar/--no-numerar", default=False, show_default=True)
|
|
23
|
+
@click.option(
|
|
24
|
+
"--modo",
|
|
25
|
+
type=click.Choice(["simples", "classico"], case_sensitive=False),
|
|
26
|
+
default="simples",
|
|
27
|
+
show_default=True,
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--ancorar-abertura",
|
|
31
|
+
is_flag=True,
|
|
32
|
+
default=False,
|
|
33
|
+
show_default=True,
|
|
34
|
+
)
|
|
35
|
+
@click.option(
|
|
36
|
+
"--data-mode",
|
|
37
|
+
type=click.Choice(["candle", "tick"], case_sensitive=False),
|
|
38
|
+
default=DATA_MODE,
|
|
39
|
+
show_default=True,
|
|
40
|
+
)
|
|
41
|
+
@click.option(
|
|
42
|
+
"--max-ticks",
|
|
43
|
+
default=MAX_TICKS,
|
|
44
|
+
show_default=True,
|
|
45
|
+
type=int,
|
|
46
|
+
help="Limite máximo de ticks processados no modo tick.",
|
|
47
|
+
)
|
|
48
|
+
def renko(
|
|
49
|
+
symbol,
|
|
50
|
+
brick,
|
|
51
|
+
timeframe,
|
|
52
|
+
bars,
|
|
53
|
+
numerar,
|
|
54
|
+
modo,
|
|
55
|
+
ancorar_abertura,
|
|
56
|
+
data_mode,
|
|
57
|
+
max_ticks,
|
|
58
|
+
):
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
tf_enum = Timeframe.from_string(timeframe)
|
|
62
|
+
except ValueError as e:
|
|
63
|
+
raise click.BadParameter(str(e))
|
|
64
|
+
|
|
65
|
+
controller = RenkoController(
|
|
66
|
+
symbol,
|
|
67
|
+
brick,
|
|
68
|
+
tf_enum.mt5_const,
|
|
69
|
+
bars,
|
|
70
|
+
modo,
|
|
71
|
+
ancorar_abertura,
|
|
72
|
+
data_mode,
|
|
73
|
+
max_ticks,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
bricks = controller.executar()
|
|
77
|
+
exibir_renko(bricks, numerar=numerar)
|
|
@@ -70,3 +70,20 @@ DIGITS = int(os.getenv(
|
|
|
70
70
|
"DIGITS",
|
|
71
71
|
_get_config_value("RENKO", "digits", 2)
|
|
72
72
|
))
|
|
73
|
+
|
|
74
|
+
# Hora oficial de abertura do pregão (HH:MM)
|
|
75
|
+
SESSION_OPEN = os.getenv(
|
|
76
|
+
"SESSION_OPEN",
|
|
77
|
+
_get_config_value("RENKO", "session_open", "09:00")
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
DATA_MODE = os.getenv(
|
|
81
|
+
"DATA_MODE",
|
|
82
|
+
_get_config_value("RENKO", "data_mode", "candle")
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
MAX_TICKS = int(os.getenv(
|
|
86
|
+
"MAX_TICKS",
|
|
87
|
+
_get_config_value("RENKO", "max_ticks", 10000)
|
|
88
|
+
))
|
|
89
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Renko controller.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ..models.renko_model import RenkoModel
|
|
6
|
+
from mtcli.logger import setup_logger
|
|
7
|
+
|
|
8
|
+
log = setup_logger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RenkoController:
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
symbol,
|
|
16
|
+
brick_size,
|
|
17
|
+
timeframe,
|
|
18
|
+
quantidade,
|
|
19
|
+
modo="simples",
|
|
20
|
+
ancorar_abertura=False,
|
|
21
|
+
data_mode="candle",
|
|
22
|
+
max_ticks=3000,
|
|
23
|
+
):
|
|
24
|
+
self.model = RenkoModel(symbol, brick_size)
|
|
25
|
+
self.timeframe = timeframe
|
|
26
|
+
self.quantidade = quantidade
|
|
27
|
+
self.modo = modo
|
|
28
|
+
self.ancorar_abertura = ancorar_abertura
|
|
29
|
+
self.data_mode = data_mode
|
|
30
|
+
self.max_ticks = max_ticks
|
|
31
|
+
|
|
32
|
+
def executar(self):
|
|
33
|
+
|
|
34
|
+
# -------------------------------------------------
|
|
35
|
+
# TICK MODE
|
|
36
|
+
# -------------------------------------------------
|
|
37
|
+
|
|
38
|
+
if self.data_mode == "tick":
|
|
39
|
+
|
|
40
|
+
ticks = self.model.obter_ticks(
|
|
41
|
+
timeframe=self.timeframe,
|
|
42
|
+
max_ticks=self.max_ticks,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
if ticks is None or len(ticks) == 0:
|
|
46
|
+
return []
|
|
47
|
+
|
|
48
|
+
return self.model.construir_renko_ticks(ticks)
|
|
49
|
+
|
|
50
|
+
# -------------------------------------------------
|
|
51
|
+
# CANDLE MODE
|
|
52
|
+
# -------------------------------------------------
|
|
53
|
+
|
|
54
|
+
rates = self.model.obter_rates(
|
|
55
|
+
self.timeframe,
|
|
56
|
+
self.quantidade,
|
|
57
|
+
ancorar_abertura=self.ancorar_abertura,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if rates is None or len(rates) == 0:
|
|
61
|
+
return []
|
|
62
|
+
|
|
63
|
+
return self.model.construir_renko(
|
|
64
|
+
rates,
|
|
65
|
+
modo=self.modo,
|
|
66
|
+
)
|