fix: generate_report now uses actual position_weights from daily_records
Previously hardcoded equal weight (1/select_num), ignoring config weight type. Now reads position_weights from last daily_record, correctly showing rank-based weights.
This commit is contained in:
@@ -1203,7 +1203,7 @@ class SimpleRotationStrategy:
|
||||
|
||||
# Build positions info for table
|
||||
# Sort holdings by momentum score descending
|
||||
weight = 1.0 / self.select_num if self.select_num > 0 else 1.0
|
||||
position_weights = last_rec.get('position_weights', {})
|
||||
sorted_holdings = sorted(holdings, key=lambda c: factors.get(c, 0) or 0, reverse=True)
|
||||
|
||||
# Determine previous holdings to distinguish "调入" vs "维持"
|
||||
@@ -1249,7 +1249,7 @@ class SimpleRotationStrategy:
|
||||
|
||||
positions_info.append({
|
||||
'name': name, 'code': code, 'etf': etf_code,
|
||||
'weight': weight, 'score': score,
|
||||
'weight': position_weights.get(code, 1.0 / len(holdings)), 'score': score,
|
||||
'idx_close': idx_close, 'etf_close': etf_close,
|
||||
'premium': premium, 'action': action,
|
||||
'entry_date': entry_date, 'entry_price': entry_price,
|
||||
@@ -1276,7 +1276,7 @@ class SimpleRotationStrategy:
|
||||
premium = self._get_latest_premium(trade_code, last_date)
|
||||
exit_positions.append({
|
||||
'name': name, 'code': code, 'etf': etf_code,
|
||||
'weight': weight, 'score': None,
|
||||
'weight': 0, 'score': None,
|
||||
'idx_close': idx_close, 'etf_close': etf_close,
|
||||
'premium': premium, 'action': '调出',
|
||||
'entry_date': None, 'entry_price': None,
|
||||
|
||||
Reference in New Issue
Block a user