AI Research Engine
Meridian Themes uses an AI-powered research engine to generate automated briefings.
Overview
The research engine:
- Takes theme tickers and prompts
- Sends queries to Perplexity via OpenRouter
- Receives live web research with citations
- 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:
| Model | Use Case |
|---|---|
perplexity/sonar-medium-online | Standard research |
perplexity/sonar-large-online | Deep analysis |
Configuration
# .env
OPENROUTER_API_KEY=sk-or-v1-xxx
RESEARCH_MODEL=perplexity/sonar-medium-online
Research Scheduling
Frequency Options
| Frequency | Use Case |
|---|---|
| Daily | Active trading themes |
| Weekly | Long-term positions |
| On-demand | Event-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