dividend-tracking

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Dividend Tracking

股息追踪

Purpose

目的

Import Fidelity dividend CSV data into the Dividends sheet input area, then trigger the Apps Script to process records into the historical log.
将Fidelity的股息CSV数据导入至股息表格的输入区域,然后触发Apps Script将记录处理至历史日志中。

Workflow Routing

工作流路由

When executing this workflow, output this notification:
Running the **SyncDividends** workflow from the **dividend-tracking** skill...
WorkflowTriggerAction
SyncDividends"sync dividends", "update dividends", "dividend tracker"CSV → Input Area → Click Button
执行此工作流时,输出以下通知:
Running the **SyncDividends** workflow from the **dividend-tracking** skill...
工作流触发词操作
SyncDividends"同步股息"、"更新股息"、"股息追踪"CSV → 输入区域 → 点击按钮

Dividends Sheet Architecture

股息表格架构

The Dividends tab has TWO SECTIONS:
股息标签页包含两个区域

Left Side: INPUT AREA (Columns A-D, Rows 2-43)

左侧:输入区域(A-D列,第2-43行)

This is where YOU write dividend records.
ColumnFieldSource
ATicketCSV Symbol
BDividends ReceivedCalculated: Quantity × Amount per share
CDateCSV Pay date (MM/DD/YYYY format)
DDRIPTRUE/FALSE
RULES:
  • ✅ Write to rows 2-43 ONLY (row 1 is header)
  • ✅ Maximum 42 records per batch
  • ❌ NEVER write past row 43
  • After writing, click "Add Dividend" button to process
这是你写入股息记录的区域。
字段来源
A股票代码CSV中的Symbol字段
B已收到股息计算得出:持股数 × 每股股息金额
C日期CSV中的派息日期(格式为MM/DD/YYYY)
DDRIP(股息再投资)TRUE/FALSE
规则:
  • ✅ 仅可写入第2-43行(第1行为表头)
  • ✅ 每批次最多42条记录
  • ❌ 绝对不可写入第43行之后
  • 写入完成后,点击“添加股息”按钮进行处理

Right Side: HISTORICAL LOG (Columns G-U, Rows 4+)

右侧:历史日志(G-U列,第4行及以后)

This is populated by the Apps Script - DO NOT WRITE HERE.
ColumnField
GFund Name
HTicker
I-TMonthly amounts (JAN-DEC)
UTotal
The Apps Script reads from the input area (A-D) and appends to the historical log (G onwards).
此区域由Apps Script自动填充 - 请勿在此写入内容。
字段
G基金名称
H股票代码
I-T月度金额(1月-12月)
U总计
Apps Script会读取输入区域(A-D列)的内容,并将其追加至历史日志(G列及以后)。

Core Workflow

核心工作流

1. Read Dividend CSV

1. 读取股息CSV文件

File Location:
notebooks/updates/dividend.csv
Key CSV Columns:
CSV ColumnUse
Symbol→ Column A (Ticket)
QuantityUsed to calculate dividend received
Amount per shareUsed to calculate dividend received
Pay date→ Column C (Date) - format as MM/DD/YYYY
TypeMargin/Cash (for aggregation)
文件位置
notebooks/updates/dividend.csv
CSV关键列:
CSV列用途
Symbol→ A列(股票代码)
Quantity用于计算已收到股息
Amount per share用于计算已收到股息
Pay date→ C列(日期) - 格式为MM/DD/YYYY
Type保证金/现金账户(用于聚合)

2. Calculate Dividends Received

2. 计算已收到股息

Dividends Received = Quantity × Amount per share
Aggregation Rules:
  • Sum quantities for same ticker (Margin + Cash accounts)
  • Use single row per ticker
  • Skip rows with
    --
    in Amount per share (non-dividend payers)
  • Only include pay dates that have PASSED (already received)
已收到股息 = 持股数 × 每股股息金额
聚合规则:
  • 对同一股票代码的持股数求和(保证金账户 + 现金账户)
  • 每个股票代码仅保留一行记录
  • 跳过每股股息金额为
    --
    的行(非派息标的)
  • 仅包含已过的派息日期(已实际收到股息)

3. Check Input Area Status

3. 检查输入区域状态

Read current input area:
javascript
mcp__gdrive__sheets(
    operation: "readSheet",
    params: {
        spreadsheetId: "{spreadsheet_id}",
        range: "Dividends!A2:D43"
    }
)
Determine:
  • First empty row (where to start writing)
  • Available slots (max 45 - current entries)
  • If full, STOP and alert user to click button first
读取当前输入区域:
javascript
mcp__gdrive__sheets(
    operation: "readSheet",
    params: {
        spreadsheetId: "{spreadsheet_id}",
        range: "Dividends!A2:D43"
    }
)
需要确定:
  • 第一个空行(写入起始位置)
  • 可用插槽数(最多45 - 当前已输入条目数)
  • 如果已满,停止操作并提醒用户先点击按钮清空

4. Write to Input Area

4. 写入输入区域

Write starting at first empty row:
javascript
mcp__gdrive__sheets(
    operation: "updateCells",
    params: {
        spreadsheetId: "{spreadsheet_id}",
        range: "Dividends!A2:D13",  // Adjust range based on record count
        values: [
            ["JEPI", "$51.63", "01/05/2026", "TRUE"],
            ["JEPQ", "$78.62", "01/05/2026", "TRUE"],
            // ... more records
        ]
    }
)
从第一个空行开始写入:
javascript
mcp__gdrive__sheets(
    operation: "updateCells",
    params: {
        spreadsheetId: "{spreadsheet_id}",
        range: "Dividends!A2:D13",  // 根据记录数量调整范围
        values: [
            ["JEPI", "$51.63", "01/05/2026", "TRUE"],
            ["JEPQ", "$78.62", "01/05/2026", "TRUE"],
            // ... 更多记录
        ]
    }
)

5. Click "Add Dividend" Button (Browser Automation)

5. 点击“添加股息”按钮(浏览器自动化)

After writing records, use browser automation to process them:
javascript
// 1. Open Google Sheets
mcp__claude-in-chrome__tabs_create_mcp({
    url: "https://docs.google.com/spreadsheets/d/{spreadsheet_id}/edit#gid=2068577140"
})

// 2. Wait for sheet to load
// 3. Look for "Add Dividend" button or custom menu
// 4. Click to trigger Apps Script
Alternative: Use Apps Script Menu
  • Extensions → Apps Script macros
  • Or custom menu added by the script
写入记录后,使用浏览器自动化工具进行处理:
javascript
// 1. 打开Google Sheets
mcp__claude-in-chrome__tabs_create_mcp({
    url: "https://docs.google.com/spreadsheets/d/{spreadsheet_id}/edit#gid=2068577140"
})

// 2. 等待表格加载完成
// 3. 查找“Add Dividend”按钮或自定义菜单
// 4. 点击以触发Apps Script
替代方案:使用Apps Script菜单
  • 扩展程序 → Apps Script宏
  • 或脚本添加的自定义菜单

6. Verify Processing

6. 验证处理结果

After clicking button:
  • Input area (A2:D43) should be cleared
  • Historical log should have new entries
  • Monthly totals should update
点击按钮后:
  • 输入区域(A2:D43)应被清空
  • 历史日志应新增条目
  • 月度总计应更新

Data Flow Diagram

数据流图

┌─────────────────────────────────┐
│  dividend.csv (Fidelity export) │
│  - Symbol, Quantity             │
│  - Amount per share, Pay date   │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  Calculate Dividends Received   │
│  Qty × Amount = Total Dividend  │
│  Aggregate by ticker            │
│  Filter: only PAST pay dates    │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  INPUT AREA (A2:D43)            │
│  Write calculated dividends     │
│  Max 42 records per batch       │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  CLICK "Add Dividend" BUTTON    │
│  (Browser automation or manual) │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  HISTORICAL LOG (G4+)           │
│  Apps Script processes input    │
│  Appends to monthly columns     │
└─────────────────────────────────┘
┌─────────────────────────────────┐
│  dividend.csv (Fidelity导出文件) │
│  - Symbol, Quantity             │
│  - Amount per share, Pay date   │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  计算已收到股息                 │
│  持股数 × 每股金额 = 总股息      │
│  按股票代码聚合                 │
│  过滤:仅包含已过派息日期       │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  输入区域(A2:D43)             │
│  写入计算后的股息数据           │
│  每批次最多42条记录             │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  点击“添加股息”按钮             │
│  (浏览器自动化或手动操作)        │
└──────────────┬──────────────────┘
┌─────────────────────────────────┐
│  历史日志(G4+)                │
│  Apps Script处理输入内容        │
│  追加至月度列                   │
└─────────────────────────────────┘

Apps Script Integration

Apps Script集成

The Dividends sheet has Apps Script automation that:
  • Reads records from input area (A2:D43)
  • Parses ticker, amount, date, DRIP status
  • Appends to historical log with proper date formatting
  • Updates monthly income columns (I-T)
  • Clears input area after processing
Script Location:
scripts/google-sheets/portfolio-optimizer/Dividend.js
Custom Menu: "Portfolio Optimizer" → (dividend-related options)
股息表格包含Apps Script自动化功能,可实现:
  • 读取输入区域(A2:D43)的记录
  • 解析股票代码、金额、日期、DRIP状态
  • 将数据追加至历史日志并格式化日期
  • 更新月度收入列(I-T列)
  • 处理完成后清空输入区域
脚本位置
scripts/google-sheets/portfolio-optimizer/Dividend.js
自定义菜单:“Portfolio Optimizer” → (股息相关选项)

Critical Rules

关键规则

WRITABLE Area

可写入区域

  • ✅ Columns A-D, Rows 2-43 (input area)
  • ✅ Maximum 42 records per batch
  • ✅ Must click "Add Dividend" button after writing
  • ✅ A-D列,第2-43行(输入区域)
  • ✅ 每批次最多42条记录
  • ✅ 写入完成后必须点击“添加股息”按钮

DO NOT MODIFY

禁止修改区域

  • ❌ Row 1 (header)
  • ❌ Rows 44+ in columns A-D
  • ❌ Columns G-U (historical log - Apps Script managed)
  • ❌ Any formulas
  • ❌ 第1行(表头)
  • ❌ A-D列的第44行及以后
  • ❌ G-U列(历史日志 - 由Apps Script管理)
  • ❌ 任何公式

Date Format

日期格式

  • Use MM/DD/YYYY (e.g., "01/05/2026")
  • Match existing entries in the sheet
  • 使用MM/DD/YYYY格式(例如:"01/05/2026")
  • 与表格中现有条目的格式保持一致

DRIP Status

DRIP状态

  • TRUE = dividend was reinvested (shares increased)
  • FALSE = dividend paid as cash
  • Default TRUE for accumulation phase
  • TRUE = 股息已再投资(持股数增加)
  • FALSE = 股息以现金形式发放
  • 积累阶段默认设为TRUE

Pre-Flight Checklist

预检查清单

Before syncing dividends:
  • dividend.csv
    exists in
    notebooks/updates/
  • CSV is recent (check "Date downloaded" at bottom)
  • Input area (A2:D43) has available slots
  • If input area has data, click button first to clear it
  • Browser automation available for button click
同步股息前请确认:
  • dividend.csv
    文件存在于
    notebooks/updates/
    目录中
  • CSV文件为最新版本(检查底部的“下载日期”)
  • 输入区域(A2:D43)有可用插槽
  • 如果输入区域已有数据,先点击按钮清空
  • 浏览器自动化工具可用于点击按钮

Example Scenario

示例场景

User: "sync dividends"
Agent workflow:
  1. ✅ Read CSV - found 40 rows
  2. ✅ Filter - 12 tickers with dividend data for past pay dates
  3. ✅ Aggregate - combined Margin/Cash positions
  4. ✅ Calculate - total dividends: $786.86
  5. ✅ Check input area - rows 2-43 empty, 42 slots available
  6. ✅ Write records - added 12 rows to A2:D13
  7. ✅ Open browser - navigate to Dividends sheet
  8. ✅ Click button - trigger "Add Dividend" Apps Script
  9. ✅ Verify - input area cleared, historical log updated
  10. ✅ LOG: "Synced 12 dividend records totaling $786.86"
用户:“同步股息”
Agent工作流
  1. ✅ 读取CSV文件 - 找到40行数据
  2. ✅ 过滤 - 12个股票代码包含已过派息日期的股息数据
  3. ✅ 聚合 - 合并保证金/现金账户的持仓
  4. ✅ 计算 - 总股息:$786.86
  5. ✅ 检查输入区域 - 第2-43行为空,有42个可用插槽
  6. ✅ 写入记录 - 向A2:D13添加12行数据
  7. ✅ 打开浏览器 - 导航至股息表格
  8. ✅ 点击按钮 - 触发“添加股息”Apps Script
  9. ✅ 验证 - 输入区域已清空,历史日志已更新
  10. ✅ 日志:“已同步12条股息记录,总计$786.86”

Google Sheets Integration

Google Sheets集成

Spreadsheet ID:
{spreadsheet_id}
Dividends Sheet ID:
2068577140
Direct URL:
https://docs.google.com/spreadsheets/d/{spreadsheet_id}/edit#gid=2068577140
表格ID
{spreadsheet_id}
股息标签页ID
2068577140
直接链接
https://docs.google.com/spreadsheets/d/{spreadsheet_id}/edit#gid=2068577140

Reference Files

参考文件

  • Dividend CSV:
    notebooks/updates/dividend.csv
  • Apps Script:
    scripts/google-sheets/portfolio-optimizer/Dividend.js
  • Spreadsheet: Finance Guru Portfolio Tracker (Dividends tab)

Skill Type: Domain (workflow guidance) Enforcement: SUGGEST (high priority advisory) Priority: High
  • 股息CSV文件
    notebooks/updates/dividend.csv
  • Apps脚本
    scripts/google-sheets/portfolio-optimizer/Dividend.js
  • 表格:Finance Guru Portfolio Tracker(股息标签页)

技能类型:领域(工作流指导) 执行方式:建议(高优先级建议) 优先级:高