Oil Trading Pipeline with LLM News Filtering and FallbacksOil Trading Pipeline with LLM News Filtering and Fallbacks
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
A developer asked me about latency in my reasoning gate. Here is the full architecture, and the tradeoff I made.
This is a case study of OIL-NEWS-SYSTEM—an autonomous oil trading pipeline I built from scratch.
The Problem
Most trading bots trade on headlines that were never about oil, or they fire on stale news because they acted on the first tweet they saw instead of the newest one. The developer assumes the strategy is bad. They tweak the RSI. It bleeds again. The flaw is not the strategy. It is the signal.
The Decision
I put a reasoning model in front of every headline before a single dollar moves. The model returns four fields: Is this actually about oil? Impact (BULL/BEAR/NEUTRAL). Strength (1–5). Confidence (0.0–1.0). A trade only executes if confidence passes a hard threshold.
The Tradeoff (the latency question)
A reasoning call per headline costs ~200–400ms on the hot path via Groq (gpt-oss-20b). That sounds expensive—until you look at the cadence. The monitor polls every 20 seconds, not every tick. I am not competing in a high-frequency race. I am filtering noise before it reaches execution.
Headlines are processed sequentially, not in parallel, so every trade has a single auditable reasoning trace. If the API fails 3 times in a row, a circuit breaker falls back to the deterministic keyword engine. The system gets dumber for one cycle. It does not go dark.
The Honest Gap
There is no two-tier local/hosted setup yet. A small local model for the first gate, escalating to the hosted model only when the impact field is ambiguous, is the next optimization. I chose auditability over raw speed for v1. If you need sub-100ms decisions, this is the wrong architecture. If you can tolerate a 20-second cadence, the reasoning gate pays for itself in false-signal reduction.
The Architecture
twitter_monitor.py → primes on first poll, never trades stale news. groq_brain.py → reasoning gate, structured JSON out. sentiment.py → deterministic fallback. main.py → Binance Futures execution, leverage + SL/TP locked before order. Dockerized. Python 3.11.
The Result
A pipeline that reads the world, reasons through noise, and executes with precision. No human in the chair. No stale signals. No keyword guessing.
This is not a script. It is a system with a brain, a fallback, and an audit trail.
If you are building autonomous systems and need an execution layer that ships, my inbox is open.
#AITrading #Python #LLM #BuildInPublic #QuantDev
Post image
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started