Skip to main content

AI Research Engine

Meridian Themes uses an AI-powered research engine to generate automated briefings.

Overview

The research engine:

  1. Takes theme tickers and prompts
  2. Sends queries to Perplexity via OpenRouter
  3. Receives live web research with citations
  4. Stores insights in the theme timeline

How It Works

┌─────────────────────────────────────────────────────────┐
│ Research Query │
├─────────────────────────────────────────────────────────┤
│ Theme: Copper Breakout │
│ Tickers: HG=F, SCCO, FCX │
│ Prompt: "Analyze copper supply news from Chile" │
└───────────────────────┬─────────────────────────────────┘


┌─────────────────────────────────────────────────────────┐
│ OpenRouter → Perplexity │
│ (sonar-medium-online) │
└───────────────────────┬─────────────────────────────────┘


┌─────────────────────────────────────────────────────────┐
│ Research Output │
├─────────────────────────────────────────────────────────┤
│ Content: Markdown-formatted analysis │
│ Sources: [url1, url2, url3...] │
│ Generated: 2025-01-12 09:00:00 │
└─────────────────────────────────────────────────────────┘

Perplexity Integration

Why Perplexity?

  • Live web search: Real-time market news
  • Citation included: Verify sources
  • Financial focus: Good at market analysis
  • Via OpenRouter: Unified API access

Model Selection

Recommended models for research:

ModelUse Case
perplexity/sonar-medium-onlineStandard research
perplexity/sonar-large-onlineDeep analysis

Configuration

# .env
OPENROUTER_API_KEY=sk-or-v1-xxx
RESEARCH_MODEL=perplexity/sonar-medium-online

Research Scheduling

Frequency Options

FrequencyUse Case
DailyActive trading themes
WeeklyLong-term positions
On-demandEvent-driven research

Scheduled Jobs

Research can be triggered:

  • Manually via "Generate Report" button
  • Automatically via cron job
  • On-demand from theme detail page

Query Construction

Template Structure

function buildResearchQuery(theme: Theme): string {
const tickerList = theme.tickers.join(', ');
const basePrompt = theme.researchPrompts[0].prompt_text;

return `
Research the following financial instruments: ${tickerList}

Focus on: ${basePrompt}

Provide:
1. Key recent developments
2. Market sentiment analysis
3. Price action summary
4. Notable news or events

Include source citations.
`;
}

Prompt Engineering Tips

Be specific about:

  • Timeframe (last 24 hours, this week)
  • Geographic focus (Chile, China, global)
  • Event types (earnings, regulatory, supply chain)
  • Output format (bullet points, summary)

Output Storage

Theme Insights Table

CREATE TABLE theme_insights (
id UUID PRIMARY KEY,
theme_id UUID REFERENCES themes(id),
content TEXT NOT NULL, -- Markdown report
sources JSONB, -- Citation URLs
created_at TIMESTAMPTZ DEFAULT NOW()
);

Insight Object

{
"id": "uuid",
"theme_id": "uuid",
"content": "## Copper Market Update\n\n...",
"sources": [
"https://reuters.com/...",
"https://bloomberg.com/..."
],
"created_at": "2025-01-12T09:00:00Z"
}

Timeline Display

Insights appear in the theme timeline:

  • Chronological order (newest first)
  • Markdown rendering
  • Expandable source list
  • Delete/regenerate options