Skip to content

wenyupapa-sys/tradingagents-codex-skill

tradingagents-codex

Verified

Run the local TradingAgents Codex fork for multi-agent stock and ETF research. Use when the user asks to analyze tickers with TradingAgents, run codex-analyze, batch stock/ETF research, summarize TradingAgents reports, validate the TradingAgents Codex setup, or turn QQQ/TSLA-style full-chain analysis into a repeatable workflow.

FileKindSize
SKILL.mdskill md4.0 KB
agents/openai.yamlconfig242 B
assets/tradingagents-codex-skill-flow.pngbinary1.2 MB
references/troubleshooting.mdmarkdown1.5 KB
references/workflow.mdmarkdown2.1 KB
scripts/check_setup.pyexecutablescript4.2 KB
scripts/quick_validate.pyexecutablescript4.8 KB
scripts/run_analysis.pyexecutablescript5.4 KB
scripts/summarize_report.pyexecutablescript4.0 KB

scripts/summarize_report.py

View on GitHub
#!/usr/bin/env python3
"""Summarize a TradingAgents portfolio manager report."""

from __future__ import annotations

import argparse
import json
import os
import sys
from pathlib import Path
from typing import Any


DEFAULT_PROJECT = str(Path.home() / "TradingAgents_codex")


def resolve_project(raw: str | None) -> Path:
    return Path(raw or os.environ.get("TRADINGAGENTS_PROJECT") or DEFAULT_PROJECT).expanduser().resolve()


def find_run_dir(args: argparse.Namespace) -> Path:
    if args.run_dir:
        return Path(args.run_dir).expanduser().resolve()
    if not args.ticker or not args.date:
        raise SystemExit("Provide --run-dir or both --ticker and --date.")
    return resolve_project(args.project) / "codex_runs" / args.ticker.upper() / args.date


def load_report(run_dir: Path) -> tuple[dict[str, Any], Path]:
    report_json = run_dir / "reports" / "portfolio_manager.json"
    if not report_json.exists():
        existing = []
        if run_dir.exists():
            existing = [str(path.relative_to(run_dir)) for path in sorted(run_dir.rglob("*")) if path.is_file()]
        raise FileNotFoundError(
            f"Missing {report_json}. Existing artifacts: {existing[:40]}"
        )
    with report_json.open("r", encoding="utf-8") as handle:
        data = json.load(handle)
    if not isinstance(data, dict):
        raise ValueError(f"{report_json} must contain a JSON object")
    return data, report_json


def require(data: dict[str, Any], keys: list[str]) -> None:
    missing = [key for key in keys if key not in data]
    if missing:
        raise KeyError(f"portfolio_manager.json missing keys {missing}; available keys: {sorted(data.keys())}")


def as_list(value: Any) -> list[str]:
    if value is None:
        return []
    if isinstance(value, list):
        return [str(item) for item in value]
    return [str(value)]


def render_markdown(data: dict[str, Any], run_dir: Path) -> str:
    require(data, ["rating", "summary"])
    horizon = data.get("time_horizon") or data.get("horizon") or ""
    positioning = data.get("positioning") if isinstance(data.get("positioning"), dict) else {}
    report = run_dir / "reports" / "complete_report.md"

    lines = [
        f"# {data.get('ticker', '')} TradingAgents summary",
        "",
        f"- Analysis date: {data.get('analysis_date', '')}",
        f"- Rating: {data.get('rating', '')}",
    ]
    if horizon:
        lines.append(f"- Horizon: {horizon}")
    lines.extend(["", "## Summary", str(data.get("summary", ""))])

    if positioning:
        lines.extend(["", "## Positioning"])
        for key in ("entry", "size", "stop", "take_profit"):
            if key in positioning:
                lines.append(f"- {key}: {positioning[key]}")

    reasons = as_list(data.get("top_reasons"))
    if reasons:
        lines.extend(["", "## Top reasons"])
        lines.extend(f"- {item}" for item in reasons)

    risks = as_list(data.get("top_risks"))
    if risks:
        lines.extend(["", "## Top risks"])
        lines.extend(f"- {item}" for item in risks)

    lines.extend(["", f"Complete report: {report}"])
    return "\n".join(lines) + "\n"


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--project", help="Path to TradingAgents_codex project")
    parser.add_argument("--ticker", help="Ticker symbol")
    parser.add_argument("--date", help="Analysis date, YYYY-MM-DD")
    parser.add_argument("--run-dir", help="Direct run directory")
    parser.add_argument("--output", choices=["markdown", "json"], default="markdown")
    args = parser.parse_args()

    try:
        run_dir = find_run_dir(args)
        data, report_json = load_report(run_dir)
        if args.output == "json":
            print(json.dumps({"run_dir": str(run_dir), "report_json": str(report_json), "portfolio_manager": data}, ensure_ascii=False, indent=2))
        else:
            print(render_markdown(data, run_dir), end="")
    except Exception as exc:
        print(f"ERROR: {exc}", file=sys.stderr)
        return 1
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall