Inspiration
The financial markets are inherently noisy, and most algorithmic trading systems suffer from a critical flaw: they are too reactive. While AI and ML models can predict directional movements with high accuracy, transient market noise often triggers premature exits, destroying a strategy's statistical edge.
We were inspired to build NertzMetalEngine (Nertzh) to solve this exact problem. We wanted to create an automated trading engine that doesn't just predict the market, but possesses the mathematical discipline to let its edge play out without panicking over temporary fluctuations.
What We Learned
The most crucial lesson we learned is that in algorithmic trading, trade management (exit logic) is far more critical than entry prediction. Our proprietary multi-factor entry model—combining EGM (Exhaustion Gap Metric), PIO, TFI (Trade Flow Imbalance), and recent trades imbalance—achieved an impressive ~56% directional win rate.
However, we discovered that a high win rate is useless if the exit logic doesn't respect the Risk/Reward ratio. A bot that cuts winners early out of "fear" (reacting to opposite micro-signals) will never be profitable in the long run. We also learned how to deeply integrate with the Bybit V5 API via WebSockets to handle low-latency order book and execution data effectively.
How We Built It
We built Nertzh using a robust, asynchronous Python architecture integrated directly with the Bybit V5 API for ultra-low-latency execution and market data streaming. To process massive streams of tick data and optimize our multi-factor entry model, we leveraged Qwen Cloud's powerful compute infrastructure to backtest and refine our feature weights.
The core of our innovation is the Structural Hard Lock mechanism in our execution engine:
- Signal Suppression: Once a position is opened with predefined Take Profit (TP) and Stop Loss (SL), the engine completely blocks the re-evaluation of opposing entry signals.
- Exchange-Level Execution: The bot relies strictly on Bybit's native TP/SL triggers, removing local network latency from the exit equation.
- Timeout & Hold Bands: A configurable timeout (e.g., 8-15 minutes) acts as a secondary fail-safe, working in tandem with our strict
combined_hold_bandlogic to ensure the trade has time to breathe.
By decoupling the signal generation engine from the position management engine, we ensured the bot remains a disciplined executor rather than an overactive trader.
Challenges Faced
The biggest challenge was preventing the bot from being "too smart for its own good." Initially, the AI would generate a valid opposite signal while a position was still active, and the bot would prematurely close a winning or recovering trade. This completely destroyed our target Risk/Reward ratio:
$$ R:R = \frac{\text{Expected Profit}}{\text{Expected Loss}} \ge 3.0 $$
Engineering the "Hard Lock" required us to redesign the bot's state machine from the ground up. We had to ensure that while the market data stream continued to flow and log metrics for analysis, the execution thread was entirely blinded to new directional signals until the active trade resolved. Balancing this strict discipline with the need to occasionally abort a trade during extreme, unforeseen market anomalies required careful tuning of our timeout parameters and hold-band logic.
Built With
- bybit
- cloud
- mientras
- numpy
- pandas
- python
- qwen
- websockets
Log in or sign up for Devpost to join the conversation.