Building a Quick Event-Driven Algo: The NVDA Earnings Momentum Bot
Whenever a massive market catalyst approaches—like an NVIDIA (NVDA) earnings call—the market braces for impact. Discretionary traders sit at their screens, fingers hovering over the buy/sell buttons.
Building a Quick Event-Driven Algo: The NVDA Earnings Momentum Bot
Whenever a massive market catalyst approaches—like an NVIDIA (NVDA) earnings call—the market braces for impact. Discretionary traders sit at their screens, fingers hovering over the buy/sell buttons. But as quantitative traders, we can do better. We can build and deploy a targeted, event-driven bot to capture the momentum before human reaction times even register.
Today, I’m sharing a breakdown of a Nasdaq-100 AI Momentum Bot I wrote specifically as a beta play for NVDA earnings.
This script is a perfect example of a “rapid-deployment” bot. It’s something you can spin up quickly to capitalize on a specific macroeconomic event or earnings call. Let’s dive into the code and see how it works.
The Strategy at a Glance
The logic is simple but highly effective for momentum bursts:
The Trigger: NVDA announces a guidance “BEAT”.
The Confirmation: RSI(14) > 50, a bullish MACD crossover, and price pulling back to the 20-period VWAP.
The Execution: Go LONG 5 E-mini Nasdaq-100 (NQ) contracts (or 10 Micro MNQ contracts).
The Risk: Strict -3% stop loss, +6% primary target, and a circuit breaker to halt trading if things go south.
Code Breakdown: Under the Hood
1. Configuration and Risk Parameters
At the top of the script, we define the rules of engagement. Hardcoding these parameters allows us to quickly tweak the bot for different volatility environments.
# Risk parameters
TARGET_PCT = 0.06 # +6% target
STOP_LOSS_PCT = 0.03 # -3% stop loss
TARGET_SESSION_PCT = 0.025 # +2.5% session target (post-earnings)
# Technical indicators
RSI_PERIOD = 14
RSI_THRESHOLD = 50 # RSI > 50 for entry
VWAP_PERIOD = 20
Notice the TARGET_SESSION_PCT. Post-earnings moves can fade fast, so the bot is programmed to take a quick 2.5% profit if it happens within the first 8 hours.
2. The Circuit Breaker
When trading highly volatile events, your bot needs a kill switch. I implemented a CircuitBreaker class to protect capital.
class CircuitBreaker:
def record_trade(self, pnl_pct: float):
# ... calculates equity curve ...
if drawdown_pct > self.max_drawdown:
self.is_paused = True
logger.warning(f”Circuit breaker triggered: Max drawdown exceeded”)
If the bot hits a 5% max drawdown or suffers two consecutive losses, it automatically pauses. No emotional revenge trading allowed.
3. The Alpha Logic (Checking the Signal)
The core of the bot lives in the check_momentum_signal method. It doesn’t just blindly buy because NVDA beat earnings; it waits for market structure to confirm the risk-on appetite.
def check_momentum_signal(self, market_data: MarketData) -> MomentumSignal:
signal = MomentumSignal()
# 1. Did NVDA beat?
signal.nvda_beat = market_data.nvda_guidance == NVDAGuidance.BEAT
# 2. Are we in an uptrend?
signal.rsi_above_50 = market_data.rsi > RSI_THRESHOLD
signal.macd_bullish = market_data.macd > market_data.macd_signal
# 3. Are we getting a good entry price?
if market_data.vwap > 0:
vwap_distance = abs(market_data.nq_price - market_data.vwap) / market_data.vwap
signal.price_at_vwap = vwap_distance <= 0.005 # Within 0.5% of VWAP
signal.signal_valid = (signal.nvda_beat and signal.rsi_above_50 and
signal.macd_bullish and signal.price_at_vwap)
return signal
4. Execution via Redis Pub/Sub
To make this bot fast and scalable, it doesn’t execute trades directly via a slow API loop. Instead, it uses Redis Pub/Sub to instantly broadcast trading commands to an execution engine.
def execute_entry(self, market_data: MarketData, signal: MomentumSignal):
order = {
‘symbol’: SYMBOL,
‘exchange’: EXCHANGE,
‘side’: ‘BUY’,
‘quantity’: CONTRACTS,
‘order_type’: ‘MARKET’,
‘action’: ‘MOMENTUM_ENTRY’
}
# Instantly publish the order to the execution channel
self.r.publish(TRADING_COMMANDS_CHANNEL, json.dumps(order))
This decoupled architecture means you can run the strategy logic on one server and the API execution on another, minimizing latency.
Why This Matters
This script is just a sampling of what is possible. It’s a typical “quick bot” that I can spin up and deploy rapidly based on specific macroeconomic catalysts. You don’t always need a massive, machine-learning-driven black box. Sometimes, combining a known binary event (earnings) with standard momentum indicators and strict risk management is all you need to extract alpha from the market.
This is just one of many examples of event-driven algorithms I deploy in my own trading.
Do you want to see more code drops like this?
If you found this breakdown helpful and want me to share more of these rapid-deployment strategy scripts (like FOMC rate-decision bots, or CPI volatility catchers), let me know in the comments below!
(Disclaimer: The code discussed is for educational purposes only and does not constitute financial advice. Futures trading involves substantial risk of loss.)


The circuit breaker implementation is the most underrated part here. Most retail algo traders obsess over entry logic and completely ignore what happens when the model blows up. The Redis Pub/Sub architecture for decoupling strategy from execution is intresting too, I've seen a lot of event-driven setups bottleneck on the order routing side. One thing I'd add is a news latency buffer since official guidance and market timestamps don't always sync cleanly after-hours. The 0.5% VWAP tolerence check is tight but realistic for NQ liquidity post-catalyst. Would definitely want to see the FOMC rate-decision version of this.