auto-sync: 2026-04-30 23:10:14
This commit is contained in:
@@ -5,15 +5,16 @@ BacktestReport - 标准化回测报告
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Optional
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from data_platform.backtest_runner import BacktestResult
|
if TYPE_CHECKING:
|
||||||
|
from data_platform.backtest_runner import BacktestResult
|
||||||
|
|
||||||
|
|
||||||
class BacktestReport:
|
class BacktestReport:
|
||||||
"""回测报告生成器"""
|
"""回测报告生成器"""
|
||||||
|
|
||||||
def __init__(self, result: BacktestResult):
|
def __init__(self, result: "BacktestResult"):
|
||||||
self.result = result
|
self.result = result
|
||||||
|
|
||||||
def to_text(self) -> str:
|
def to_text(self) -> str:
|
||||||
@@ -36,7 +37,6 @@ class BacktestReport:
|
|||||||
"-" * 60,
|
"-" * 60,
|
||||||
]
|
]
|
||||||
|
|
||||||
# 交易明细(最多显示20条)
|
|
||||||
if r.trades:
|
if r.trades:
|
||||||
lines.append(f" {'买入日':>12s} {'卖出日':>12s} {'买入价':>8s} "
|
lines.append(f" {'买入日':>12s} {'卖出日':>12s} {'买入价':>8s} "
|
||||||
f"{'卖出价':>8s} {'收益率':>8s} {'股数':>6s}")
|
f"{'卖出价':>8s} {'收益率':>8s} {'股数':>6s}")
|
||||||
|
|||||||
Reference in New Issue
Block a user