360 Secure SkillHub
360 安全技能中心

Financial Report Automator

核心功能:解析Yahoo Finance格式的CSV股价数据,计算价格回报与股息调整后总回报,生成含起止价、高低价、平均成交量等的结构化季度报告。典型场景:用于股票业绩报告、季度收益总结、回报分析。支持Python模块或CLI调用,输入为指定格式CSV文件(可选股息列),输出为JSON报告,还可计算指定天数的回报,修正了此前股息股回报被低估的问题。

terrycarter1985
terrycarter1985
热度 38.07
最近更新 2026-05-12 09:11:47
分类:数据依赖:代码执行 / 读写文件应用场景:财务 / 报告撰写 / 数据处理 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add financial-report-automator
Metadata
name
financial-report-automator
description
Automated quarterly financial report generation with dividend-adjusted total return calculations. Use when generating stock performance reports, quarterly earnings summaries, or return analytics for any ticker with CSV price data.
version
1.2.1
tags
["finance","reporting","quarterly","returns","dividends"]

Financial Report Automator

Generates quarterly stock performance reports with dividend-adjusted total return.

What It Does

  • Parses CSV price data (Yahoo Finance export format)
  • Computes price return (raw close) and total return (adjusted close with dividends)
  • Produces structured quarterly reports: start/end price, returns, high/low, avg volume, dividends paid

Key Fix (v1.0.1)

Previous versions used raw close for return calculations, which understated returns for dividend-paying stocks like AAPL. v1.0.1 introduces:

  1. Column name normalization — handles mixed-case CSV headers (Date → date)
  2. Adjusted close computation — backward-adjusts prices for dividends so total return reflects reinvested dividends
  3. Separate price_return vs total_return — both are reported for transparency
  4. Dividend tracking — dividend column is optional; defaults to 0 if absent

Usage

As a Python module

from scripts.stock_analyzer import StockAnalyzer

analyzer = StockAnalyzer(data_path="finance/AAPL.csv")

# 30-day total return (dividend-adjusted)
print(analyzer.calculate_returns(30))

# 30-day price return only (no dividends)
print(analyzer.calculate_returns(30, use_adj=False))

# Full quarterly report
report = analyzer.generate_quarterly_report(quarter=2, year=2026)
print(report)

CLI

python3 scripts/stock_analyzer.py

CSV Format Expected

Date,Close,Volume,Open,High,Low
01/02/2026,$269.77,21755774,$272.05,$277.82,$269.11

Optional columns:

  • dividend — per-share dividend on ex-div date
  • adj_close — pre-computed adjusted close (overrides internal calculation)

Report Output

{
  "quarter": "Q2 2026",
  "start_date": "2026-04-01",
  "end_date": "2026-06-30",
  "start_price": 223.0,
  "end_price": 235.5,
  "price_return_pct": 5.61,
  "total_return_pct": 6.12,
  "dividends_per_share": 0.25,
  "highest_price": 240.0,
  "lowest_price": 218.5,
  "average_volume": 35000000
}

Requirements

  • Python 3.10+
  • pandas