Skip to content

Latest commit

 

History

History
275 lines (228 loc) · 11.9 KB

File metadata and controls

275 lines (228 loc) · 11.9 KB
name investment-analysis
version 2.0.0
description Multi-agent investment research and analysis system by Tododeia. Use when the user wants market analysis, investment research, or a summary of current opportunities across crypto, stocks, forex, and commodities. Spawns 5 specialized research agents (4 sector + 1 strategy), adapts to user risk profile, tracks historical accuracy, and generates a branded interactive HTML report served locally. Trigger phrases: "investment analysis", "market research", "analyze markets", "investment opportunities", "what should I invest in", "market report", "tododeia", "investment advice", "portfolio recommendations", "run tododeia", "daily market analysis", "weekly report".
user_invocable true

Tododeia Investment Analysis — Multi-Agent System v2

You are the orchestrator of a multi-agent investment research system branded as Tododeia by @soyenriquerocha. You manage 5 specialized agents, adapt to user risk profiles, track historical accuracy, and generate an interactive branded HTML report.

Workflow

Follow these steps exactly:

Step 1: Determine Risk Profile

Before any research, ask the user their risk tolerance using the AskUserQuestion tool:

Question: "What's your investment risk profile?" Options:

  1. Conservative — "Capital preservation, stable returns, lower risk (bonds, blue chips, gold)"
  2. Moderate — "Balanced growth and safety, diversified across sectors (Recommended)"
  3. Aggressive — "Maximum growth potential, comfortable with high volatility (crypto, growth stocks, leveraged positions)"

Store the selected profile as the risk_profile variable ("conservative", "moderate", or "aggressive"). This profile will be passed to the Strategy Agent and used to filter recommendations.

Step 2: Load Agent Prompts

Read the file references/agent-prompts.md relative to this skill's directory. Use the Glob tool to find this skill's installation path by searching for **/jere-noticias-inver/references/agent-prompts.md or **/investment-analysis/references/agent-prompts.md.

Step 3: Load Historical Data

Check if previous reports exist at output/history/ in the user's current working directory. If the directory exists, read the most recent JSON file (sorted by filename which uses date format YYYY-MM-DD.json). This historical data will be passed to the Strategy Agent for accuracy tracking.

If no history exists, that's fine — this is the first run.

Step 4: Spawn 4 Sector Research Agents

Launch all 4 agents in parallel using the Agent tool in a single message. Each agent must use WebSearch and WebFetch to gather current market data. Pass each agent its sector-specific prompt from the agent-prompts file.

The 4 sector agents are:

  1. Crypto Agent — Discovers 5-7 best crypto assets to analyze (always includes BTC + ETH, dynamically finds trending/promising altcoins)
  2. Stocks Agent — Discovers 5-8 best stocks to analyze (always includes SPX + IXIC benchmarks, dynamically finds top-performing and catalyst-driven stocks across sectors)
  3. Currencies Agent — Discovers 5-7 most relevant currency pairs (always includes DXY + USD/MXN, dynamically finds pairs affected by current events)
  4. Materials Agent — Discovers 5-7 best commodities to analyze (always includes Gold + Oil WTI, dynamically finds trending commodities including agricultural if relevant)

Each agent MUST return a JSON block in this exact schema:

{
  "sector": "crypto|stocks|currencies|materials",
  "timestamp": "ISO 8601 date-time",
  "assets": [
    {
      "name": "Full Name",
      "symbol": "TICKER",
      "current_price": "$XX,XXX.XX",
      "change_24h": "+X.X%",
      "change_7d": "+X.X%",
      "change_30d": "+X.X%",
      "ytd_change": "+X.X%",
      "week_52_high": "$XX,XXX.XX",
      "week_52_low": "$XX,XXX.XX",
      "market_cap": "$X.XT",
      "volume_24h": "$X.XB",
      "sentiment": "bullish|bearish|neutral",
      "social_sentiment": "bullish|bearish|neutral|mixed",
      "social_buzz": "high|medium|low",
      "confidence": 7,
      "source_agreement": "high|medium|low",
      "sources_checked": ["source1.com", "source2.com"],
      "key_news": ["headline 1", "headline 2"],
      "social_highlights": ["tweet/post 1", "tweet/post 2"],
      "recommendation": "buy|hold|sell",
      "reasoning": "1-2 sentence explanation"
    }
  ],
  "sector_summary": "2-3 sentence overview of the sector",
  "sector_outlook": "bullish|bearish|neutral",
  "top_pick": "TICKER",
  "top_pick_reasoning": "Why this is the best opportunity in this sector"
}

Step 5: Spawn Strategy Agent

After all 4 sector agents return, launch the Strategy Agent using the Agent tool. Pass it:

  • All 4 sector JSON outputs
  • The user's risk_profile
  • Historical data from previous reports (if any)
  • The strategy agent prompt from references/agent-prompts.md

The Strategy Agent performs cross-sector analysis and MUST return this JSON:

{
  "risk_profile": "conservative|moderate|aggressive",
  "macro_environment": {
    "summary": "2-3 sentence macro overview (rates, inflation, geopolitics)",
    "interest_rate_outlook": "rising|stable|falling",
    "inflation_outlook": "rising|stable|falling",
    "geopolitical_risk": "high|medium|low",
    "key_factors": ["factor 1", "factor 2", "factor 3"]
  },
  "portfolio_allocation": {
    "crypto": 10,
    "stocks": 45,
    "currencies": 15,
    "materials": 20,
    "cash": 10
  },
  "cross_sector_insights": [
    {
      "insight": "Gold and crypto are both rallying — unusual correlation suggests...",
      "implication": "What this means for investors"
    }
  ],
  "risk_adjusted_picks": [
    {
      "rank": 1,
      "name": "Asset Name",
      "symbol": "TICKER",
      "sector": "crypto",
      "confidence": 9,
      "risk_score": 7,
      "risk_adjusted_score": 8.2,
      "recommendation": "buy",
      "reasoning": "Risk-adjusted reasoning for this profile",
      "position_size": "5-10% of portfolio"
    }
  ],
  "historical_accuracy": {
    "previous_date": "2026-03-12",
    "calls_made": 5,
    "calls_correct": 3,
    "accuracy_pct": 60,
    "notable": "BTC buy call at $65k now at $67.5k (+3.8%)"
  },
  "warnings": ["Any risk warnings or cautions"],
  "strategy_summary": "3-4 sentence strategy overview tailored to risk profile"
}

Step 6: Build the Report Data

Combine all agent outputs into the final REPORT_DATA object:

{
  "brand": "Tododeia",
  "creator": "@soyenriquerocha",
  "generated_at": "ISO 8601 timestamp",
  "risk_profile": "moderate",
  "executive_summary": "Strategy agent's strategy_summary",
  "macro_environment": { ...from strategy agent... },
  "portfolio_allocation": { ...from strategy agent... },
  "cross_sector_insights": [ ...from strategy agent... ],
  "risk_adjusted_picks": [ ...from strategy agent... ],
  "historical_accuracy": { ...from strategy agent... },
  "warnings": [ ...from strategy agent... ],
  "sectors": {
    "crypto": { ...sector agent output... },
    "stocks": { ...sector agent output... },
    "currencies": { ...sector agent output... },
    "materials": { ...sector agent output... }
  }
}

Step 7: Save Historical Data

  1. Create output/history/ directory if it doesn't exist.
  2. Save the REPORT_DATA as output/history/YYYY-MM-DD.json (using today's date).
  3. Keep only the last 30 report files — delete older ones to avoid bloat.

Step 8: Generate the Report

Primary (Next.js dashboard):

  1. Check if dashboard/package.json exists in the project directory. If yes, use the Next.js dashboard.
  2. Create dashboard/public/data/ directory if it doesn't exist.
  3. Write the REPORT_DATA JSON to dashboard/public/data/report.json.

Fallback (legacy HTML template): If dashboard/package.json does not exist (Node.js not set up):

  1. Find and read assets/template.html from this skill's directory (use Glob to locate it).
  2. Replace the token {{REPORT_DATA_JSON}} with the serialized REPORT_DATA JSON object.
  3. Create the output/ directory if it doesn't exist.
  4. Write the populated HTML to output/report.html.

Step 8b: Translate Report to Spanish

After writing the English report, spawn a Translation Agent to create a Spanish version:

  1. Read the English report from dashboard/public/data/report.json.
  2. Translate all human-readable text fields to Spanish:
    • executive_summary
    • strategy_summary
    • macro_environment.summary
    • macro_environment.key_factors[]
    • cross_sector_insights[].insight
    • cross_sector_insights[].implication
    • warnings[]
    • historical_accuracy.notable
    • Per sector: sector_summary, top_pick_reasoning
    • Per asset: reasoning, key_news[], social_highlights[]
  3. Do NOT translate: numbers, tickers, prices, dates, percentages, asset names, symbols, URLs, sentiment values, recommendation values.
  4. Write the translated report to dashboard/public/data/report-es.json.

The translation agent prompt:

You are a financial translator. Translate the following investment report JSON from English to Spanish. Translate only the human-readable text fields listed above. Preserve all numbers, tickers, prices, dates, percentages, asset names, symbols, URLs, and enum values (like "bullish", "buy", "high") exactly as-is. Return valid JSON with the same structure.

Step 9: Serve the Report

Primary (Next.js dashboard):

  1. Check if dashboard/node_modules/ exists. If not, run npm install --prefix dashboard.
  2. Check if port 3420 is available: lsof -i :3420
  3. If a dev server is already running on 3420, skip starting a new one (user just refreshes the browser).
  4. If not running, start it in background: npm run dev --prefix dashboard -- -p 3420
  5. Wait 3 seconds for the server to start.
  6. Tell the user:

Tododeia Investment Report is ready! Open: http://localhost:3420

Profile: {risk_profile} | Top Pick: {#1 risk-adjusted pick} | Portfolio: {allocation summary}

The report includes cross-sector strategy analysis, social sentiment, historical accuracy tracking, and interactive charts.

Fallback (legacy): If Node.js/npm is not available:

  1. Check if port 8420 is available: lsof -i :8420
  2. If busy, try ports 8421-8425.
  3. Start the server in background: python3 -m http.server PORT --directory output
  4. Tell the user to open: http://localhost:PORT/report.html

Step 10: Offer Scheduling

After showing the report URL, ask the user:

Want daily or weekly reports? I can set up automatic scheduling:

  • /loop 24h /investment-analysis for daily reports
  • /loop 168h /investment-analysis for weekly reports

Or just run it manually anytime by saying "run investment analysis".

Do NOT auto-set this up — only mention it as an option.

Error Handling

  • If WebSearch returns no results for an asset, try WebFetch on known financial sites (Yahoo Finance, CoinGecko, Google Finance).
  • If an agent returns malformed JSON, re-prompt it once with correction instructions. If it still fails, mark that sector as "data_unavailable": true.
  • If the Strategy Agent fails, fall back to simple confidence-score ranking (v1 behavior) and note "Strategy analysis unavailable" in the report.
  • If Python is not available, try npx serve output -p PORT or tell the user to open output/report.html directly in their browser.
  • If all web searches fail (no internet), generate the report with "No data available" messages.
  • If historical data files are corrupted, skip accuracy tracking and start fresh.

Important Notes

  • Always use today's date when constructing search queries.
  • The report MUST include a visible disclaimer that this is not financial advice.
  • Never cache or reuse old data — every invocation does fresh research.
  • Keep agent prompts focused — each sector agent should do 5-8 targeted web searches (including social media).
  • The Strategy Agent is the brain — give it ALL sector data and let it do the cross-sector thinking.
  • Risk profile shapes everything: which assets to emphasize, position sizes, and allocation percentages.