بنقرة واحدة
investment-autoresearch-strategy-chart
// Use when creating matplotlib/strategy charts. Use when user asks to "draw", "chart", "plot", or "visualize" a strategy, backtest result, or price series.
// Use when creating matplotlib/strategy charts. Use when user asks to "draw", "chart", "plot", or "visualize" a strategy, backtest result, or price series.
| name | investment-autoresearch:strategy-chart |
| description | Use when creating matplotlib/strategy charts. Use when user asks to "draw", "chart", "plot", or "visualize" a strategy, backtest result, or price series. |
Generate matplotlib charts for backtesting strategy results. Chart is saved to /tmp/chart.png.
import matplotlib
matplotlib.use("Agg") # Non-interactive backend — required for headless environments
import matplotlib.pyplot as plt
# ... create figure ...
plt.savefig("/tmp/chart.png", dpi=150, bbox_inches="tight",
facecolor=fig.get_facecolor(), edgecolor="none")
plt.close()
colors = {
"bg": "#1a1a2e", "panel": "#16213e", "text": "#e0e0e0",
"grid": "#2a2a4a", "equity": "#00d4aa", "price": "#6c7b95",
"buy": "#00ff88", "sell": "#ff4466", "drawdown": "#ff6b6b",
"vix": "#ffa726",
}
fig.patch.set_facecolor(colors["bg"])
for ax in axes:
ax.set_facecolor(colors["panel"])
ax.tick_params(colors=colors["text"])
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
3-panel layout for backtesting charts:
Panel 1 (3x height): Price + Equity curve + Buy/Sell markers + Stats box
Panel 2 (1.5x): Drawdown fill
Panel 3 (1x): VIX or volatility indicator with threshold lines
fig, axes = plt.subplots(3, 1, figsize=(16, 12),
gridspec_kw={"height_ratios": [3, 1.5, 1]})
The chart is saved to /tmp/chart.png. Copy it wherever needed:
cp /tmp/chart.png ~/charts/$(date +%Y-%m-%d)-strategy.png
| Mistake | Fix |
|---|---|
Forgetting matplotlib.use("Agg") | Required for non-interactive (headless) chart generation |
| Not closing figure | Always plt.close() after savefig to free memory |
Use when optimizing a strategy, model, or system through parallel experimentation — when the search space is large, multiple hypotheses exist, and there is an automated scoring function to evaluate variants.
Use when converting autoresearch markdown results (verified_insights.md and AGENT_R*_RESULTS.md) into structured JSON for reporting or slides generation.
Use when generating a structured markdown report from an autoresearch_result.json file for a given ticker. Triggered when user asks for a report, summary, or writeup of autoresearch results.