This skill should be used when the user asks to "query WRDS", "access Compustat", "get CRSP data", "pull Form 4 insider data", "query ISS compensation", "download SEC EDGAR filings", "get ExecuComp data", "access Capital IQ", or needs WRDS PostgreSQL query patterns.
/plugin marketplace add edwinhu/workflows/plugin install workflows@edwinhu-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
examples/form4_disposals.pyexamples/wrds_connector.pyreferences/compustat.mdreferences/connection.mdreferences/crsp.mdreferences/edgar.mdreferences/insider-form4.mdreferences/iss-compensation.mdscripts/test_connection.pyWRDS (Wharton Research Data Services) provides academic research data via PostgreSQL at wrds-pgdata.wharton.upenn.edu:9737.
Before executing ANY WRDS query, you MUST:
This is not negotiable. Claiming query success without sample inspection is LYING to the user about data quality.
| Excuse | Reality | Do Instead |
|---|---|---|
| "I'll add filters later" | You'll forget and pull bad data | Add filters NOW, before execution |
| "User didn't specify filters" | Standard filters are ALWAYS required | Apply Critical Filters section defaults |
| "Just a quick test query" | Test queries with bad filters teach bad patterns | Use production filters even for tests |
| "I'll let the user filter in pandas" | Pulling millions of unnecessary rows wastes time/memory | Filter at database level FIRST |
| "The query worked, so it's correct" | Query success ≠ data quality | INSPECT sample for invalid records |
| "I can use f-strings for simple queries" | SQL injection risk + wrong type handling | ALWAYS use parameterized queries |
Before EVERY query execution:
For Compustat queries (comp.funda, comp.fundq):
indfmt = 'INDL'datafmt = 'STD'popsrc = 'D'consol = 'C'For CRSP v2 queries (crsp.dsf_v2, crsp.msf_v2):
sharetype == 'NS'securitytype == 'EQTY'securitysubtype == 'COM'usincflg == 'Y'issuertype.isin(['ACOR', 'CORP'])For Form 4 queries (tr_insiders.table1):
For ALL queries:
.head() or .sample() BEFORE claiming success| Dataset | Schema | Key Tables |
|---|---|---|
| Compustat | comp | company, funda, fundq, secd |
| ExecuComp | comp_execucomp | anncomp |
| CRSP | crsp | dsf, msf, stocknames, ccmxpf_linkhist |
| CRSP v2 | crsp | dsf_v2, msf_v2, stocknames_v2 |
| Form 4 Insiders | tr_insiders | table1, header, company |
| ISS Incentive Lab | iss_incentive_lab | comppeer, sumcomp, participantfy |
| Capital IQ | ciq | wrds_compensation |
| IBES | tr_ibes | det_epsus, statsum_epsus |
| SEC EDGAR | wrdssec | wrds_forms, wciklink_cusip |
| SEC Search | wrds_sec_search | filing_view, registrant |
| EDGAR | edgar | filings, filing_docs |
| Fama-French | ff | factors_monthly, factors_daily |
| LSEG/Datastream | tr_ds | ds2constmth, ds2indexlist |
import psycopg2
conn = psycopg2.connect(
host='wrds-pgdata.wharton.upenn.edu',
port=9737,
database='wrds',
sslmode='require'
# Credentials from ~/.pgpass
)
Auth: ~/.pgpass with chmod 600:
wrds-pgdata.wharton.upenn.edu:9737:wrds:USERNAME:PASSWORD
SSH: ssh wrds (uses ~/.ssh/wrds_rsa)
Always include for clean fundamental data:
WHERE indfmt = 'INDL'
AND datafmt = 'STD'
AND popsrc = 'D'
AND consol = 'C'
Equivalent to legacy shrcd IN (10, 11):
df = df.loc[
(df.sharetype == 'NS') &
(df.securitytype == 'EQTY') &
(df.securitysubtype == 'COM') &
(df.usincflg == 'Y') &
(df.issuertype.isin(['ACOR', 'CORP']))
]
WHERE acqdisp = 'D' -- Dispositions
AND trancode IN ('S', 'D', 'G', 'F') -- Sales, Dispositions, Gifts, Tax
Always use parameterized queries (never string formatting):
# Correct
cursor.execute("""
SELECT gvkey, conm FROM comp.company WHERE gvkey = %s
""", (gvkey,))
# For lists, use ANY()
cursor.execute("""
SELECT * FROM comp.funda WHERE gvkey = ANY(%s)
""", (gvkey_list,))
Detailed query patterns and table documentation:
references/compustat.md - Compustat tables, ExecuComp, financial variablesreferences/crsp.md - CRSP stock data, CCM linking, v2 formatreferences/insider-form4.md - Thomson Reuters Form 4, rolecodes, insider typesreferences/iss-compensation.md - ISS Incentive Lab, peer companies, compensationreferences/edgar.md - SEC EDGAR filings, URL construction, DCN vs accession numbersreferences/connection.md - Connection pooling, caching, error handlingWorking code from real projects:
examples/form4_disposals.py - Insider trading analysis (from SVB project)examples/wrds_connector.py - Connection pooling patternscripts/test_connection.py - Validate WRDS connectivityWRDS-provided samples at ~/resources/wrds-code-samples/:
ResearchApps/CCM2025.ipynb - Modern CRSP-Compustat mergeResearchApps/ff3_crspCIZ.ipynb - Fama-French factor constructioncomp/sas/execcomp_ceo_screen.sas - ExecuComp patternsPattern from oh-my-opencode: When querying historical data, be aware of current date context.
Current date is automatically available via datetime.now(). Use this for:
Example:
from datetime import datetime, timedelta
# Query last 5 years of data
end_date = datetime.now()
start_date = end_date - timedelta(days=5*365)
query = """
SELECT * FROM comp.funda
WHERE datadate BETWEEN %s AND %s
"""
df = pd.read_sql(query, conn, params=(start_date, end_date))
Force current year awareness in date-dependent queries.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.