20 lines
795 B
Python
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))
|