Spaces:
Running
Running
AJAY KASU commited on
Commit ·
492cce0
1
Parent(s): 816b15c
Fix: Correct Tracking Error variable in AI prompt generation to eliminate hallucination
Browse files- ai/ai_reporter.py +3 -2
- main.py +5 -1
ai/ai_reporter.py
CHANGED
|
@@ -112,7 +112,8 @@ class AIReporter:
|
|
| 112 |
|
| 113 |
def generate_report(self,
|
| 114 |
attribution_report: AttributionReport,
|
| 115 |
-
excluded_sector: str
|
|
|
|
| 116 |
"""
|
| 117 |
Constructs the prompt and calls the Bytez API to generate the commentary.
|
| 118 |
"""
|
|
@@ -130,7 +131,7 @@ Current Date: {current_date}
|
|
| 130 |
Portfolio Metadata:
|
| 131 |
- Sector Exclusions: {excluded_sector}
|
| 132 |
- Alpha (Active Return): {attribution_report.total_active_return * 100:.2f}%
|
| 133 |
-
- Total Tracking Error: {
|
| 134 |
- Full Replication Mode: {is_replication}
|
| 135 |
|
| 136 |
## DATA TABLES:
|
|
|
|
| 112 |
|
| 113 |
def generate_report(self,
|
| 114 |
attribution_report: AttributionReport,
|
| 115 |
+
excluded_sector: str,
|
| 116 |
+
tracking_error: float = 0.0) -> str:
|
| 117 |
"""
|
| 118 |
Constructs the prompt and calls the Bytez API to generate the commentary.
|
| 119 |
"""
|
|
|
|
| 131 |
Portfolio Metadata:
|
| 132 |
- Sector Exclusions: {excluded_sector}
|
| 133 |
- Alpha (Active Return): {attribution_report.total_active_return * 100:.2f}%
|
| 134 |
+
- Total Tracking Error: {tracking_error * 100:.4f}%
|
| 135 |
- Full Replication Mode: {is_replication}
|
| 136 |
|
| 137 |
## DATA TABLES:
|
main.py
CHANGED
|
@@ -166,7 +166,11 @@ class QuantScaleSystem:
|
|
| 166 |
exclusions_list = request.excluded_sectors + request.excluded_tickers
|
| 167 |
excluded = ", ".join(exclusions_list) if exclusions_list else "None"
|
| 168 |
|
| 169 |
-
commentary = self.ai_reporter.generate_report(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
return {
|
| 172 |
"optimization": opt_result,
|
|
|
|
| 166 |
exclusions_list = request.excluded_sectors + request.excluded_tickers
|
| 167 |
excluded = ", ".join(exclusions_list) if exclusions_list else "None"
|
| 168 |
|
| 169 |
+
commentary = self.ai_reporter.generate_report(
|
| 170 |
+
attribution_report=attribution,
|
| 171 |
+
excluded_sector=excluded,
|
| 172 |
+
tracking_error=opt_result.tracking_error
|
| 173 |
+
)
|
| 174 |
|
| 175 |
return {
|
| 176 |
"optimization": opt_result,
|