performance-attribution
ما الذي تفعله
تقسم هذه المهارة عوائد المحفظة إلى أسباب واضحة، مثل اختيارات القطاعات وانتقاء الأسهم. وهي موجهة لمديري الصناديق والمحللين الذين يحتاجون إلى تفسير النتائج.
متى تستخدمها
- ✓عندما تريد معرفة هل تفوقت المحفظة على مؤشرها المرجعي بسبب اختيارات القطاعات أم انتقاء الأسهم.
- ✓عندما تحتاج إلى فصل المهارة عن الحظ في عوائد الاستراتيجية.
- ✓عندما تراجع التعرض للعوامل وقرارات التوقيت بعد فترة من النتائج.
رابط المهارة
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/performance-attribution/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“لماذا تفوقت محفظتي على المؤشر المرجعي الربع الماضي؟ فصّل ذلك حسب القطاع.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تقارن المهارة أوزان المحفظة وعوائدها مع المؤشر المرجعي قطاعًا بقطاع. ثم تقسم الفرق إلى تأثيرات التخصيص والاختيار والتفاعل، التي تجمع بدقة إلى الفرق الكلي.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Performance Attribution Analysis
Overview
Decompose portfolio excess returns into explainable sources: sector allocation, stock selection, factor exposure, timing contribution, and more. This helps explain why a strategy made or lost money, rather than only how much it made or lost.
Brinson Attribution Model
Do not retype these formulas into throwaway Python. They are implemented and
tested in src/quantlib/attribution.py; import them.
Single-Period Brinson-Fachler Model
Let w_p,i = portfolio weight of sector i
w_b,i = benchmark weight of sector i
r_p,i = portfolio return of sector i
r_b,i = benchmark return of sector i
R_b = total benchmark return
Allocation_i = (w_p,i - w_b,i) × (r_b,i - R_b)
Selection_i = w_b,i × (r_p,i - r_b,i)
Interaction_i = (w_p,i - w_b,i) × (r_p,i - r_b,i)
Total active return = Σ(Allocation_i) + Σ(Selection_i) + Σ(Interaction_i)
The decomposition itself has no residual term. The three effects sum to
R_p - R_b identically, for any sector returns whatsoever, provided the
portfolio and benchmark weights carry the same total. brinson_fachler enforces
the weight-sum precondition and raises rather than returning a decomposition
that does not tie out.
A residual is therefore never a property of the algebra — but it is a real and expected property of a reported attribution, because the inputs are a snapshot. Intra-period trading, cash drag, corporate actions and FX translation all move the actual portfolio return away from the one these weights and sector returns imply. So:
- residual inside the decomposition, given the inputs → impossible; if you see one, the arithmetic or the weight convention is wrong;
- residual between the decomposition and the reported fund return → normal;
quantify it and attribute it to its source rather than absorbing it silently
into selection. This is what the
/attribreconciliation gate asks for.
from src.quantlib.attribution import brinson_fachler
result = brinson_fachler(
portfolio_weights={"Tech": 0.40, "Financials": 0.10, "Energy": 0.30, "Health": 0.20},
benchmark_weights={"Tech": 0.25, "Financials": 0.30, "Energy": 0.25, "Health": 0.20},
portfolio_returns={"Tech": 0.12, "Financials": 0.04, "Energy": -0.02, "Health": 0.07},
benchmark_returns={"Tech": 0.10, "Financials": 0.05, "Energy": -0.01, "Health": 0.06},
)
result.portfolio_return # 0.0600
result.benchmark_return # 0.0495
result.active_return # 0.0105
result.allocation # 0.0045
result.selection # 0.0015
result.interaction # 0.0045
# 0.0045 + 0.0015 + 0.0045 == 0.0105 exactly (residual ~3e-18, machine epsilon)
for effect in result.sectors:
print(effect.sector, effect.allocation, effect.selection, effect.interaction, effect.total)
A sector return may be omitted only where the matching weight is zero. A benchmark sector you did not own therefore shows zero selection and zero interaction, and the whole effect lands in allocation — you cannot demonstrate stock-picking skill in something you never held.
Example Brinson Attribution
Rendered from the call above, so every figure below is reproducible:
### Brinson Sector Attribution
| Sector | Portfolio Weight | Benchmark Weight | Portfolio Return | Benchmark Return | Allocation | Selection | Interaction |
|------|---------|---------|---------|---------|---------|---------|---------|
| Tech | 40% | 25% | 12% | 10% | +0.7575% | +0.50% | +0.30% |
| Financials | 10% | 30% | 4% | 5% | -0.0100% | -0.30% | +0.20% |
| Energy | 30% | 25% | -2% | -1% | -0.2975% | -0.25% | -0.05% |
| Health | 20% | 20% | 7% | 6% | +0.0000% | +0.20% | +0.00% |
| **Total** | 100% | 100% | 6.00% | 4.95% | **+0.45%** | **+0.15%** | **+0.45%** |
Active return 1.05% = allocation 0.45% + selection 0.15% + interaction 0.45%. No residual.
Multi-Period Attribution (Linked Brinson)
Single-period effects add, but returns compound, so simply summing each period's
effects does not reproduce the compounded active return. Take the four-sector
period above and two more like it (the exact three are the _three_periods
fixture in tests/quantlib/test_attribution.py, so you can run them): summing the
three active returns gives 2.8500%, while the compounded active return is 3.0318%
— an 18.2bp error that grows with the horizon and the return level.
Use Carino logarithmic linking, implemented as carino_link.
الأسئلة الشائعة
ما نموذج برينسون؟
هو طريقة معيارية تقسم العائد الزائد إلى تأثيرات التخصيص والاختيار والتفاعل.
هل يتطابق التقسيم دائمًا؟
نعم. التأثيرات الثلاثة تجمع إلى الفرق الكلي بالضبط، بشرط تطابق أوزان المحفظة والمؤشر.
هل تفحص توقيت السوق؟
نعم. تتضمن المهارة تقييم توقيت السوق مع مقارنات العوامل والمؤشر المرجعي.
التفاصيل
الوصف الأصلي من المؤلف
Performance attribution analysis — Brinson sector/stock-selection attribution, factor alpha/beta decomposition, market-timing evaluation, and benchmark comparison framework.
repo: HKUDS/Vibe-Trading
الشعبية
- نجوم GitHub
- 37k
- الترتيب
- #7541
- الترخيص
- MIT
- آخر تحديث
- 1/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
vibe-trading
37kيمنح وكيلك مجموعة متكاملة من أدوات البحث المالي، تغطي الاختبار الرجعي وتحليل العوامل وتسعير الخيارات وبيانات السوق عبر أسواق كثيرة.
adr-hshare
37kيعلّم وكيلك مقارنة سعر شركة صينية مدرجة في أكثر من سوق، مثل ADR الأمريكي وسهم هونغ كونغ، لقياس فجوة السعر بينهما.
akshare
37kيتيح لوكيلك سحب بيانات سوق مجانية للأسهم والعقود والعملات والمؤشرات الاقتصادية، دون الحاجة إلى مفتاح API.
alpha-zoo
37kيتيح لوكيلك تصفح مكتبة من عوامل الأسهم الجاهزة واختبار مدى قدرة مجموعة كاملة منها على التنبؤ بالعوائد في سوق تختاره.
مهارات مشابهة
gitcrawl
394kيتيح لوكيلك البحث في أرشيف محفوظ لمشكلات GitHub وطلبات السحب، وتجميع المكرر منها، والتحقق من حالتها الحالية على GitHub.
slacrawl
394kيتيح لوكيلك البحث في رسائل Slack داخل أرشيف محلي وعدّها، والتحقق من مدى حداثة الأرشيف، وتحديثه عند الحاجة.
goplaces
394kيساعد وكيلك على البحث عن الأماكن وعرض تفاصيلها وتقييماتها وتحديد أسمائها عبر Google Places، مع مخرجات JSON للسكربتات.