feat: add purge-all for Pattern Library + clarify Trade Ideas in Data Management
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1629,15 +1629,23 @@ function DataManagementCard() {
|
||||
|
||||
<PurgeButton
|
||||
label="Pattern Lab Runs"
|
||||
description="Delete all Pattern Lab backtest runs (event presets + instrument scans)."
|
||||
description="Delete all Pattern Lab backtest runs (event presets + instrument scans). Does not affect the Pattern Library."
|
||||
tables={['backtest_lab_runs']}
|
||||
endpoint="/api/pattern-lab/purge-all"
|
||||
color="orange"
|
||||
/>
|
||||
|
||||
<PurgeButton
|
||||
label="Pattern Library"
|
||||
description="Delete all custom and backtested patterns from the library. Trade ideas will regenerate from scratch on the next cycle. Does not affect Pattern Lab run history."
|
||||
tables={['custom_patterns']}
|
||||
endpoint="/api/patterns/purge-all"
|
||||
color="red"
|
||||
/>
|
||||
|
||||
<div className="mt-2 p-3 border border-slate-700/40 rounded-lg bg-dark-700/30">
|
||||
<p className="text-xs text-slate-500">
|
||||
<span className="font-semibold text-slate-400">Note:</span> 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.
|
||||
<span className="font-semibold text-slate-400">Note:</span> 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.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user