From 5ff5006dec82441efcff0ae8a38521ac43d5e17f Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Mon, 22 Jun 2026 18:42:11 +0200 Subject: [PATCH] feat: add purge-all for Pattern Library + clarify Trade Ideas in Data Management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend: DELETE /api/patterns/purge-all — removes all custom + backtested patterns (source != 'builtin'), leaves Pattern Lab run history intact. Frontend Config > Data Management: - New PurgeButton for Pattern Library (custom_patterns table) - Updated note: Trade Ideas are computed live from the Pattern Library (no separate table), so purging patterns resets trade idea generation on next cycle. Co-Authored-By: Claude Sonnet 4.6 --- backend/routers/patterns.py | 12 ++++++++++++ frontend/src/pages/Config.tsx | 12 ++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/backend/routers/patterns.py b/backend/routers/patterns.py index c06110f..7915cf8 100644 --- a/backend/routers/patterns.py +++ b/backend/routers/patterns.py @@ -61,6 +61,18 @@ def update_pattern(pat_id: str, req: PatternRequest): return {"id": pat_id, "status": "updated"} +@router.delete("/purge-all") +def purge_all_patterns(): + """Delete ALL custom/backtested patterns from the pattern library.""" + from services.database import get_conn + conn = get_conn() + conn.execute("DELETE FROM custom_patterns WHERE source != 'builtin'") + n = conn.total_changes + conn.commit() + conn.close() + return {"deleted": n} + + @router.delete("/custom/{pat_id}") def delete_pattern(pat_id: str): delete_custom_pattern(pat_id) diff --git a/frontend/src/pages/Config.tsx b/frontend/src/pages/Config.tsx index 9504a60..81b28e2 100644 --- a/frontend/src/pages/Config.tsx +++ b/frontend/src/pages/Config.tsx @@ -1629,15 +1629,23 @@ function DataManagementCard() { + +

- Note: Custom patterns, risk profiles, config, API keys, and the Knowledge Base are managed from their respective sections and are not affected by the purges above. + Note: Trade Ideas are computed live from the Pattern Library — they have no separate table. Risk profiles, config, API keys, and the Knowledge Base are managed from their respective sections.