Skip to main content

Plugin mtcli para controle de loss diário

Project description

mtcli-risco

Testes

Plugin para controle de risco diário integrado ao mtcli. Bloqueia automaticamente o envio de ordens caso o limite de prejuízo do dia seja ultrapassado.


Instalação

Instale via pip (com mtcli já instalado):

pip install mtcli-risco

Requisitos

  • Python 3.10+
  • MetaTrader 5 instalado e configurado
  • Conta de negociação conectada no MT5
  • mtcli instalado e funcionando

Como usar

Executar o comando:

mt risco

Exemplo com limite personalizado:

mt risco --limite -300

Isso bloqueará novas ordens quando o lucro total do dia (realizado + em aberto) for menor ou igual a -300.


📁 Arquivo de estado

O estado do risco diário é salvo no arquivo:

bloqueio_risco.json

Exemplo de conteúdo:

{
  "data": "2025-09-20",
  "bloqueado": true
}

Esse arquivo é reavaliado a cada novo dia. O bloqueio se aplica apenas ao dia corrente.


Lógica

  1. Consulta as negociações realizadas no dia (buy/sell).
  2. Soma os lucros/prejuízos dessas operações.
  3. Adiciona o lucro/prejuízo da posição atual em aberto.
  4. Se o total for menor ou igual ao limite definido, bloqueia novas ordens.

Rodar testes

Execute os testes com:

pytest tests/

Desenvolvimento

Clone e instale em modo editável:

git clone https://github.com/seuuser/mtcli-risco.git
cd mtcli-risco
pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtcli_risco-2.4.1.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mtcli_risco-2.4.1-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file mtcli_risco-2.4.1.tar.gz.

File metadata

  • Download URL: mtcli_risco-2.4.1.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Windows/11

File hashes

Hashes for mtcli_risco-2.4.1.tar.gz
Algorithm Hash digest
SHA256 c74c2675f3d5ae9ad68514c35a92658bda047e837c03adb23db07bed3ed83c65
MD5 77253daa8a7ad3826f3d45f77551e3bd
BLAKE2b-256 3b36be09c61fccd834052ef96813d73811568993b06f469e26c56874a03e5240

See more details on using hashes here.

File details

Details for the file mtcli_risco-2.4.1-py3-none-any.whl.

File metadata

  • Download URL: mtcli_risco-2.4.1-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Windows/11

File hashes

Hashes for mtcli_risco-2.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5f1d6f15de535777d15366e8cecf4bea8d613177fad7a020a75418e6c0c8d3b
MD5 7a6a0b31046994ec4dd53b499662ec35
BLAKE2b-256 e03bccd1422b6639a1f52b4c91c52a8e1349994ed646711e229f4c29d4f0c733

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page