Artifex/control_plane/trading_studio/management/commands/tradingstudio_report.py
2026-08-17 13:48:50 +07:00

20 lines
795 B
Python

import json
from django.core.management.base import BaseCommand, CommandError
from control_plane.trading_studio.models import TradingProject
from control_plane.trading_studio.services import TradingStudioService
class Command(BaseCommand):
help = "Create a canonical Trading Studio cohort report."
def add_arguments(self, parser):
parser.add_argument("--project", required=True)
def handle(self, *args, **options):
project = TradingProject.objects.filter(slug=options["project"]).first()
if project is None:
raise CommandError("TradingProject not found.")
report = TradingStudioService().report(project)
self.stdout.write(json.dumps({"report": str(report.id), "title": report.title, "content": report.content}, default=str))