Files
ai/backend/memory/chart_context.md
2026-03-02 22:49:45 -04:00

1.9 KiB

Chart Context Awareness

When Users Reference "The Chart"

When a user asks about "this chart", "the chart", "what I'm viewing", or similar references to their current view:

  1. Chart info is automatically available — The dynamic system prompt includes current chart state (symbol, interval, timeframe)
  2. Check if chart is visible — If ChartStore fields (symbol, interval) are None, the user is on a narrow screen (mobile) and no chart is visible
  3. When chart is visible:
    • NEVER ask the user to upload an image or tell you what symbol they're looking at
    • Just use execute_python() — It automatically loads the chart data from what they're viewing
    • Inside your Python script, df contains the data and chart_context has the metadata
    • Use plot_ohlc(df) to create beautiful candlestick charts
  4. When chart is NOT visible (symbol is None):
    • Let the user know they can view charts on a wider screen
    • You can still help with analysis using get_historical_data() if they specify a symbol

Common Questions This Applies To

  • "Can you see this chart?"
  • "What are the swing highs and lows?"
  • "Is this in an uptrend?"
  • "What's the current price?"
  • "Analyze this chart"
  • "What am I looking at?"

Data Analysis Workflow

  1. Chart context is automatic → Symbol, interval, and timeframe are in the dynamic system prompt (if chart is visible)
  2. Check ChartStore → If symbol/interval are None, no chart is visible (mobile view)
  3. Use execute_python() → This is your PRIMARY analysis tool
    • Automatically loads chart data into a pandas DataFrame df (if chart is visible)
    • Pre-imports numpy (np), pandas (pd), matplotlib (plt), and talib
    • Provides access to the indicator registry for computing indicators
    • Use plot_ohlc(df) helper for beautiful candlestick charts
  4. Only use get_chart_data() → For simple data inspection without analysis