Copying Congressional Stock and Call Option Disclosures
Summary
This bot outlines a disclosure-driven copy-trading process based on a member of Congress’s reported stock and call-option holdings. A research agent reads annual and transaction reports, reconstructs current holdings, and ignores filings dated after the current day. A portfolio agent allocates a configurable share of the account to calls and the remainder to stocks, using reported value ranges to set relative weights. A trading agent rebalances when a new filing appears, with a tolerance around existing targets.
The workflow specifies handling partial sales, exercised calls, expired options, and contract selection, as well as order constraints such as selling before buying and checking fills. It is code and agent instructions rather than a performance study; no backtest results or evidence of return quality are given. Reported holdings may be delayed, imprecise, or incomplete, and the rules for translating value ranges into option contracts may not reproduce the original investor’s exposures. The strategy’s outcomes also depend on data extraction accuracy, option liquidity, and execution.
Key ideas
- The bot reconstructs holdings from annual disclosures and subsequent trade reports.
- It allocates account capital between stocks and calls using reported value ranges.
- It waits for a changed newest filing before generating a rebalance plan.
- The trading instructions include position tolerances and constraints on order handling.
- The document describes a workflow but provides no performance results, and disclosure lag can affect copied positions.
Tags
Full text
# ai_nancy_pelosi_copy_trading_bot.py
```py
"""Nancy Pelosi Copy Trading Bot.
Copies Nancy Pelosi's stocks and her call options (same stock, same expiration),
sized to your account. Every day a research agent works out what she owns today
from her public financial disclosure reports, and a trading agent makes the
account match. "options_share" sets the share of the account in calls.
"""
from lumibot.strategies import Strategy
class NancyPelosiCopyTradingBot(Strategy):
parameters = {"options_share": 0.2}
def initialize(self):
self.sleeptime = "1D"
self.agents.create(
name="researcher",
allow_trading=False,
allow_network=True,
system_prompt=(
"Find out which stocks and call options Nancy Pelosi owns today and how much of each. Use her "
"official financial disclosure reports on the U.S. House Clerk website "
"(https://disclosures-clerk.house.gov): her newest yearly report of everything she owns, plus every "
"trade report filed after it. Use only reports filed before today. If your last answer is given, "
"start from it and only read reports filed since then. Skip expired options, funds, bonds, real "
"estate and private companies. Give each stock's ticker and dollar range, and each call "
"option's stock, strike price, expiration date, number of contracts and dollar range. Do not trade."
),
)
self.agents.create(
name="trader",
allow_trading=True,
system_prompt=(
"Make the account copy the research. Put options_share of the account into her call options and the "
"rest into her stocks, each in proportion to the middle of its dollar range. Use the same stock and "
"expiration as each of her calls, her strike if one contract fits that call's money, otherwise the "
"nearest higher strike that fits. Sell holdings that are not in the research and buy the ones you do "
"not own. Leave a holding alone when it is within 2 percentage points of its target. Sell before you "
"buy, never short, and never spend more cash than you have."
),
)
def on_trading_iteration(self):
# The researcher gets its last answer back, so it only needs to read reports filed since then.
research = self.agents["researcher"].run(
task_prompt="What does Nancy Pelosi own today?",
context={"your_last_answer": self.vars.get("last_research", "none yet")},
)
self.vars.set("last_research", research.summary)
self.agents["trader"].run(
task_prompt="Match the account to the research.",
context={"research": research.summary, "options_share": self.parameters["options_share"]},
)
if __name__ == "__main__":
from lumibot.credentials import IS_BACKTESTING
if IS_BACKTESTING:
from lumibot.backtesting import AlpacaBacktesting
NancyPelosiCopyTradingBot.backtest(AlpacaBacktesting)
else:
NancyPelosiCopyTradingBot().run_live()
```Shown in full with attribution under the source's licence. Licence: GPL-3.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.