Ray Fu, ex-Meta senior engineer and AI automation educator

Ray Fu

I'm an Ex Meta Senior Engineer that makes content and teaches OpenClaw and AI Automations.

stan.store/raycfu

How Someone Used MiroFish to Make $1.49M Betting on the NBA

(And How Mirofish Works)

Don't want to figure this out alone? I walk members through every step inside the community. Join the Skool → skool.com/raycfu

Someone trained a swarm of 4,096 AI agents on 3 years of NBA data, fed the consensus into a transformer model, and used it to bet on Polymarket. The result was $1.49 million. He didn't build a better prediction model. He built a better crowd.

This guide breaks down what MiroFish is, how the NBA betting system works, how to set it up yourself, and what you need to know before you try it. This is for educational purposes. Prediction market trading involves real financial risk.

What is MiroFish?

MiroFish is an open-source AI engine that simulates thousands of digital humans. You feed it a document or dataset, it extracts every entity and relationship into a knowledge graph, then generates thousands of autonomous AI agents. Each agent gets a unique biography, personality type, social connections, and behavioral logic. Then they all interact with each other in a simulated world.

The key feature is called "God's Eye View." At any point you can inject new variables into the simulation ("Fed cuts rates by 50 basis points" or "starting point guard is out with an injury") and watch the entire digital world reorganize in real time. Every agent reacts based on their personality and position. Opinion leaders form, herd effects develop, sentiment shifts. You're watching a controlled experiment that would be impossible to run in reality.

It was built in 10 days by a 20-year-old college student in China named Guo Hangjiang. A billionaire (Chen Tianqiao, founder of Shanda Group) gave him $4.1 million to incubate it the morning after seeing the demo. The project hit number 1 on GitHub trending above OpenAI, Google, and Microsoft. Currently at 22,000+ stars.

It's fully open source under AGPL-3.0. You can run it locally or with Docker.

How the NBA Betting System Works

The system has four layers. MiroFish handles the crowd simulation. A transformer model handles the final prediction. Kelly Criterion handles position sizing. And the Polymarket API handles execution.

Layer 1: The Data

Before MiroFish can simulate anything, it needs raw material. For NBA prediction markets, the system ingests five categories of data.

Player stat vectors: Points, rebounds, assists, effective field goal percentage (eFG%), and usage rate across 3 full seasons. This gives each simulated agent a baseline understanding of player quality and trajectory.

Team form tensors: Performance over the last 10 games, home vs away splits, pace of play, and defensive rating. Recent form matters more than season averages for game-by-game prediction.

Matchup history: Head-to-head records between the two teams, positional mismatches (does their center dominate your center?), and referee tendencies. Some referees call significantly more fouls, which changes game dynamics.

Injury probability models: Current injury reports weighted by medical staff assessments and historical recovery timelines. A player listed as "probable" has a different impact than "questionable" or "doubtful."

Line movement tracking: Where the sharp (professional) money is flowing before tip-off. If the line moves significantly in one direction without news, it usually means informed bettors are taking a position. This is a signal the market hasn't fully priced in.

All of this data gets structured into documents that MiroFish can ingest. You format it as markdown or JSON, upload it, and MiroFish reads it, maps the relationships, and builds the knowledge graph.

Layer 2: The Swarm Simulation

This is where MiroFish does its thing. Based on the data, it generates 4,096 agents. Each one gets a different role and reasoning style.

The agent types include:

Statistical analysts: Focus purely on numbers. Historical matchup data, player efficiency ratings, pace-adjusted metrics.

Narrative-driven bettors: Focus on storylines, momentum, and psychology. "This team just lost three in a row at home and is desperate."

Sharp money trackers: Focus entirely on line movement and where professional bettors are placing money.

Oddsmakers: Try to set fair odds based on all available information. They're the baseline the other agents argue against.

Insider-style agents: Weight injury reports and locker room dynamics more heavily. They care about who's actually playing and how healthy they are.

Contrarian agents: Systematically look for situations where the crowd is wrong. They push back on consensus.

All 4,096 agents interact on simulated social platforms (MiroFish runs Twitter-like and Reddit-like environments simultaneously). They post opinions, argue, influence each other, form clusters, and shift positions over time. The simulation engine (OASIS by CAMEL-AI) supports 23 different social actions: following, commenting, reposting, debating.

Over the course of the simulation, consensus emerges. Not because the agents are forced to agree, but because the simulation runs long enough for opinion dynamics to stabilize. Some agents become opinion leaders. Herd effects form. Minority views either get absorbed or strengthen into a contrarian signal.

The output is a probability distribution: what does this simulated crowd think the actual probability of each outcome is?

This is the core insight. Traditional prediction models crunch numbers and output a single probability. MiroFish simulates how a crowd of different thinkers processes the same information, which captures dynamics that pure statistical models miss. Things like narrative momentum, overreaction to recent results, and the way sharp money influences casual bettors.

Layer 3: The Transformer Model

The raw MiroFish consensus goes through a second layer of processing. A 12-layer transformer model trained on the full history of over 16,000 previous predictions.

This model learns the patterns of when MiroFish's crowd is right and when it's wrong. It calibrates the raw consensus against historical accuracy. If MiroFish tends to overvalue home court advantage in certain matchups, the transformer adjusts for that. If MiroFish underestimates the impact of back-to-back games, it corrects for that.

The transformer output is the final probability estimate that gets compared against live Polymarket odds.

Layer 4: Execution

The model compares its final probability against Polymarket's current price. When the gap exceeds a Kelly Criterion threshold, it enters a position.

Example: Lakers are trading at 40 cents on Polymarket (implying a 40% chance of winning). MiroFish consensus, after transformer calibration, says 62%. The edge is 22 percentage points. Kelly Criterion calculates the optimal position size. One trade: $190,823.

The system uses limit orders on Polymarket's CLOB (Central Limit Order Book) to control slippage. It monitors the position until settlement. If new information changes the probability significantly (a star player is ruled out 30 minutes before tip-off), the system can adjust or exit.

How to Set Up MiroFish

You need: Node.js, Python, Git, Docker (optional but recommended), and API keys for an LLM provider.

Option 1: Source install

git clone https://github.com/666ghj/MiroFish.git

cd MiroFish

cp .env.example .env

Edit the .env file and add your API keys. MiroFish supports any LLM API compatible with the OpenAI SDK format. The documentation recommends Qwen from Alibaba's Bailian platform for cost efficiency, but you can use Claude, GPT-4, or any other provider.

npm run setup

npm run setup:backend

npm run dev

This starts the frontend on port 3000 and the backend on port 5001.

Option 2: Docker

cp .env.example .env

docker compose up -d

This pulls the images and starts everything. Frontend on port 3000, backend on port 5001.

MiroFish uses Zep Cloud for long-term agent memory. You'll need a Zep Cloud API key. The free tier is usually enough for smaller experiments.

Important cost note: Running thousands of agents through multiple simulation rounds means a lot of LLM API calls. The documentation recommends starting with fewer than 40 rounds to manage costs. Large simulations can get expensive fast.

Option 3: Offline (No Cloud APIs)

There's a community fork called MiroFish-Offline that replaces cloud LLM APIs with local models via Ollama and replaces Zep Cloud with Neo4j for local knowledge graphs.

git clone https://github.com/nikmcfly/MiroFish-Offline.git

cd MiroFish-Offline

cp .env.example .env

docker compose up -d

docker exec mirofish-ollama ollama pull qwen2.5:32b

docker exec mirofish-ollama ollama pull nomic-embed-text

Open http://localhost:3000. Everything runs locally. No API costs. The tradeoff is that local models are less capable than frontier cloud models, so simulation quality may be lower.

How to Adapt MiroFish for Sports Prediction

MiroFish was designed for general-purpose simulation, not sports specifically. Adapting it for NBA betting requires preparing your data correctly and configuring the agent generation to produce the right types of reasoners.

Step 1: Prepare your seed documents

Create markdown files containing the data categories from Layer 1. Structure them so MiroFish can extract entities and relationships. For example:

A document about the Lakers vs Celtics game should include: current season records, last 10 game results for each team, key player stats, injury reports, head-to-head history this season, and current Polymarket odds.

The more structured your input, the better the knowledge graph. MiroFish uses GraphRAG to build the graph, so clear entity names and explicit relationships help.

Step 2: Write your simulation requirement

When you start a simulation, MiroFish asks you to describe your prediction requirement in natural language. For NBA betting, something like:

"Predict the outcome of the Lakers vs Celtics game on March 20, 2026. Consider player performance trends, injury impacts, home court advantage, referee tendencies, and recent team form. Generate agents representing statistical analysts, narrative bettors, sharp money trackers, oddsmakers, and contrarians. Run the simulation and produce a probability estimate for each outcome."

Step 3: Configure agent count and simulation rounds

For the NBA system described in the script, 4,096 agents were used. MiroFish can scale up to one million agents via OASIS, but more agents means more LLM API calls and higher costs. For testing, start with 100-500 agents and see how the outputs look before scaling up.

Keep simulation rounds under 40 to start. Each round is a cycle where all agents interact, post opinions, and update their positions. More rounds produces more refined consensus but costs more.

Step 4: Extract the consensus probability

After the simulation completes, MiroFish generates a report using its ReportAgent (which uses the ReACT reasoning pattern). The report synthesizes the simulation results. You can also interact with the simulated world directly by chatting with individual agents and asking them to explain their reasoning.

Extract the final probability distribution from the report. This is what gets fed into your calibration model or compared directly against market odds.

Step 5: Compare against Polymarket odds

Pull live odds from Polymarket's API (docs.polymarket.com). Compare your MiroFish probability against the market price. Calculate the edge (your probability minus market price). If the edge exceeds your threshold, it's a potential trade.

Step 6: Size the position with Kelly Criterion

Kelly Criterion formula: f* = (p * b - q) / b

Where p is your probability, q is 1 minus p, and b is the net odds.

Use Fractional Kelly (multiply by 0.15 to 0.25) to reduce variance. Full Kelly is mathematically optimal but extremely volatile. The NBA system reportedly uses fractional Kelly with strict caps.

Position limits to enforce: No more than 5% of bankroll on a single game. Maximum 15 concurrent positions across all markets. If daily losses exceed 15% of bankroll, stop trading for the day.

Step 7: Execute on Polymarket

Polymarket uses a CLOB system on Polygon. You need a Polygon wallet funded with USDC. The API uses EIP-712 signing for authentication and HMAC credentials for trading requests.

Use limit orders, not market orders, to control slippage. WebSocket feeds give you roughly 100ms latency for live orderbook updates. If the price moves more than 2% between your signal and fill, abort the trade.

Set up a kill switch. A simple mechanism (like a file drop that halts all trading) so you can stop everything immediately if something goes wrong.

What to Know Before You Try This

MiroFish has not published benchmarks comparing its predictions against real-world outcomes. The demos show the approach working, but they're illustrations, not proof of accuracy.

LLM agents tend to be more susceptible to herd behavior than real humans. The OASIS research paper notes that simulated crowds can polarize faster than real ones. This means your consensus may be more extreme than it should be.

Agent personalities inherit whatever biases exist in the LLM training data. If the underlying model has a tendency to overrate certain teams or underrate certain statistical factors, the simulation will reflect that.

Running 4,096 agents through multiple rounds is expensive in API costs. Budget carefully. Start small and scale up only after you've validated the approach.

The $1.49M result is extraordinary and likely represents a combination of good system design, favorable market conditions, and some amount of variance. Do not expect to replicate this result. Most automated prediction market traders report much more modest returns.

Polymarket is crypto-native and operates on Polygon. You need a funded wallet with USDC. Check the legal status of prediction markets in your jurisdiction before trading. Several US states have filed lawsuits against prediction market platforms.

Polymarket is now using Palantir's AI monitoring system to screen for suspicious trading activity, including prohibited users and potential manipulation.

You just read the full playbook. Most people will close this tab and never implement it. The ones who do usually hit a wall around the technical setup and quit.

Inside the Skool, I walk you through the exact build step-by-step, troubleshoot your setup live in the community, and share the scripts and templates I use to actually land paying clients.

If you want the shortcut instead of the long way around:

Join the Skool →

Disclaimer

This guide is for educational and research purposes only. Prediction market trading involves substantial financial risk. The $1.49M result described is not typical and should not be expected. MiroFish has not published validated benchmarks against real-world outcomes. LLM-based simulations inherit biases from training data. Always start with paper trading (simulation without real money). Never trade money you can't afford to lose. Check the legal status of prediction markets in your jurisdiction.