Nancy Pelosi Stock Trading Bot

Research agent reads Pelosi's yearly report and trade reports, portfolio agent sets your target mix, trading agent rebalances when a new report appears

This bot owns the same stocks Nancy Pelosi owns, in the same mix, sized to your account. It reads her own reports on the U.S. House website, so it copies her whole stock portfolio, not just her latest trade. Why copy her? Her reported portfolio was up an estimated 70.9% in 2024, while the S&P 500 rose 24.9%, according to the Unusual Whales report covered by Fortune.

Want her call options too? The Nancy Pelosi Copy Trading Bot copies those as well.

How it works

  1. Research agent goes to the House Clerk website and opens the yearly list of filings. It finds Pelosi’s newest yearly report, which lists every stock she owned on December 31, and every trade report filed since.

  2. The research agent reads those reports and works out what she owns today: the yearly report, plus every stock she bought or sold after it. It only uses reports filed before today.

  3. Portfolio agent turns her holdings into your target mix. A stock she holds $5 million to $25 million of gets a bigger share of your account than one she holds $1 million to $5 million of.

  4. Trading agent buys and sells to match that mix, and checks that every order filled.

  5. The bot checks once a day, but it only trades when she files a new report. On other days the research agent answers “nothing new” and the bot does nothing, so it does not trade every day.

Want a different member of Congress? Change last_name from "Pelosi" to any House member’s last name.

Run it on BotSpot

Run this bot on BotSpot without installing anything. BotSpot runs LumiBot in the cloud, backtests it, and connects it to your broker.

The code

The whole bot is one short file. The three prompts are the strategy. The research agent uses LumiBot’s built-in web tools, which read ZIP files, PDFs, spreadsheets and web pages from any website.

"""Nancy Pelosi Stock Trading Bot.

Holds the same stocks Nancy Pelosi owns, in the same proportions. A research
agent reads her reports on the House Clerk website: the yearly report of
everything she owns, plus every newer trade report. A portfolio agent turns that
into target weights, and a trading agent rebalances only when a new report
appears. Change "last_name" to copy any other member of the House.
"""

from lumibot.strategies import Strategy

HOUSE = "https://disclosures-clerk.house.gov/public_disc"


class NancyPelosiTradingBot(Strategy):
    parameters = {"last_name": "Pelosi"}

    def initialize(self):
        self.sleeptime = "1D"
        self.agents.create(
            name="researcher",
            allow_trading=False,
            allow_network=True,
            system_prompt=(
                "You find out which stocks a member of Congress owns today, from the House Clerk website. Each "
                f"year's list of filings is a ZIP file such as {HOUSE}/financial-pdfs/2026FD.ZIP (change 2026 to the "
                "year). Each row is one filing with its filing date. FilingType O is a yearly report of everything "
                "the member owned on December 31 of that Year; P is a trade report. Yearly reports are at "
                f"{HOUSE}/financial-pdfs/YEAR/DOCID.pdf and trade reports at {HOUSE}/ptr-pdfs/YEAR/DOCID.pdf. Every "
                "day, first check the lists for this year and the two years before, using only filings dated before "
                "today. Start your answer with \"Newest filing:\" and the date and DocID of the member's own newest "
                "filing, yearly or trade report (other people's filings do not count). If your notes start with "
                "that same newest filing, reply only NOTHING NEW. Otherwise start from the newest yearly report and "
                "apply every trade dated after the December 31 it covers; ignore earlier trades, because the yearly "
                "report already includes them. Shares bought, including shares from exercised call options, add to "
                "a stock. A sale removes a stock only when the report says all shares or the entire position were "
                "sold; \"Sold 10,000 shares\" alone is a partial sale, so keep the stock. Partnership units with a "
                "ticker, such as AB, count as stocks. Skip options, real estate, private companies, funds, and "
                "bonds. List every stock the member still owns with a dollar range: the yearly report's range, or "
                "the trade amount for a stock bought since. Do not trade."
            ),
        )
        self.agents.create(
            name="portfolio",
            allow_trading=False,
            system_prompt=(
                "You turn a member's holdings into target weights for our account. Use the middle of each dollar "
                "range as the value of that stock. Each stock's weight is its value divided by the total value of "
                "all the stocks. Do the math with a calculator, not in your head. Return one line per ticker with "
                "its target percent of the account. Do not trade."
            ),
        )
        self.agents.create(
            name="trader",
            allow_trading=True,
            system_prompt=(
                "You move the account to the target percents in the plan. Sell every stock that is not in the plan "
                "and buy every stock in the plan you do not own yet. Only change a stock you already own when it is "
                "more than 2 percentage points away from its target, so the account does not trade every day. Sell "
                "before you buy, never short, and never spend more cash than you have. Check that every order "
                "filled."
            ),
        )

    def on_trading_iteration(self):
        facts = {"last_name": self.parameters["last_name"]}
        research = self.agents["researcher"].run(task_prompt="What does the member own today?", context=facts)
        answer = research.summary or ""
        # Rebalance only when her newest filing changes, never on a re-read of the same filings.
        newest = "".join(ch for ch in answer.split("DocID", 1)[-1][:20] if ch.isdigit()) if "DocID" in answer else ""
        if (newest and newest == self.vars.get("newest_filing")) or (not newest and "NOTHING NEW" in answer):
            return
        plan = self.agents["portfolio"].run(
            task_prompt="Set the target weights.", context={"holdings": research.summary}
        )
        self.agents["trader"].run(task_prompt="Rebalance to the plan.", context={"plan": plan.summary})
        if newest:
            self.vars.set("newest_filing", newest)


if __name__ == "__main__":
    from lumibot.credentials import IS_BACKTESTING

    if IS_BACKTESTING:
        from lumibot.backtesting import YahooDataBacktesting

        NancyPelosiTradingBot.backtest(YahooDataBacktesting)
    else:
        NancyPelosiTradingBot().run_live()

Run it yourself

pip install lumibot
python -m lumibot.example_strategies.ai_nancy_pelosi_trading_bot

Put these in your .env file: OPENAI_API_KEY, and your broker keys (for example ALPACA_API_KEY, ALPACA_API_SECRET, and ALPACA_IS_PAPER=true for paper trading). With IS_BACKTESTING=false the bot trades. With IS_BACKTESTING=true it backtests instead; set BACKTESTING_START and BACKTESTING_END to pick the dates, and start with a week or two, because every AI call costs a little.

Good to know

  • Members of Congress can take up to 45 days to report a trade, so the bot always sees trades late.

  • Reports show dollar ranges, such as $1,000,001 to $5,000,000. The bot uses the middle of each range.

  • The yearly report comes out in May and shows what she owned on December 31. Until the new one is filed, the bot starts from the year before and adds every trade since.

  • In a backtest the website also shows reports from after the test date. The research agent reads the date on each report and skips any report filed after the test day.

  • Pelosi said on November 6, 2025 that she will not run for re-election in 2026 (NBC News). Her reports stop after she leaves office, so change last_name to keep the bot trading.

  • The House website says its reports may not be used for most commercial purposes (5 U.S.C. 13107). Check that your use is allowed.

See AI Trading Bot Examples for more AI trading bots and Backtest, paper, or live: choose the runner for backtest and live runs.