Building Applications

The real power of Quantish Agent is combining coding tools with trading tools to build any application that interacts with prediction markets. Trading bots, web dashboards, mobile backends, notification services, analytics tools, Discord bots, and more.

What You Can Build

🤖 Trading Bots

Automated trading based on price thresholds, trends, or external signals.

📊 Web Dashboards

React/Next.js apps displaying market data, portfolio, and analytics.

🔔 Alert Systems

Notifications via email, SMS, Discord, Telegram when prices move.

📱 Mobile Backends

API servers that power iOS/Android prediction market apps.

📈 Analytics Tools

Scripts that analyze historical prices, trends, and patterns.

💹 Arbitrage Scanners

Tools that find price discrepancies across platforms.

The MCP API

All applications use the Quantish MCP API. There are two endpoints:

Trading API (requires your API key)
POST https://quantish-sdk-production.up.railway.app/mcp/execute
Header: x-api-key: YOUR_QUANTISH_API_KEY

Used for: balances, positions, orders, trading

Discovery API (free, public)
POST https://quantish.live/mcp/execute
Header: X-API-Key: qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8

Used for: searching markets, trending data, arbitrage scanning

Universal Code Template

Every application you build should start with this template:

#!/usr/bin/env node
require('dotenv').config();

// ============================================
// MCP Configuration
// ============================================
const TRADING_MCP_URL = 'https://quantish-sdk-production.up.railway.app/mcp/execute';
const DISCOVERY_MCP_URL = 'https://quantish.live/mcp/execute';
const DISCOVERY_API_KEY = 'qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8';

// Validate API key
if (!process.env.QUANTISH_API_KEY) {
  console.error('ERROR: QUANTISH_API_KEY required');
  console.error('Get your key at: https://quantish.live');
  process.exit(1);
}

// ============================================
// MCP Helper Functions
// ============================================

async function callTradingTool(name, args = {}) {
  const response = await fetch(TRADING_MCP_URL, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.QUANTISH_API_KEY
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'tools/call',
      params: { name, arguments: args },
      id: Date.now()
    })
  });
  
  const data = await response.json();
  if (data.error) throw new Error(data.error.message);
  
  try {
    return JSON.parse(data.result.content[0].text);
  } catch {
    return data.result.content[0].text;
  }
}

async function callDiscoveryTool(name, args = {}) {
  // Discovery MCP uses simpler format (not JSON-RPC)
  const response = await fetch(DISCOVERY_MCP_URL, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': DISCOVERY_API_KEY
    },
    body: JSON.stringify({ name, arguments: args })
  });
  
  const data = await response.json();
  if (data.error) throw new Error(data.error.message);
  
  try {
    return JSON.parse(data.result.content[0].text);
  } catch {
    return data.result.content[0].text;
  }
}

// ============================================
// Your Application Code
// ============================================

async function main() {
  // Your code here...
}

main().catch(console.error);

Example: Ask the Agent

You: Build a Discord bot that responds to /market commands with current prices for any market
 
I'll create a Discord bot that queries prediction markets...
 
✓ write_file(path: "discord-bot/package.json")
✓ write_file(path: "discord-bot/index.js")
✓ write_file(path: "discord-bot/.env.example")
✓ write_file(path: "discord-bot/README.md")
Created discord-bot/ with 4 files!

Example: Web Dashboard

You: Create a React dashboard that shows my portfolio value, open positions, and recent trades
 
I'll create a React dashboard with portfolio tracking...
 
✓ shell_command(npx create-vite dashboard --template react)
✓ write_file(path: "dashboard/src/App.jsx")
✓ write_file(path: "dashboard/src/api/quantish.js")
✓ write_file(path: "dashboard/src/components/Portfolio.jsx")
Dashboard created!

Example: Trading Bot

You: Create a trading bot that:
1. Monitors my positions every 30 seconds
2. Sells when profit exceeds 20%
3. Sends Telegram notifications on trades
⚠️ Trading Risk

Automated trading carries risk. Test with small amounts first. The agent helps you build the code - you're responsible for the trading decisions.

Available Tools

Trading Tools (require API key)

Discovery Tools (free)

Best Practices

🔐 Environment Variables

Never hardcode API keys. Always use process.env and .env files.

📁 .env.example

Always create a template so others know what variables are needed.

🔒 Error Handling

Wrap all API calls in try/catch. Network errors happen.

⏱️ Rate Limiting

Don't poll too frequently. 30-60 second intervals are sufficient.