Inspiration

Prediction markets on Solana reprice within seconds of breaking news. Manual traders can't react fast enough - by the time a human reads a headline, processes it, and places a trade, the market has already moved. We wanted to build a fully autonomous system that reads breaking news, understands what it means for open prediction markets, and executes trades on-chain before the rest of the market catches up.


What It Does

TradeMaxxer is an autonomous news-to-trade engine. It ingests a real-time financial news stream, classifies each headline against user-selected prediction markets using Groq's LLaMA 3.1, and fires trades on Solana in under 500ms with no human in the loop.

Users select which prediction market contracts they want to monitor. A dedicated agent is spawned for each contract. When breaking news arrives, all agents process it in parallel - each agent checks whether the news is relevant to its market, calls Groq to compute a theoretical probability, compares it against the current market price, and executes a trade if the edge is large enough.

A live dashboard shows the news feed, agent decisions, open positions, latency, and PnL in real time.


How We Built It

News ingestion - a WebSocket stream pulls breaking financial news from multiple sources at ~2 stories/second. An intake service deduplicates headlines by hash and assigns category tags (#fed, #crypto, #macro, #politics, #sec) via keyword matching, dropping ~90% of noise before it reaches the inference layer.

Routing - tagged stories are published to Redis Pub/Sub channels. Each channel corresponds to a tag. Agents subscribe only to their relevant channels, so a crypto market agent never wakes up for Fed news.

Inference on Modal - this is where Modal earns its place. Each agent is a Modal serverless function. When a story lands on its subscribed channel, Modal spins up a container for that agent, sends the headline and market context to Groq's LLaMA 3.1, and gets back a theoretical probability and directional decision: BUY YES, BUY NO, or SKIP. The key primitive is modal.map() — when news breaks, we broadcast the same story to all active agents in a single call and Modal parallelizes execution across as many containers as there are agents. No thread pools, no worker queues, no Kubernetes — just one function call that fans out to N containers instantly. During a live Fed announcement with 8 active markets, all 8 Groq calls fire simultaneously and return within the same 400ms window. Without Modal, this would require a self-managed worker pool, message broker, and horizontal scaling infrastructure. With Modal, it's ~20 lines of Python and costs fractions of a cent per news event.

Execution - when an agent (or the user) decides to trade, execution runs through a single pipeline for Solana, Kalshi, DFlow, and USDC. We use Turnkey as the sole signer: all on-chain actions (Solana txs, DFlow prediction-market orders, Kalshi-linked flows, USDC) are signed by a key held in Turnkey, never by a raw private key on our server. The flow is: (1) Order — we call the DFlow order API with the target market, side (YES/NO), size, and the wallet’s public key; DFlow returns one unsigned Solana transaction (e.g. wrap SOL, swap to outcome token). (2) Resolve mints — we map each prediction market to its on-chain outcome token mints (YES/NO) via the DFlow markets API and pass the correct mint so the order is valid. (3) Sign with Turnkey — we send the unsigned transaction (hex) to Turnkey’s sign_transaction API with our Turnkey key id; Turnkey signs and returns the signed bytes. (4) Submit — we send the signed transaction to Solana RPC; if simulation passes, the trade settles on-chain. So: client → our API → DFlow (unsigned tx) → Turnkey (sign) → Solana (submit). One signing path for all of it. Agents get live market data from the Kalshi WebSocket — market questions, current probabilities, and orderbook depth. Trades settle on Solana via DFlow’s program; Pyth-style oracles can auto-resolve price-based markets with no human input.

Edge calculation — the agent only trades if the Groq theoretical price diverges from the current market price by more than 5%. Signals already priced in get skipped.


Challenges We Ran Into

Groq rate limits - at 2 news stories/second across multiple agents, naive routing burned through Groq's free tier (6,000 TPM) in seconds. We solved this by adding a tag match check before every Groq call. If the news tags don't overlap with the market's tags, the agent returns SKIP instantly at zero cost before touching Groq. This cut Groq calls by ~80% and brought us well within rate limits.

News noise - live news is far messier than expected. Duplicate coverage of the same event from 10 different outlets, headlines in multiple languages, and stories with no trading relevance flooded the pipeline. The dedup hash and keyword filter were essential to keep only signal reaching the agents.

Modal cold starts - first invocations on Modal introduced latency spikes on the initial container boot. We solved this by pre-warming containers for high-priority market categories so they stay warm during active trading windows, keeping p99 latency predictable.


Accomplishments We're Proud Of

Sub-500ms end-to-end - from raw news headline to confirmed on-chain trade in under half a second, with no GPU, no centralized exchange, and no human in the loop.

True parallelism via Modal - modal.map() lets us treat N agents as a single parallel operation. All agents receive the same news story and all Groq calls fire simultaneously. Latency stays flat whether we have 3 active markets or 30. This is the core architectural win — Modal turns a hard distributed systems problem into a single function call.

Zero infrastructure ops - the entire system costs ~$5/month to run. Modal handles scaling, Redis handles routing, Solana handles settlement. No servers to provision, no Docker to manage, no autoscaling policies to tune.

Tag-based filtering as a forcing function - the tag match optimization wasn't just an efficiency fix. It forced us to think rigorously about which markets are actually affected by which news, making the agents smarter and cheaper simultaneously.


What We Learned

Routing before inference - the biggest latency and cost win wasn't faster inference, it was calling the model less often. Filtering by tag overlap before hitting Groq saved more than any model optimization would have.

Pub/Sub over queues for this use case - at 2 stories/second, missing a single story is acceptable. The next one arrives in 500ms. Redis Pub/Sub's fire-and-forget model is the right tradeoff — simpler, faster, and no message persistence overhead needed.

Modal's .map() is the right primitive - broadcasting the same news story to N agents in parallel via Modal replaced what would have been a complex self-managed worker pool with a single function call. The abstraction is exactly right for this problem.

Solana economics make this viable - the same system on Ethereum would cost $200+ per market deployment and take minutes to settle. On Solana it costs $0.001 and settles in 400ms. The chain choice isn't a preference, it's what makes autonomous market making economically possible at all.


What's Next for TradeMaxxer

Embedding-based pre-filtering - replace keyword tags with cosine similarity against cached market question embeddings to scale to 5,000+ markets without linearly increasing Groq calls. Modal's GPU functions make this a natural extension — run embedding inference serverlessly on the same infrastructure.

Parlays - chain multiple correlated markets into a single structured position. If news breaks that moves both a Fed rate market and a crypto price market in the same direction, TradeMaxxer automatically constructs a parlay across both, compounding the edge when signals align. Settlement is handled atomically on-chain so the parlay either fully executes or fully reverts.

Position monitor - auto-exit logic triggered by contradicting signals, time decay on positions approaching resolution, and edge compression detection when markets reprice toward our entry.

Real PnL tracking - on-chain position history with win rate, average edge captured, and Sharpe ratio per market category.

Multi-source arbitrage - cross-reference Groq's theoretical price against Kalshi's regulated market prices as a second benchmark before executing on Solana, exploiting mispricings between centralized and decentralized markets.

Guild-based trading - teams of users pool capital into shared agent strategies, with on-chain attribution of each agent's contribution to collective PnL.

Built With

Share this project:

Updates