[Development Log] EA has the ability to "stop" as part of its capability. A defensive design based on anomaly detection
Automatic trading systems are designed on the assumption that they will continue to operate. However, this premise always carries an inherent risk: even if an anomaly occurs, unless someone notices and intervenes, the system will continue operating as is. This time, I would like to record a design area that is less discussed than entry logic or fund management—“anomaly detection.” It is a discussion of the system's robustness as a whole, on a different axis from the resistance to frictions or to drawdown discussed in previous development notes.
1. Structural blind spots in a system that keeps running
EA is designed to run unmanned. Under this premise, not only normal operation but also how to safely disengage from abnormal states should be treated with the same level of importance as the main logic itself. In practice, however, this part tends to be deprioritized in verification and development. Because a system that makes decisions and acts without human intervention needs to predefine its behavior during anomalies even more than when humans operate it.
The reason is simple: anomaly-detection mechanisms do not function during normal times and are not visualized as results. If you prioritize easily observable metrics like the beauty of the asset curve, investments in “safety devices that are invisible most of the time” tend to be structurally de-emphasized. When allocating development effort, the stage that yields visible results is naturally prioritized, but that does not justify postponing safety design.
2. Physical-layer risks: communication cutoffs and server failures
Automated trading relies on continuous communication with the broker server. Causes of communication cuts include VPS failures, momentary connections drops, and broker-side system outages, among others, so such events are not rare.
The core issue is not the cut itself but how the system resumes processing after recovery. If order processing resumes without accurately understanding the position state, it can lead to unintended double positions or missing necessary settlements. A communication cut during a volatile market increases the risk due to the blank period before recovery. In a system designed to run without human intervention, the option for humans to intervene during that blank period does not exist, which further amplifies risk.
3. Risks from environment factors such as sudden spread widening
As recorded previously, spreads can temporarily widen several times or tens of times during economic data releases or thin trading periods. If entry processing continues in this state, trades may be executed at markedly unfavorable prices.
This is not a flaw in the logic itself; it stems from a lack of resilience to abnormal environmental conditions. Even if the logic functions correctly, if the environment remains abnormal and trading continues, the system inherently carries a risk of substantial losses. Even if friction-resistance testing shows an advantage, the normally tested backtests cannot detect situations where the underlying environment temporarily collapses.
4. Design principles when implementing anomaly detection
The basic approach when implementing anomaly detection is to build multiple monitoring mechanisms as a separate layer from the entry logic. If monitoring is mixed into the main logic, the verification of the logic itself becomes more complex; it is preferable to implement it as a separate layer. Typical design elements include
- Heartbeat monitoring that periodically checks the communication status with the server
- A threshold filter that limits entries when the spread exceeds a certain multiple of the normal level
- A mechanism that counts consecutive order errors and stops operation after a certain threshold
- A mechanism that detects unexpected consecutive losses, stops trading, and issues a notification
All of these are design elements that, independently of the logic's superiority, ensure robustness of the system as a whole.
5. Why this process is structurally undervalued
The reason anomaly-detection mechanisms are undervalued is that their effect only appears in an unseen form: “it did not activate.” If 99 out of 100 times nothing happens and only once it activates to prevent a large loss, its value is hard to quantify.
This asymmetry—costs during normal times are visible, but defensive effects during emergencies are hard to visualize—creates a structural distortion in development priority. In verification reports, the superiority of the entry logic is often the only thing evaluated, and anomaly-detection designs tend to be omitted. It is natural to deprioritize metrics that are hard to quantify, but that tendency can preserve systemic vulnerabilities in real operation.
Why Semura Lab. includes anomaly detection in verification items
At Semura Lab., we position not only the logic's superiority but also how safely we can disengage from abnormal situations as verification targets. Whether the system can stop safely as well as win is a critical condition that separates systems that endure in real operation. Since the elements are hard to quantify, we consider it important to articulate them as verification items. In this development log, we will continue to honestly record such quiet but essential design areas.