Logo Wrds

Wrds

Cộng đồng
Barrios88
wrds

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", "query TRACE bond data", "clean TRACE", "merge FISD", "query TAQ", "pull intraday trades or quotes", "build NBBO", "compute effective spread", or needs WRDS PostgreSQL query patterns.

Add to TypingMind

Tổng quan

Nhà phát hànhBarrios88
Kho mãbarrios-skills
Tên kỹ năngwrds
Sao
64
Bản fork
30
Tệp đi kèm
12
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 12 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được Barrios88 công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Wrds trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/Barrios88/barrios-skills/tree/main/skills/econometrics/wrds
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Barrios88/barrios-skills.git /tmp/barrios-skills
mkdir -p .claude/skills
cp -r /tmp/barrios-skills/skills/econometrics/wrds .claude/skills/wrds
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Wrds trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Wrds ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Wrds với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Barrios Skills — John Barrios's curated workflow for economists and accountants. Prioritize reproducible empirical work, clear identification language, and journal-ready output.

WRDS MCP (recommended for AI agents)

John Barrios's wrds-mcp server exposes WRDS to Cursor, Claude, and other MCP clients.

Before querying WRDS, the user must:

  1. Install the MCP from mcp/wrds-mcp/ — see install/wrds-mcp.md
  2. Set their own credentials: WRDS_USERNAME and WRDS_PASSWORD (from their WRDS account)
  3. Start the tunnel: bash mcp/wrds-mcp/tunnel/tunnel_up.sh and approve Duo MFA once per session
  4. Register the MCP with WRDS_TUNNEL_PORT=49600 in Cursor or Claude config

When to use WRDS instead / with EDGAR: Compustat fundamentals panels, CRSP returns, CCM links, ExecuComp, ISS, TRACE/TAQ — use this skill + wrds-mcp. For live filing text, XBRL facts, and public Forms 3/4/5 without WRDS panel infrastructure, use the sec-edgar skill + SEC EDGAR MCP.

When MCP tools are available (wrds_run_sql, wrds_get_compustat, etc.), prefer MCP over raw Python connections. Still apply all filter rules in this skill.

If the user has not configured MCP credentials, stop and walk them through install/wrds-mcp.md — do not guess usernames or passwords.

Contents

WRDS Data Access

WRDS (Wharton Research Data Services) provides academic research data via PostgreSQL at wrds-pgdata.wharton.upenn.edu:9737.

Query Enforcement

IRON LAW: NO QUERY WITHOUT FILTER VALIDATION FIRST

Before executing ANY WRDS query, you MUST:

  1. IDENTIFY what filters are required for this dataset
  2. VALIDATE the query includes those filters
  3. VERIFY parameterized queries (never string formatting)
  4. EXECUTE the query
  5. INSPECT a sample of results before claiming success

This is not negotiable. Claiming query success without sample inspection is LYING to the user about data quality.

Rationalization Table - STOP If You Think:

ExcuseRealityDo Instead
"I'll add filters later"You'll forget and pull bad dataAdd filters NOW, before execution
"User didn't specify filters"Standard filters are ALWAYS requiredApply Critical Filters section defaults
"Just a quick test query"Test queries with bad filters teach bad patternsUse production filters even for tests
"I'll let the user filter in pandas"Pulling millions of unnecessary rows wastes time/memoryFilter at database level FIRST
"The query worked, so it's correct"Query success ≠ data qualityINSPECT sample for invalid records
"I can use f-strings for simple queries"SQL injection risk + wrong type handlingALWAYS use parameterized queries

Red Flags - STOP Immediately If You Think:

  • "Let me run this query quickly to see what's there" → NO. Check Critical Filters section first.
  • "I'll just pull everything and filter later" → NO. Database-level filtering is mandatory.
  • "The table name is obvious from the request" → NO. Check Quick Reference section for exact names.
  • "I can inspect the data after the user sees it" → NO. Sample inspection BEFORE claiming success.

Query Validation Checklist

Before EVERY query execution:

For Compustat queries (comp.funda, comp.fundq):

  • Includes indfmt = 'INDL'
  • Includes datafmt = 'STD'
  • Includes popsrc = 'D'
  • Includes consol = 'C'
  • Uses parameterized queries for variables
  • Date range is explicitly specified

For CRSP v2 queries (crsp.dsf_v2, crsp.msf_v2):

  • Post-query filter: sharetype == 'NS'
  • Post-query filter: securitytype == 'EQTY'
  • Post-query filter: securitysubtype == 'COM'
  • Post-query filter: usincflg == 'Y'
  • Post-query filter: issuertype.isin(['ACOR', 'CORP'])
  • Uses parameterized queries

For Form 4 queries (tr_insiders.table1):

  • Transaction type filter specified (acqdisp)
  • Transaction codes specified (trancode)
  • Date range is explicitly specified
  • Uses parameterized queries

For TAQ queries (taqm_YYYY.ctm_ / cqm_ / complete_nbbo_*):**

  • Using taqm_YYYY (daily partitioned) for post-2003 work, not legacy taq
  • Trade filter: tr_corr = '00' (string, not integer)
  • Trade conditions: drop tr_scond containing Z, O, T, U, G, B (non-regular)
  • Regular trading hours: time_m BETWEEN '09:30:00' AND '16:00:00'
  • Price > 0 and size > 0 sanity checks
  • For NBBO: use complete_nbbo_* (not nbbom_* — incomplete by design)
  • If joining to CRSP: use wrdsapps_link_crsp_taqm with sdate/edate bounds
  • Consider wrds_iid_YYYY for pre-computed daily liquidity measures
  • Never SELECT * — specify columns (ctm has 20, cqm/nbbom are huge)
  • Sort explicitly by (time_m, time_m_nano, tr_seqnum) — insertion order not guaranteed

For TRACE queries (trace_enhanced.trace_enhanced):

  • Using trace_enhanced (uncapped) not trace_standard (capped) for research
  • Dick-Nielsen cleaning applied: drop trc_st IN ('X','C','W','Y') + matched originals
  • Pre-/post-2012-02-06 logic branch selected correctly
  • Agency double-count filter: NOT (cmsn_trd='Y' AND cntra_mp_id='D')
  • Commissioned trades handled (cmsn_trd='N' for price/yield work)
  • Special trades excluded: spcl_trd_fl != 'Y' (for price/liquidity analysis)
  • FISD merge for bond characteristics (coupon, maturity, rating, issuer)
  • Date range is explicitly specified on trd_exctn_dt
  • Uses parameterized queries

For ALL queries:

  • Sample inspection with .head() or .sample() BEFORE claiming success
  • Row count verification (is result size reasonable?)
  • NULL value check on critical columns
  • Date range validation (does min/max match expectations?)

Quick Reference: Table Names

DatasetSchemaKey Tables
Compustatcompcompany, funda, fundq, secd
ExecuCompcomp_execucompanncomp
CRSPcrspdsf, msf, stocknames, ccmxpf_lnkhist
CRSP v2crspdsf_v2, msf_v2, stocknames_v2
Form 4 Insiderstr_insiderstable1, header, company
ISS Incentive Labiss_incentive_labcomppeer, sumcomp, participantfy
Capital IQciqwrds_compensation
IBEStr_ibesdet_epsus, statsum_epsus
SEC EDGARwrdssecwrds_forms, wciklink_cusip
SEC Searchwrds_sec_searchfiling_view, registrant
EDGARedgarfilings, filing_docs
Fama-Frenchfffactors_monthly, factors_daily
LSEG/Datastreamtr_dsds2constmth, ds2indexlist
TRACE Enhanced (bonds, uncapped)trace_enhancedtrace_enhanced, trace_btds144a_enhanced, trace_agency_enhanced
TRACE Standard (bonds, capped)trace_standardtrace, trade_summary
FISD bond characteristics (Mergent)fisdfisd_mergedissue, fisd_mergedissuer, fisd_issue, fisd_issuer
TAQ Daily MSEC (ticks, µs)taqm_YYYYctm_YYYYMMDD, cqm_YYYYMMDD, complete_nbbo_YYYYMMDD, nbbom_YYYYMMDD, mastm_YYYY, wrds_iid_YYYY
TAQ Monthly (legacy, 1993–2014, sec)taqmonthly consolidated trades/quotes
CRSP↔TAQ linkwrdsapps_link_crsp_taqmlink table

Connection

Initialize PostgreSQL connection to WRDS:

python
import psycopg2

conn = psycopg2.connect(
    host='wrds-pgdata.wharton.upenn.edu',
    port=9737,
    database='wrds',
    sslmode='require'
    # Credentials from ~/.pgpass
)

Configure authentication via ~/.pgpass with chmod 600:

wrds-pgdata.wharton.upenn.edu:9737:wrds:USERNAME:PASSWORD

Connect via SSH tunnel:

bash
ssh wrds

This uses ~/.ssh/wrds_rsa for authentication.

Critical Filters

Compustat Standard Filters

Always include for clean fundamental data:

sql
WHERE indfmt = 'INDL'
  AND datafmt = 'STD'
  AND popsrc = 'D'
  AND consol = 'C'

CRSP v2 Common Stock Filter

Equivalent to legacy shrcd IN (10, 11):

python
df = df.loc[
    (df.sharetype == 'NS') &
    (df.securitytype == 'EQTY') &
    (df.securitysubtype == 'COM') &
    (df.usincflg == 'Y') &
    (df.issuertype.isin(['ACOR', 'CORP']))
]

Form 4 Transaction Types

sql
WHERE acqdisp = 'D'  -- Dispositions
  AND trancode IN ('S', 'D', 'G', 'F')  -- Sales, Dispositions, Gifts, Tax

TAQ Standard Cleaning (Holden-Jacobsen 2014)

Minimum filter for academic intraday work:

sql
-- Trades (ctm_YYYYMMDD)
WHERE tr_corr = '00'                               -- uncorrected
  AND price > 0 AND size > 0
  AND time_m BETWEEN '09:30:00'::time AND '16:00:00'::time
  AND (tr_scond IS NULL OR tr_scond = ''
       OR tr_scond !~ '[BGJKLOTUWZ4567]')          -- regular-way only

-- Quotes (cqm_YYYYMMDD)
WHERE bid > 0 AND ask > 0 AND ask > bid
  AND bidsiz > 0 AND asksiz > 0
  AND qu_cond IN ('A','B','H','O','R','W')
  AND time_m BETWEEN '09:30:00'::time AND '16:00:00'::time

Always prefer complete_nbbo_* over nbbom_* — the raw NBBO feed is incomplete when one exchange holds both sides of the top of book. If re-deriving, UNION nbbom with cqm records where natbbo_ind='1' OR nasdbbo_ind='4'. See references/taq.md.

TRACE Enhanced Cleaning (Dick-Nielsen 2014)

Apply BEFORE any price/volume analysis:

sql
-- Post-2012-02-06: drop cancels, corrections, reversals + their matched originals.
-- Match originals on (cusip_id, entrd_vol_qt, rptd_pr, trd_exctn_dt,
-- trd_exctn_tm, rpt_side_cd, cntra_mp_id, msg_seq_nb).
WHERE trc_st = 'T'                              -- keep only clean originals
  AND NOT (cmsn_trd = 'Y' AND cntra_mp_id = 'D') -- drop agency double count
  AND spcl_trd_fl != 'Y'                         -- drop special-condition trades
  AND wis_fl != 'Y'                              -- drop when-issued
  -- For price/yield work, also:
  AND cmsn_trd = 'N'

Pre-2012-02-06 data uses asof_cd = 'R' for reversals instead of trc_st = 'Y'; use the pre-2012 branch. See references/trace.md.

Parameterized Queries

Always use parameterized queries (never string formatting):

Use scalar parameter binding for single values:

python
cursor.execute("""
    SELECT gvkey, conm FROM comp.company WHERE gvkey = %s
""", (gvkey,))

Use ANY() for list parameters:

python
cursor.execute("""
    SELECT * FROM comp.funda WHERE gvkey = ANY(%s)
""", (gvkey_list,))

Additional Resources

Reference Files

Detailed query patterns and table documentation:

  • references/compustat.md - Compustat tables, ExecuComp, financial variables
  • references/crsp.md - CRSP stock data, CCM linking, v2 format
  • references/insider-form4.md - Thomson Reuters Form 4, rolecodes, insider types
  • references/iss-compensation.md - ISS Incentive Lab, peer companies, compensation
  • references/edgar.md - SEC EDGAR filings, URL construction, DCN vs accession numbers
  • references/trace.md - TRACE bond transactions, Dick-Nielsen cleaning, FISD merge, pre-/post-2012 logic
  • references/taq.md - TAQ/TAQMSEC intraday trades, quotes, complete NBBO, Holden-Jacobsen filters, WRDS Intraday Indicators
  • references/connection.md - Connection pooling, caching, error handling

Example Files

Working code from real projects:

  • examples/form4_disposals.py - Insider trading analysis (from SVB project)
  • examples/wrds_connector.py - Connection pooling pattern

Scripts

  • scripts/test_connection.py - Validate WRDS connectivity

Local Sample Notebooks

WRDS-provided samples at ~/resources/wrds-code-samples/:

  • ResearchApps/CCM2025.ipynb - Modern CRSP-Compustat merge
  • ResearchApps/ff3_crspCIZ.ipynb - Fama-French factor construction
  • comp/sas/execcomp_ceo_screen.sas - ExecuComp patterns

Date Awareness

When querying historical data, leverage current date context for dynamic range calculations.

Current date is automatically available via datetime.now(). Apply this to:

  • Data range validation (e.g., "get data for last 5 years")
  • Fiscal year calculations
  • Event study windows

Implement dynamic date ranges in queries:

python
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))

Always incorporate current date awareness in date-dependent queries to ensure results remain fresh across time.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Wrds làm được gì?

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", "query TRACE bond data", "clean TRACE", "merge FISD", "query TAQ", "pull intraday trades or quotes", "build NBBO", "compute effective spread", or needs WRDS PostgreSQL query patterns.

Vì sao nên dùng Wrds trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Wrds là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Wrds trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/Barrios88/barrios-skills/tree/main/skills/econometrics/wrds. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Wrds?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Wrds với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Wrds với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Wrds có miễn phí không?

Có. Kỹ năng này được Barrios88 phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇