Merge remote-tracking branch 'origin/qyqy_develop' into qyqy_develop

This commit is contained in:
2026-09-12 14:18:06 +08:00
7 changed files with 490 additions and 62 deletions
+3 -2
View File
@@ -103,9 +103,10 @@ class StubGovernance:
return ()
async def review(
self, result: Any, context: RequestContext, config: Any, memories: Any
self, result: Any, context: RequestContext, config: Any, memories: Any,
*, agent_type: str = "",
) -> Any:
del context, config, memories
del context, config, memories, agent_type
return result
+20 -7
View File
@@ -37,6 +37,10 @@ def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Sync advisory listed-fund market data")
parser.add_argument("--days", type=int, default=400, help="Calendar days to refresh")
parser.add_argument("--limit", type=int, default=100, help="Maximum products")
parser.add_argument(
"--product-code", action="append", dest="product_codes",
help="Refresh one product code; can be repeated",
)
parser.add_argument("--as-of-date", type=date.fromisoformat, default=date.today())
return parser.parse_args()
@@ -48,15 +52,20 @@ def expected_trading_days(start: date, end: date) -> int:
)
async def rebuild_snapshots(*, start: date, end: date, limit: int) -> tuple[int, int]:
async def rebuild_snapshots(
*, start: date, end: date, limit: int, product_codes: tuple[str, ...] | None = None
) -> tuple[int, int]:
now = datetime.now(UTC).replace(tzinfo=None)
expected = expected_trading_days(start, end)
statement = select(FundProduct).where(
FundProduct.fund_manager == "南方基金",
FundProduct.status == "上市",
)
if product_codes is not None:
statement = statement.where(FundProduct.product_code.in_(product_codes))
async with SessionFactory() as session:
products = list(await session.scalars(
select(FundProduct).where(
FundProduct.fund_manager == "南方基金",
FundProduct.status == "上市",
).order_by(FundProduct.id).limit(limit)
statement.order_by(FundProduct.id).limit(limit)
))
metric_rows: list[dict[str, object]] = []
@@ -157,13 +166,17 @@ async def run(args: argparse.Namespace) -> None:
end = args.as_of_date
start = end - timedelta(days=max(1, args.days))
result = await ProductHistorySyncService().sync(
days=args.days, limit=args.limit, as_of_date=end
days=args.days, limit=args.limit, as_of_date=end,
product_codes=tuple(args.product_codes) if args.product_codes else None,
)
metric_count, accepted_count = await rebuild_snapshots(
start=start, end=end, limit=args.limit
start=start, end=end, limit=args.limit,
product_codes=tuple(args.product_codes) if args.product_codes else None,
)
print(
f"history products={result.product_count} observations={result.observation_count}; "
f"turnover_observations={result.turnover_observation_count} "
f"failed_products={result.failed_product_count}; "
f"metrics={metric_count} quality_accepted={accepted_count}"
)