Agent skill

Question2report

by refraction-ray in refraction-ray/xalpha

Turn a natural-language financial question into a polished, self-contained HTML report.

MITAuto-check passedData & Analytics

Install Question2report

skills CLI
$ npx skills add refraction-ray/xalpha --skill question2report -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install refraction-ray/xalpha question2report --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/refraction-ray/xalpha.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/question2report .claude/skills/question2report && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
question2report
GitHub stars
2.7k
Token cost
~3.2k tokens
SKILL.md length
1,414 words
Files
3
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

Turn a natural-language financial question into a polished, self-contained HTML report.

  • Works in 8 steps: Analyze the Question → Confirm Scope → Discover Suitable APIs → …
  • The user asks for any financial data comparison
  • SKILL.md covers Pipeline, Step 1 — Analyze the Question, Step 2 — Confirm Scope and Step 3 — Discover Suitable APIs, plus 8 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Question2report is an agent skill from refraction-ray/xalpha. Turn a natural-language financial question into a polished, self-contained HTML report. Covers the full pipeline: requirement analysis → scope negotiation → data fetching → data cleaning → quantitative analysis → visualization → beautiful HTML output. Use when the user asks for any financial data comparison, fund screening, index analysis, or strategy back-test that should end with a deliverable report.

Its SKILL.md is about 3.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files (for example `examples/sample_report_structure.md`).

It sits in Data & Analytics, covering Data cleaning, Trading and backtesting and HTML artifacts. The licence is MIT.

When your agent uses it

  • The user asks for any financial data comparison
  • Strategy back-test that should end with a deliverable report

Example prompts

  • “/question2report”

Requirements

  • Python 3

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Analyze the Question
  2. Confirm Scope
  3. Discover Suitable APIs
  4. 1 — Common xalpha APIs & Interfaces
  5. Fetch & Clean Data
  6. Quantitative Analysis
  7. 1 — Pro-Tips for Reliable Analysis
  8. Generate the HTML Report

What it can do on your machine

Read from SKILL.md and the folder at commit a072712. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Question2report loads about 3.2k tokens when it runs. Until then it costs about 106 tokens; SKILL.md has 1,414 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~106
When it runs · the whole SKILL.md, loaded when a task matches
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from refraction-ray/xalpha at commit a072712, republished under its MIT licence (© refraction-ray). 1,414 words, ~3,203 tokens.

Download SKILL.mdSave it as .claude/skills/question2report/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
question2report
description
Turn a natural-language financial question into a polished, self-contained HTML report. Covers the full pipeline: requirement analysis → scope negotiation → data fetching → data cleaning → quantitative analysis → visualization → beautiful HTML output. Use when the user asks for any financial data comparison, fund screening, index analysis, or strategy back-test that should end with a deliverable report.
argument-hint
<question about financial data or analysis>

Question → Report Skill

Transform a user's free-form financial question into a production-quality, self-contained HTML report with embedded charts and tables.

Pipeline

User Question
     │
     ▼
┌──────────────────┐
│ 1. ANALYZE       │  Parse intent, identify assets, metrics, time range
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ 2. CONFIRM       │  Present analysis plan to user; agree on scope
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ 3. DISCOVER API  │  Explore the xalpha codebase to find suitable APIs
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ 4. FETCH & CLEAN │  Write & run a Python script; handle errors & NaN
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ 5. ANALYZE DATA  │  Compute metrics appropriate to the question
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ 6. GENERATE HTML │  Build a beautiful, self-contained HTML report
└──────────────────┘

Step 1 — Analyze the Question

Parse the user's natural-language question and extract:

  • Subject: What assets, funds, indices, or strategies are being discussed?
  • Comparison / benchmark: Is there a reference to compare against?
  • Time range: Explicit dates, or implied ("last 3 years", "since inception"). Default to the most recent 3 full calendar years if unspecified.
  • Desired output: What kind of insights does the user want? (rankings, trend comparison, risk analysis, prediction accuracy, etc.)

If fund codes or asset identifiers are not given, research them via web search or by exploring the xalpha codebase for relevant list/search APIs.

Step 2 — Confirm Scope

Before any data work, present a concise plan to the user:

📋 Analysis Plan
─────────────────────────────────
Subject   : <what is being analyzed>
Assets    : <list of codes / tickers>
Period    : <start> → <end>
Analysis  : <what metrics / comparisons will be computed>
Charts    : <what visualizations will be included>
─────────────────────────────────
Shall I proceed, or would you like to adjust?

Wait for user confirmation before proceeding. Adjust scope if requested.

Step 3 — Discover Suitable APIs

Do NOT assume which xalpha APIs to use. Instead:

  1. Explore the codebase — read xalpha/__init__.py, outlines of key modules like universal.py, info.py, toolbox.py, evaluate.py, indicator.py, etc.
  2. Identify the right functions for the user's question. The xalpha library is rich: it supports funds, indices, stocks, bonds, QDII, commodities, forex, PE/PB valuation, portfolio back-testing, holdings analysis, and more.
  3. Check function signatures and docstrings to understand parameters, return types, and any known quirks (e.g. some classes don't accept start in __init__).
  4. If you encounter an API error at runtime, read the traceback, explore the source for alternatives, and fix the script. Be resilient.

Step 3.1 — Common xalpha APIs & Interfaces

To accelerate discovery, prioritize these common interfaces in the xalpha package:

Data Fetching (xalpha.universal)
  • xa.get_daily(code, start=None, end=None): The "universal" historical data fetcher.

    • A-Share: SH600000 (prefix SH/SZ + 6-digit code).
    • HK-Share: HK00700.
    • US-Share: AAPL, MSFT.
    • Funds: F000001 (unit net value), T000001 (accumulated net value).
    • Valuation: peb-SH000300 (Index PE/PB, requires JQData), peb-600000 (Stock PE/PB, handles 6-digit codes automatically, no JQ required).
  • xa.get_rt(code): Fetches real-time price and basic metadata (name, market, etc.).

Fund Analysis (xalpha.info)
  • xa.fundinfo(code, path=None, priceonly=True): Core class for fund data.
    • .price: DataFrame with date and netvalue.
    • .get_holdings(year, season): Quarterly holdings data.
Backtesting & Portfolios (xalpha.trade, xa.multiple)
  • xa.trade(fund_obj, status_df): Backtests a single fund/asset based on a transaction table (status_df).
  • xa.itrade(fund_obj, status_df): For exchange-traded assets (stocks/ETFs).
  • xa.multiple(trade_list): Aggregates multiple trade/itrade objects into a portfolio.
    • .v_totvalue(): Visualizes the portfolio total value curve.
    • .combsummary(): Generates a summary table of the portfolio performance.
Evaluation & Comparison (xalpha.evaluate, xa.toolbox)
  • xa.evaluate(asset_obj): Provides comprehensive performance metrics (Sharpe, Max Drawdown).
  • xa.compare(list_of_objs, start=None): Compares multiple assets/strategies on a normalized (1.0) scale.
Technical Indicators (xalpha.indicator)
  • xa.indicator(daily_df): Wraps a daily price DataFrame to compute indicators like MA, RSI, MACD.

Step 4 — Fetch & Clean Data

Write a single self-contained Python script that:

  1. Imports xalpha and any needed stdlib/pandas/numpy modules.
  2. Fetches all required data using the APIs discovered in Step 3.
  3. Workspace Organization: If you create scratch scripts (e.g., test_api.py, diag.py) or temporary files to debug, create them directly in the target report folder or move them there immediately.
  4. Handles errors gracefully — if one data source fails, try fallbacks; if one asset in a list fails, skip it and warn rather than crash.
  5. Cleans the data:
    • Ensure dates are datetime64.
    • Handle NaN: forward-fill small gaps (≤3 days); drop assets with >30% missing.
    • Align data on common trading dates when comparing multiple series.
  6. Saves intermediate results to a temporary workspace CSV (or keeps in memory if the script does everything in one pass).

Run the script using the user's specified Python/conda environment. If not specified, use the system default.

Step 5 — Quantitative Analysis

Compute metrics appropriate to the user's question. Do not blindly apply a fixed set of metrics. Choose what makes sense:

  • For return comparison: total return, annualized return, excess return / alpha.
  • For risk analysis: max drawdown, annualized volatility, Sharpe ratio.
  • For tracking analysis: tracking error, information ratio, correlation.
  • For valuation: PE/PB percentiles, dividend yield.
  • For prediction accuracy: predicted vs actual, RMSE, hit rate.
  • For portfolio analysis: asset allocation, sector exposure, concentration.

The agent should determine which metrics are relevant based on the question context.

Step 5.1 — Pro-Tips for Reliable Analysis

Apply these principles to avoid common pitfalls in quantitative reporting:

  • Unit Consistency: Verify if your backtesting engine treats trade inputs as shares or cash value. Inconsistent handling (e.g., selling "100 shares" but interpreting it as "100 dollars") is a frequent cause of hidden performance erosion.
  • Cross-Verification: Don't trust high-level CAGR/NAV metrics blindly. Periodically reconcile the final liquidity by summing raw cash flows from underlying trade logs.
  • Contextual Visuals: Use timeline mapping (Gantt-style) to show when a strategy was "Active" vs. "Hedged/In Cash". This explains why a performance gap occurred, providing more insight than a simple NAV curve.
  • Document Framework Patches: If you apply a library-specific fix (e.g., a monkey-patch or a non-standard initialization) to bypass a known bug, document it clearly in the methodology notes.

Step 6 — Generate the HTML Report

This is the most important step for user experience. The report must be:

Show full SKILL.md (595 more words)Show less
Interactive & Self-Contained
  • All CSS, JS logic, and raw data are embedded. The HTML file must render perfectly when opened directly in any browser.
  • Interactive Charts: Load high-quality interactive charting libraries (specifically Apache ECharts, or alternatively Chart.js) from highly reliable public CDNs (e.g., cdn.jsdelivr.net or cdnjs.cloudflare.com). ECharts is strongly recommended for financial data because of its native support for data zoom sliders, interactive legends, crosshairs, CJK tooltips, and high-quality styling.
  • Data Serialization: In the python script, serialize raw timeseries data (dates, returns, alpha curves, drawdowns) as a JSON object, and inject it inside the HTML in a <script> block. This allows the browser to perform calculations (such as dynamic start/end date selection and real-time return metrics calculation).
  • Do NOT use static Matplotlib PNG images unless interactive libraries are absolutely unavailable.
Visually Polished & Responsive

Follow the design system in templates/report_style.css:

  • Color palette: Professional dark/light-themed design using CSS variables. Primary dark blue/teal, warm accent colors. Positive values in green (#27ae60), negative in red (#e74c3c).
  • Layout: Card-based responsive grids with subtle transitions and interactive tabs to switch between tables or groups.
  • Typography: System font stack with CJK support.
  • Tables: Zebra-striped rows, interactive hover highlights, conditional coloring for performance metrics.
  • Dynamic Charts: Consistent CJK label support, gridlines, responsive sizing, and interactive legend toggles.
  • Controls: Add clean UI selectors (tabs, buttons, sliders) to allow the user to toggle between different metrics or filter the display dynamically.
Structured Sections

Every report should include (adapt as needed):

  1. Header — Report title, date range, generation timestamp.
  2. Executive Summary — 3–5 bullet points with key takeaways. This is what a busy reader should see first.
  3. Data & Charts — The main analytical content: comparison charts, distribution plots, time series, etc. One card per logical section.
  4. Metrics Tables — Summary tables with computed statistics. Use conditional formatting (green/red) for values where direction matters.
  5. Methodology Note — Brief paragraph on data source and any caveats.
  6. Footer — "Generated by xalpha · question2report skill · {date}".
Output Location & Organization

All generated artifacts—including the fetching/analysis Python scripts, intermediate data files (JSON/CSV), and the final HTML report—must be organized into a dedicated folder.

  • Default Location: <project_root>/doc/samples/reports/<descriptive_name>_<YYYYMMDD>/
  • Custom Location: If the user specifies a directory, use that.

The folder structure should look like this:

<report_folder>/
├── <fetch_and_analyze_script>.py
├── <generate_report_script>.py
├── <data_results>.json
└── <final_report>.html

Cleanup

After the report is generated successfully:

  • Move all related scripts, debug/test files, and intermediate data files into the designated output folder. DO NOT leave any temporary files (e.g., test_fetch.py, diag.py, data.csv) in the project root.
  • Perform a final cleanup: Delete any transient test scripts or log files that are not part of the final reproducible analysis (unless they are valuable for documenting the process). Ensure the project environment is as clean as it was before the task started.
  • Verify the HTML report correctly is 100% self-contained for the best portability.

Error Handling Philosophy

  • Fail gracefully: if one asset out of many fails, skip it and note the skip in the report, rather than aborting the whole pipeline.
  • Informative errors: when a script fails, read the traceback, understand the root cause, fix the script, and re-run. Don't just report the error to the user without attempting a fix.
  • Interactive fallbacks: If CDN scripts fail to load, ensure the page falls back to simple table views or provides a clear error notification rather than crashing. Ensure local JSON data is still fully accessible.
  • Framework Patching: If you encounter a bug in a 3rd-party library (like the TypeError in xalpha.multiple or ZeroDivisionError in combsummary), document the patch you applied in the Methodology Note of the report.

Additional Resources

© refraction-ray, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in .agents/skills/question2report of refraction-ray/xalpha.

  • SKILL.md
  • examples/sample_report_structure.md
  • templates/report_style.css

Open the folder on GitHubat commit a072712

Compare with similar skills

Question2report next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Question2report compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Question2report this skillrefraction-ray/xalpha2.7k—~3.2kAutomated safety check: PassMIT
Prediction Market Risk Reviewaffaan-m/ECC274k1 repos~471Automated safety check: PassMIT
Cja Dimension Analysisadobe/skills195—~3.3kAutomated safety check: PassApache-2.0
Openbb Data Fetchermonarchjuno/vibe-investing299—~2.9kAutomated safety check: NotesMIT
Polymarketmachina-sports/sports-skills242—~1.9kAutomated safety check: PassMIT
Feature Engineeringagiprolabs/claude-trading-skills410—~2.7kAutomated safety check: PassMIT

Similar skills

  • Review prediction-market, basket, oracle, and trading-agent workflows for compliance, safety, data-quality, privacy, and execution risk.

    274k GitHub starsUsed in 1 repo~471 tokens
    Data & AnalyticsAuto-check passed
  • Comprehensive dimension analysis and reporting for CJA. An agent skill from adobe/skills.

    195 GitHub stars~3.3k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed
  • Openbb Data Fetcher

    monarchjuno/vibe-investing

    Fetch financial, market, economic, fundamental, news, options, crypto, ETF, index, and macro data through the OpenBB Python interface instead of the OpenBB MCP server.

    299 GitHub stars~2.9k tokensUpdated 5 mo ago
    Data & AnalyticsAuto-check: notes
  • Polymarket

    machina-sports/sports-skills

    Polymarket sports prediction markets — read-only live odds, prices, order books, events, series, and market search.

    242 GitHub stars~1.9k tokensUpdated 2 days ago
    Data & AnalyticsAuto-check passed
  • Feature Engineering

    agiprolabs/claude-trading-skills

    Feature construction from market data for ML trading models including price, volume, on-chain, and microstructure features

    410 GitHub stars~2.7k tokensUpdated 1 mo ago
    Data & AnalyticsAuto-check passed
  • Trading Visualization

    agiprolabs/claude-trading-skills

    Professional trading charts including candlesticks, equity curves, drawdowns, correlation heatmaps, and return distributions

    410 GitHub stars~2.8k tokensUpdated 1 mo ago
    Data & AnalyticsAuto-check passed

Questions about Question2report

What does Question2report do?

Turn a natural-language financial question into a polished, self-contained HTML report. Question2report is an agent skill from refraction-ray/xalpha. Turn a natural-language financial question into a polished, self-contained HTML report.

When should I use Question2report?

Question2report fits situations like: the user asks for any financial data comparison; strategy back-test that should end with a deliverable report.

How do I install Question2report in Claude Code?

Run `npx skills add refraction-ray/xalpha --skill question2report -a claude-code`. Or copy the skill folder (.agents/skills/question2report in refraction-ray/xalpha) into .claude/skills/question2report in your project. Claude Code loads it when a task matches its description.

How do I install Question2report in Codex?

Run `npx skills add refraction-ray/xalpha --skill question2report -a codex`. Or copy the skill folder (.agents/skills/question2report in refraction-ray/xalpha) into .agents/skills/question2report in your project. Codex loads it when a task matches its description.

Can I use Question2report in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add refraction-ray/xalpha --skill question2report -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/question2report, .gemini/skills/question2report, .github/skills/question2report and .opencode/skills/question2report in your project.

What does Question2report need to run?

SKILL.md names no scripts, command-line tools or credentials: Question2report is instructions for the agent only. Our summary lists: Python 3.

Does Question2report access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Question2report safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Question2report use?

Question2report is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Question2report use?

About 3.2k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Question2report?

Skills that share tags, products or a category with Question2report: Prediction Market Risk Review (affaan-m/ECC, 274k stars), Cja Dimension Analysis (adobe/skills, 195 stars), Openbb Data Fetcher (monarchjuno/vibe-investing, 299 stars) and Polymarket (machina-sports/sports-skills, 242 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Question2report?

refraction-ray (a GitHub user) maintains it in refraction-ray/xalpha, which has 2,720 GitHub stars. The repository was last updated on July 25, 2026.

Source: refraction-ray/xalpha on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.