mtcli-volume 2.0.0.dev0__tar.gz → 2.0.0.dev1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mtcli-volume
3
- Version: 2.0.0.dev0
3
+ Version: 2.0.0.dev1
4
4
  Summary: Plugin mtcli para exibir o volume profile
5
5
  Author: Valmir França da Silva
6
6
  Author-email: vfranca3@gmail.com
@@ -1,35 +1,30 @@
1
- import click
2
- from mtcli_volume.controllers.volume_controller import calcular_volume_profile
3
- from mtcli_volume.views.volume_view import exibir_volume_profile
4
- from mtcli_volume.conf import SYMBOL, PERIOD, BARS, STEP, VOLUME
5
-
6
-
7
- @click.command(
8
- "volume",
9
- help="Exibe o Volume Profile, agrupando volumes por faixa de preço no histórico recente."
10
- )
11
- @click.version_option(package_name="mtcli-volume")
12
- @click.option("--symbol", "-s", default=SYMBOL, help="Símbolo do ativo (default WIN$N).")
13
- @click.option("--period", "-p", default=PERIOD, help="Timeframe (ex: M1, M5, H1).")
14
- @click.option("--bars", "-b", default=BARS, help="Número de barras (default 566).")
15
- @click.option(
16
- "--step", "-e", type=float, default=STEP,
17
- help="Tamanho do agrupamento de preços (default 100)."
18
- )
19
- @click.option(
20
- "--volume", "-v", default=VOLUME,
21
- help="Tipo de volume (tick ou real), default tick."
22
- )
23
- @click.option("--exporta-csv", "-csv", is_flag=True, help="Exportar resultados para CSV.")
24
- @click.option(
25
- "--sem-histograma", "-sh", is_flag=True,
26
- help="Oculta o histograma textual de volume."
27
- )
28
- def volume(symbol, period, bars, step, volume, exporta_csv, sem_histograma):
29
- """Exibe o Volume Profile agrupando volumes por faixa de preço."""
30
- profile, stats = calcular_volume_profile(symbol, period, bars, step, volume)
31
- exibir_volume_profile(profile, stats, symbol, exporta_csv, sem_histograma)
32
-
33
-
34
- if __name__ == "__main__":
35
- volume()
1
+ import click
2
+ from mtcli_volume.controllers.volume_controller import calcular_volume_profile
3
+ from mtcli_volume.views.volume_view import exibir_volume_profile
4
+ from mtcli_volume.conf import SYMBOL, PERIOD, BARS, STEP, VOLUME
5
+
6
+
7
+ @click.command(
8
+ "volume",
9
+ help="Exibe o Volume Profile, agrupando volumes por faixa de preço no histórico recente."
10
+ )
11
+ @click.version_option(package_name="mtcli-volume")
12
+ @click.option("--symbol", "-s", default=SYMBOL, help="Símbolo do ativo (default WIN$N).")
13
+ @click.option("--period", "-p", default=PERIOD, help="Timeframe (ex: M1, M5, H1).")
14
+ @click.option("--bars", "-b", default=BARS, help="Número de barras (default 566).")
15
+ @click.option(
16
+ "--step", "-e", type=float, default=STEP,
17
+ help="Tamanho do agrupamento de preços (default 100)."
18
+ )
19
+ @click.option(
20
+ "--volume", "-v", default=VOLUME,
21
+ help="Tipo de volume (tick ou real), default tick."
22
+ )
23
+ def volume(symbol, period, bars, step, volume):
24
+ """Exibe o Volume Profile agrupando volumes por faixa de preço."""
25
+ profile, stats = calcular_volume_profile(symbol, period, bars, step, volume)
26
+ exibir_volume_profile(profile, stats, symbol)
27
+
28
+
29
+ if __name__ == "__main__":
30
+ volume()
@@ -0,0 +1,30 @@
1
+ import click
2
+ from mtcli_volume.conf import DIGITOS
3
+
4
+ BARRA_CHAR = "#" # Pode mudar para "■" ou "=" se UTF-8 for garantido
5
+
6
+
7
+ def exibir_volume_profile(profile, stats, symbol):
8
+ """Exibe o volume profile no terminal."""
9
+ if not profile:
10
+ click.echo(f"Nenhum dado disponível para {symbol}")
11
+ return
12
+
13
+ dados_ordenados = sorted(profile.items(), reverse=True)
14
+
15
+ click.echo(f"\nVolume Profile {symbol}\n")
16
+ max_vol = max(profile.values())
17
+ for preco, vol in dados_ordenados:
18
+ barra = BARRA_CHAR * (vol // max(1, max_vol // 50))
19
+ click.echo(f"{preco:>8.{DIGITOS}f} {vol:>6} {barra}")
20
+
21
+ # Estatísticas
22
+ if stats.get("poc") is not None:
23
+ click.echo(f"\nPOC (Preço de Maior Volume): {stats['poc']:.{DIGITOS}f}")
24
+ click.echo(
25
+ f"Área de Valor: {stats['area_valor'][0]:.{DIGITOS}f} a {stats['area_valor'][1]:.{DIGITOS}f}"
26
+ )
27
+ click.echo(f"HVNs: {stats['hvns']}")
28
+ click.echo(f"LVNs: {stats['lvns']}")
29
+ else:
30
+ click.echo("\nEstatísticas indisponíveis (dados insuficientes).")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mtcli-volume"
3
- version = "2.0.0.dev0"
3
+ version = "2.0.0.dev1"
4
4
  description = "Plugin mtcli para exibir o volume profile"
5
5
  authors = [
6
6
  {name = "Valmir França da Silva",email = "vfranca3@gmail.com"}
@@ -1,50 +0,0 @@
1
- import click
2
- import csv
3
- from datetime import datetime
4
- from mtcli.logger import setup_logger
5
- from mtcli_volume.conf import DIGITOS
6
-
7
- log = setup_logger()
8
- BARRA_CHAR = "#" # Pode mudar para "■" ou "=" se UTF-8 for garantido
9
-
10
-
11
- def exibir_volume_profile(profile, stats, symbol, exporta_csv=False, sem_histograma=False):
12
- """Exibe o volume profile no terminal ou exporta para CSV."""
13
- if not profile:
14
- click.echo(f"Nenhum dado disponível para {symbol}.")
15
- return
16
-
17
- dados_ordenados = sorted(profile.items(), reverse=True)
18
-
19
- if exporta_csv:
20
- try:
21
- data_str = datetime.now().strftime("%Y%m%d_%H%M")
22
- nome_arquivo = f"volume_profile_{symbol}_{data_str}.csv"
23
- with open(nome_arquivo, mode="w", newline="", encoding="utf-8") as f:
24
- writer = csv.writer(f)
25
- writer.writerow(["Faixa de Preço", "Volume"])
26
- writer.writerows(dados_ordenados)
27
- click.echo(f"Exportado para {nome_arquivo}")
28
- log.info(f"Exportado para {nome_arquivo}")
29
- except Exception as e:
30
- log.error(f"Erro ao exportar CSV: {e}")
31
- click.echo(f"Erro ao exportar CSV: {e}")
32
- return
33
-
34
- # Exibição textual
35
- click.echo(f"\nVolume Profile {symbol}\n")
36
- max_vol = max(profile.values())
37
- for preco, vol in dados_ordenados:
38
- barra = "" if sem_histograma else BARRA_CHAR * (vol // max(1, max_vol // 50))
39
- click.echo(f"{preco:>8.{DIGITOS}f} {vol:>6} {barra}")
40
-
41
- # Estatísticas
42
- if stats.get("poc") is not None:
43
- click.echo(f"\nPOC (Preço de Maior Volume): {stats['poc']:.{DIGITOS}f}")
44
- click.echo(
45
- f"Área de Valor: {stats['area_valor'][0]:.{DIGITOS}f} a {stats['area_valor'][1]:.{DIGITOS}f}"
46
- )
47
- click.echo(f"HVNs: {stats['hvns']}")
48
- click.echo(f"LVNs: {stats['lvns']}")
49
- else:
50
- click.echo("\nEstatísticas indisponíveis (dados insuficientes).")