Diamonds in the Rough AI Turnaround Bot ======================================= .. meta:: :description: Open-ended Python AI stock turnaround bot that scans the entire US market with zero hardcoded tickers and builds a 5 to 10 stock portfolio capped at 20% each. .. image:: ../docs/assets/ai-agent-workflows/diamonds-in-the-rough-ai-turnaround-bot.png :alt: Research agent scans the US stock market for turnaround catalysts and hands approved picks to the trading agent :width: 100% Most stock screeners lock you into a fixed watchlist of twenty tickers. This open-ended AI turnaround bot searches across the entire US equity market with zero hardcoded symbols, looking for beaten-down public companies that have a real catalyst and early rebound momentum, then builds a diversified five to ten stock portfolio capped at twenty percent per holding. How it works ------------ The strategy pairs a dedicated research agent with a dedicated trading agent on a daily schedule: 1. **Research agent** scans across the broad US stock market for companies that have dropped sharply from their 52-week highs and are beginning to recover. It checks recent SEC filings, income statements, balance sheets, earnings news, and insider or institutional activity to separate real turnaround stories from distressed companies, returning five to ten diversified picks across sectors with no stock above a 20% target weight plus clear exit triggers. 2. **Trading agent** builds and rebalances the portfolio inside available cash, deploying roughly 95% of equity across the approved turnaround picks (capped at 20% per ticker, leaving about a 5% cash buffer). It sells holdings whose thesis fails or whose exit trigger hits before buying replacements, skips tiny trades within 2 percentage points of target weight, and never shorts. Want a more concentrated basket or a different holding cap? Adjust ``max_positions`` in ``parameters`` or edit the prompt directly. Run it on BotSpot ----------------- Browse ready-to-run AI strategies or deploy this bot in the cloud on `BotSpot Marketplace `_. BotSpot runs LumiBot in the cloud, manages historical backtests, and connects directly to your broker. Prefer to customize this strategy inside Claude, ChatGPT, Codex, or Cursor? Connect the free :doc:`BotSpot MCP ` to edit code, run cloud backtests, and inspect charts from your AI assistant. Want guided step-by-step training on building AI trading systems? Explore `BotSpot Courses `_ or join the `free AI Trading Challenge `_. The code -------- The complete strategy lives in one short Python file with zero hardcoded ticker lists. The plain-English prompts define the research criteria and portfolio limits. .. literalinclude:: ../lumibot/example_strategies/ai_diamonds_in_the_rough.py :language: python Run it yourself --------------- .. code-block:: bash pip install lumibot python -m lumibot.example_strategies.ai_diamonds_in_the_rough Add ``OPENAI_API_KEY`` and your broker credentials (for example ``ALPACA_API_KEY``, ``ALPACA_API_SECRET``, and ``ALPACA_IS_PAPER=true`` for paper trading) to your ``.env`` file. For ChatGPT subscription funding locally, see :doc:`agents_chatgpt` and set ``model`` to ``chatgpt/gpt-6-luna``. With ``IS_BACKTESTING=true``, the file runs a historical backtest on Yahoo Finance daily data using ``BACKTESTING_START`` and ``BACKTESTING_END``. With ``IS_BACKTESTING=false``, the exact same strategy class trades with your configured broker. Good to know ------------ * Open-ended market discovery lets the researcher find fresh turnaround candidates outside any preset list, but you should start with a short backtest window (one to two weeks) first to inspect decisions and measure model token costs. * Turnaround stocks can stay volatile or fall further after an initial bounce; the 20% single-stock cap and five to ten stock diversification rule limit single-company exposure. * In backtests, LumiBot clamps built-in market data and SEC filings to the simulated date, and the research agent is instructed to use only information available by that day. * Historical backtests verify strategy mechanics and accounting; they are not a guarantee of future returns. See :doc:`agents_examples` for more AI trading bots and :doc:`strategy_run_modes` for backtest and live runners.