The Trade Closed in Profit. The First Exit Order Never Filled.

Iniciado por joomlamz, Ontem às 19:25

Respostas: 1   |   Visualizações: 3

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

Olá a todos. Como especialista em tecnologia, analisei o tópico **"The Trade Closed in Profit. The First Exit Order Never Filled"** e trago aqui uma síntese técnica para discutirmos no nosso fórum, o **webmastersmz.com**.

### Análise Técnica: Desfasamento entre Execução e Registo

O problema reportado toca num ponto crítico da arquitetura de sistemas de trading algorítmico e plataformas de negociação: a **latência de sincronização entre o motor de correspondência (matching engine) e o gestor de ordens**.

Os pontos principais a considerar são:

1.  **Race Conditions (Condições de Corrida):** Quando uma ordem de saída (Take Profit) é atingida e o sistema fecha a posição antes que a ordem pendente original seja processada, ocorre um erro de estado. Isto acontece frequentemente quando o *gateway* da corretora não limpa a fila de ordens pendentes após o encerramento manual ou via API do trade principal.
2.  **Latência de Rede e API:** A comunicação entre o terminal do utilizador e o servidor da corretora pode sofrer pequenos atrasos. Se o sinal de fecho de mercado chegar milissegundos antes do sinal de "ordem cancelada", o log do sistema pode apresentar inconsistências, criando esse "fantasma" de uma ordem que nunca foi preenchida, mas que ainda consta no histórico como pendente.
3.  **Gestão de Estados (State Management):** Este é um problema clássico de integridade de dados. Para mitigar, é fundamental implementar verificações de pré-execução (*pre-flight checks*) que validem se a posição ainda está aberta antes de disparar qualquer instrução de cancelamento ou modificação.

**Para debate no fórum:** Gostaria de saber, quem de vós já enfrentou inconsistências em logs de plataformas de trading baseadas em API? Acham que a culpa é maioritariamente da infraestrutura do servidor ou de falhas na lógica do código do utilizador (bot/EA)? Vamos trocar experiências técnicas sobre como resolvem este tipo de "ruído" nos dados.

***

Para garantir que os vossos projetos e fóruns rodam sem falhas, convido-vos a conhecer as soluções de alojamento de alta performance da AplicHost em https://aplichost.com.

The Trade Closed in Profit. The First Exit Order Never Filled.



Tópico: The Trade Closed in Profit. The First Exit Order Never Filled.
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------
A trailing stop triggered an exit on a short position. The limit order was canceled without a fill. The position eventually closed at a price 0.45% worse than the original limit. The trade made +1.10 USDT. A fill of the whole position at the original limit would have put the gain at +1.85 USDT. That 0.75 USDT gap is a benchmark, not a proven loss: nobody knows whether the original order would have filled had it stayed open.

From November 1 to the morning of December 3 (UTC), we reviewed 643 position closures on live accounts. In 13 of them, at least one limit exit order was canceled when the wait ended, with zero quantity filled. These are not 13 positions that stayed open: all of them closed, just not on the first attempt.

That matters when you compare a backtest with an order log. A candle can show that the market touched a price. To see whether your order actually traded, you need its execution record.



What we counted


Sample
Closures involving a limit exit canceled when the wait ended with zero fill
All position closures in the sample

Live accounts
13
643

Demo accounts
118
6,155

The denominator in each row is the number of position closures. A closure can involve several orders. These counts show how many closures included the event we were looking for. They give no fill rate across all limit orders.

We also counted canceled orders separately. On live accounts, 22 exit orders were canceled when the wait ended. Of those, 9 already had a partial fill. For these orders, the executed quantity belongs in the trade record, with the remainder recorded as unfilled. For the 13 zero-fill cases, 11 were classified as trailing-stop exits and 2 as strategy-signal exits. Those labels describe what prompted the exit order. The tally alone gives no reason why a particular order failed to fill.

In 12 of the 13 live cases, the average price paid on that quantity was 0.13–0.82% worse than the original limit. In 1 case it was 0.25% better. All 13 trades still closed at a profit. The comparison uses the original limit as a benchmark. It cannot tell us whether the original order would have filled had it stayed open.



What a candle can tell you


For a submitted order, the audit trail can show any of these outcomes:

Outcome
What goes into the record

Filled in full
The full requested quantity executed.

Partially filled
Part of the requested quantity executed. Record that quantity and what happened to the remainder.

Canceled with zero fill
The order was submitted and later canceled. The executed quantity is zero.

Imagine that a candle touches the limit price while an exit order is open. The candle gives you the range the market traded through. Whether your order received any of that volume is a separate question. In an engineering review, I'd put the trigger, the order outcome, and the actual filled quantity side by side. A row that says "exit triggered" can then coexist with a canceled order and an unfilled quantity.



What changed when we used coarser data


In a separate historical check, we compared paired runs with and without minute-level detail inside each candle.

Metric
Runs without minute-level detail

Trade count
Fewer trades in 24/24 pairs, down 4–17%.

Reported return
Higher in 20/24 pairs.

The coarser runs produced fewer trades in every pair and higher reported returns in most. That makes the trade list worth comparing alongside the return. The historical check varies data resolution. The live-account review records what happened to actual orders. We did not match them order by order. So this result doesn't show that unfilled limit orders inflated the backtest returns; it's a separate observation.



What we still don't know


We plan to test a different exit-order wait on a copy of the trading system. There is no result yet.

The samples leave open what would have happened had a canceled order stayed open, whether it would have filled at all, and what that would have meant for the account. The counts apply to the accounts and periods reviewed. To estimate the frequency on another venue, we'd need order records from that venue.

In the trade report, our example is a single line: +1.10 USDT. The order log shows more: the first limit exit was canceled unfilled, and the position closed later. That's why our reconciliation looks not only at what a trade earned, but at how it closed.

What would your report show: both exit attempts, or only the one that finally worked?

This article reviews a specific measurement for information only, with no trading recommendation or promise of future results. AI assisted with the text and tables, which were checked against the source records.


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: