Files
group_fqcd_jr/tools/sync_product_history.py
T

41 lines
1.2 KiB
Python

"""Backfill or refresh additive advisory fund NAV history."""
from __future__ import annotations
import argparse
import asyncio
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Synchronize advisory fund NAV history")
parser.add_argument("--days", type=int, default=400, help="Calendar days to request, default: 400")
parser.add_argument("--limit", type=int, default=100, help="Maximum listed products, default: 100")
parser.add_argument(
"--codes", default="", help="Comma-separated product codes for a resumable batch"
)
return parser.parse_args()
async def main() -> None:
from app.service.product_history_sync_service import ProductHistorySyncService
args = parse_args()
codes = tuple(code.strip() for code in args.codes.split(",") if code.strip()) or None
result = await ProductHistorySyncService().sync(
days=args.days, limit=args.limit, product_codes=codes
)
print(
f"history sync complete: products={result.product_count}, "
f"observations_upserted={result.observation_count}"
)
if __name__ == "__main__":
asyncio.run(main())