Giter VIP home page Giter VIP logo

link_compustat_ibes's Introduction

Link_compustat_ibes

Python script to create a mapping table between I/B/E/S and Compustat. Requires WRDS login credentials.

Supported methods are via CRSP and via G_Security.

Example call

python3 link_compustat_ibes.py -o ~/linktable.csv

This asks the script to create a link table in the user's home path. It will download I/B/E/S, CRSP, and a Compustat-CRSP linktable from WRDS SQL server and merge the three tables in order to create a linktable for I/B/E/S and Compustat. This requires valid login credentials to WRDS.

The option -m (or --method) can be used to specify the method with which the two tables should be merged (see above). The script can either perform the merge via the CRSP key or via G_security. CRSP is the default. To merge via G_security, run

python3 link_compustat_ibes.py -o ~/linktable2.csv -m 'gsec'

link_compustat_ibes's People

Contributors

snauhaus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

link_compustat_ibes's Issues

Q for Permission

Hi, when I run code "db.get_table(library='ibes', table='idsum', columns=['ticker', 'cusip', 'cname']) " I got a Programming error:

ProgrammingError: (psycopg2.errors.InsufficientPrivilege) permission denied for schema tr_ibes

[SQL: SELECT ticker,cusip,cname FROM ibes.idsum OFFSET 0;]
(Background on this error at: http://sqlalche.me/e/f405)

Does it mean I don't have access to use this I/B/E/S database?
Thanks~

About link compustat and crsp by python

I have two questions I would like to ask you. Thanks.

  1. How to match CRSP monthly with Compustat quarterly through python?
    Is like this ?
# Get a comp demo data
comp_demo = db.get_table(library='comp', table='funda', columns=['gvkey', 'datadate',
                                                                'fyear'])
comp_demo.drop_duplicates(inplace=True)

# Get a CRSP demo data
crsp_demo = db.get_table(library='crsp', table='msf', columns=['permno', 'ncusip', 'date'])
crsp_demo.drop_duplicates(inplace=True)

# Get Compustat-CRSP linktable
link = db.get_table(library='crsp', table='ccmxpf_lnkhist', columns=['gvkey', 'lpermno', 'lpermco', 'linktype', 'linkprim']) # 'linkdt', 'linkenddt'
link = link[link['linktype'].isin(['LC', 'LU'])]
link = link[link['linkprim'].isin(['C', 'P'])]
link.drop(['linktype', 'linkprim'], axis=1, inplace=True)

crsp_add_gvkey = crsp_demo.merge(link, left_on='permno', right_on='lpermno')
crsp_add_gvkey.drop_duplicates(inplace=True)

out = crsp_add_gvkey.merge(comp_demo, left_on='gvkey', right_on='gvkey')
out.drop_duplicates(inplace=True)
  1. how to resample the data by fiscal year ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.