MUSASHI

How to Build a Prediction Market Trading Bot with Musashi

Musashi provides a free REST API that monitors 71 Twitter accounts, matches sentiment signals to live prediction markets on Polymarket and Kalshi, and delivers structured trading data. Clone, install, and your bot has live market intelligence in minutes.

Prerequisites

You need Node.js 18+ and a Polymarket or Kalshi account to execute trades. The Musashi API requires no authentication and has no rate limits during beta.

  • Node.js 18+
  • Git
  • Polymarket or Kalshi account (for execution)
  • Optional: Python 3.9+ for Python bots

Step 1: Install Musashi

Terminal
git clone https://github.com/MusashiBot/Musashi.git
cd Musashi && npm install
npm run agent

The agent starts polling Twitter accounts and building the market match cache. The first full cycle takes about 2 minutes.

Step 2: Poll the Feed API

Your bot polls GET /api/feed to get new signals. Filter by category and urgency to reduce noise.

JavaScript (Node.js)
const BASE = 'https://musashi-api.vercel.app'
let lastSeen = Date.now()

async function pollFeed() {
  const res = await fetch(
    `${BASE}/api/feed?urgency=high&since=${lastSeen}`
  )
  const { signals } = await res.json()
  const newestSignalTs = signals.reduce(
    (max, signal) => Math.max(max, signal.createdAt),
    lastSeen
  )
  lastSeen = newestSignalTs
  return signals
}

setInterval(async () => {
  const signals = await pollFeed()
  for (const signal of signals) {
    if (signal.sentiment === 'bullish' && signal.confidence > 0.75) {
      await executeTrade(signal)
    }
  }
}, 25_000)

Step 3: Interpret Trading Signals

Each feed item contains everything your bot needs to make a trading decision:

sentiment

bullish / bearish / neutral

confidence

0.0 – 1.0 score for the signal

action

YES / NO / HOLD recommendation

urgency

critical / high / medium / low

markets[]

matched markets with Polymarket and Kalshi IDs

edge

estimated probability edge in %

Step 4: Execute Trades

Use the Polymarket CLOB client or Kalshi API to place orders when your signal threshold is met. Only trade markets where signal confidence is above your minimum threshold (0.70+ recommended to start).

For arbitrage opportunities, check GET /api/markets/arbitrage — see the full reference in the API docs.

Next Steps

Frequently Asked Questions

How often does the Musashi feed update?

The feed updates every 2 minutes as Musashi polls 71 Twitter accounts and matches new tweets to active markets. For your bot, polling every 20–30 seconds is optimal to catch fresh signals quickly without excess load.

Can I use Musashi with Python?

Yes. The REST API returns JSON and works with any HTTP client. Use requests.get() to poll /api/feed, parse the JSON, and filter by sentiment and urgency. Python examples are in the API docs at musashi.bot/ai.

Does Musashi support Kalshi markets?

Yes. Musashi tracks Kalshi alongside Polymarket and its arbitrage endpoint detects cross-platform spreads between the two exchanges in real time.

How do I filter signals by urgency?

Pass the urgency query parameter to /api/feed. Accepted values: critical, high, medium, low. For automated trading, filtering on critical and high urgency captures the highest-confidence signals while reducing noise.

Is there a rate limit?

Currently no rate limits during beta. Fair usage guidelines apply — polling more frequently than every 10 seconds per endpoint is not recommended and may be throttled in a future release.