Inspiration

Recently BTC has been on a sell off pattern and people suspect market makers, particularly Jane Street is responsible for this. Since there is no real data to back this, I thought of building an agent that can look for such manipulative patterns and flag anomalies.

What it does

Imagine a really busy fish market. Lots of people are shouting buy/sell prices at the same time. Sometimes a big fish-buyer pretends to want a lot of fish, drives up the price, then cancels their order and buys cheap. That's called spoofing.

AMMA watches the Bitcoin "fish market" (called an order book) every half second, looks for these tricks, and alerts you when something fishy is going on.

How we built it

The 4 moving parts Binance (live BTC prices) ↓ AMMA watches for weird patterns ↓ AI (GPT) explains what it found ↓ Dashboard shows you everything live

  1. The Watcher (orderbook_stream.py) Connects to Binance's live data feed Every 500ms it takes a "snapshot" of all buy/sell orders Calculates scores: Is there an unusually big wall of orders? Are orders being cancelled suspiciously fast? If something looks weird → raises a flag
  2. The Brain (anomaly_agent.py) Receives the flag Pulls in recent history + similar past events Fetches relevant crypto news (via Tavily) Asks GPT: "Hey, what's going on here?" GPT responds with one of: SPOOF / ICEBERG / DISTRIBUTION / ACCUMULATION / NOISE
  3. The Memory (neo4j_client.py) Stores every pattern in a graph database (Neo4j) Later checks: did the price actually move the way GPT predicted? Builds up a track record of accuracy
  4. The Feedback Loop (feedback_loop.py) Every 5 minutes: checks whether old predictions came true Every 15 minutes: if accuracy is high → fires alerts more often; if low → backs off The system gets smarter over time

Challenges we ran into

Took me a while to figure out the correlations and the thresholds. What's the norm how much does it deviate. Also news gathering by Tavily - was returning same news content. So had to learn to use different keywords based on thresholds.

Accomplishments that we're proud of

Got it working under the hackathon limit and have now gathered significant patterns that would otherwise be undiscovered.

What we learned

Used Neo4j for the first time and Tavily as well - so new technologies learned.

What's next for AMMA - Autonomous market microsctructure agent

Extend to other securities and potentially stocks.

Built With

Share this project:

Updates