Skip to content

Commit b0c5770

Browse files
committed
[Localization] Update WalkForwardResult output to include Chinese translations
1 parent 30c3f2b commit b0c5770

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

src/quanteval/optimization/walk_forward.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ def summary(self) -> str:
6767
"""Return a formatted summary of walk-forward results."""
6868
lines = [
6969
'=' * 70,
70-
' Walk-Forward Analysis Results',
70+
' 滚动前瞻分析结果(Walk-Forward Analysis',
7171
'=' * 70,
7272
'',
73-
f'Strategy: {self.strategy_class.__name__}',
74-
f'Optimization Metric: {self.metric_name}',
75-
f'Number of Windows: {len(self.windows)}',
73+
f'策略名称(Strategy: {self.strategy_class.__name__}',
74+
f'优化指标(Optimization Metric: {self.metric_name}',
75+
f'窗口数量(Number of Windows: {len(self.windows)}',
7676
'',
77-
'📊 Per-Window Performance:',
77+
'📊 各窗口表现(Per-Window Performance:',
7878
'',
7979
]
8080

8181
# Table header
8282
lines.append(
83-
f'{"Window":<8} {"Train Period":<24} {"Test Period":<24} {"Train":<10} {"Test":<10} {"Gap":<10}'
83+
f'{"窗口(Window":<8} {"训练区间(Train Period":<24} {"测试区间(Test Period":<24} {"训练得分(Train":<12} {"测试得分(Test":<12} {"回撤(Gap":<10}'
8484
)
8585
lines.append('-' * 86)
8686

@@ -102,12 +102,10 @@ def summary(self) -> str:
102102
lines.extend(
103103
[
104104
'-' * 86,
105-
f'{"Mean":<8} {"":<24} {"":<24} '
106-
f'{float(np.mean(train_scores)):>9.3f} {float(np.mean(test_scores)):>9.3f} {float(np.mean(gaps)):>9.3f}',
107-
f'{"Std":<8} {"":<24} {"":<24} '
108-
f'{float(np.std(train_scores)):>9.3f} {float(np.std(test_scores)):>9.3f} {float(np.std(gaps)):>9.3f}',
105+
f'{"平均值(Mean)":<8} {"":<24} {"":<24} {float(np.mean(train_scores)):>9.3f} {float(np.mean(test_scores)):>9.3f} {float(np.mean(gaps)):>9.3f}',
106+
f'{"标准差(Std)":<8} {"":<24} {"":<24} {float(np.std(train_scores)):>9.3f} {float(np.std(test_scores)):>9.3f} {float(np.std(gaps)):>9.3f}',
109107
'',
110-
'🎯 Combined Out-of-Sample Performance:',
108+
'🎯 样本外综合表现(Combined Out-of-Sample Performance:',
111109
'',
112110
]
113111
)
@@ -116,11 +114,11 @@ def summary(self) -> str:
116114
metrics = self.combined_results.summary()
117115
lines.extend(
118116
[
119-
f' Total Return: {_series_metric(metrics, "total_return", 0.0) * 100:>8.2f}%',
120-
f' Annual Return: {_series_metric(metrics, "annual_return", 0.0) * 100:>8.2f}%',
121-
f' Sharpe Ratio: {_series_metric(metrics, "sharpe_ratio", 0.0):>8.3f}',
122-
f' Max Drawdown: {_series_metric(metrics, "max_drawdown", 0.0) * 100:>8.2f}%',
123-
f' Win Rate: {_series_metric(metrics, "win_rate") * 100:>8.2f}%',
117+
f' 总收益(Total Return): {_series_metric(metrics, "total_return", 0.0) * 100:>8.2f}%',
118+
f' 年化收益(Annual Return): {_series_metric(metrics, "annual_return", 0.0) * 100:>8.2f}%',
119+
f' 夏普比率(Sharpe Ratio): {_series_metric(metrics, "sharpe_ratio", 0.0):>8.3f}',
120+
f' 最大回撤(Max Drawdown): {_series_metric(metrics, "max_drawdown", 0.0) * 100:>8.2f}%',
121+
f' 胜率(Win Rate): {_series_metric(metrics, "win_rate") * 100:>8.2f}%',
124122
'',
125123
]
126124
)

0 commit comments

Comments
 (0)