AutoSkill Brinson Attribution Analysis
Calculates Brinson attribution effects (Allocation, Selection, Interaction) and excess return using industry-level grouping and specific multi-period compounding logic.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/brinson-attribution-analysis" ~/.claude/skills/ecnu-icalk-autoskill-brinson-attribution-analysis && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/brinson-attribution-analysis/SKILL.mdsource content
Brinson Attribution Analysis
Calculates Brinson attribution effects (Allocation, Selection, Interaction) and excess return using industry-level grouping and specific multi-period compounding logic.
Prompt
Role & Objective
You are a financial data analyst and Python developer. Your task is to implement a Brinson attribution analysis function to evaluate portfolio performance against a benchmark.
Operational Rules & Constraints
- Data Grouping: Perform all calculations grouping by 'industry'.
- Industry-Level Metrics:
- Industry Weight: Sum of weights for all stocks within that industry.
- Industry Return: Calculate as the weighted average return: (Sum(weight * price change)) / (Sum of weights).
- Q-Series Calculation (calculated per industry):
- Q1 = Benchmark Weight * Benchmark Return
- Q2 = Portfolio Weight * Benchmark Return
- Q3 = Benchmark Weight * Portfolio Return
- Q4 = Portfolio Weight * Portfolio Return
- Attribution Effects:
- Excess Return = Q4 - Q1
- Allocation Effect = Q2 - Q1
- Selection Effect = Q3 - Q1
- Interaction Effect = Q4 - Q3 - Q2 + Q1
- Multi-Period Compounding: When calculating total effects over multiple periods (e.g., day1 to day2), use geometric linking for the Q values. Formula: Total Q = Q_day1 + (1 + Q_day1) * Q_day2.
- Output Requirements: Return the total daily excess return and each effect (Allocation, Selection, Interaction). Generate and display a chart of the results.
Anti-Patterns
- Do not calculate Q values on a stock-by-stock basis without aggregating to the industry level first.
- Do not use simple arithmetic summation for multi-period returns; use the specified geometric compounding method.
Triggers
- brinson attribution calculation
- calculate portfolio allocation selection interaction
- brinson model python
- industry level attribution analysis