Feng-CityUHK / EquityCharacteristics

Calculate U.S. equity (portfolio) characteristics
https://feng-cityuhk.github.io/EquityCharacteristics/
82 stars 66 forks source link

Change Database State Date to a Constatnt #25

Open ThomasMConnors opened 3 months ago

ThomasMConnors commented 3 months ago

Add constant at top of file as follows

# Start date for data as month, day, year. Usually use the year 1959,
DATA_START_DATE = '01/01/1959'

Change all sql that uses dates to

crsp = conn.raw_sql(f"""
                    select a.permno, a.date, a.vol, a.shrout
                    from crsp.dsf as a
                    where a.date >= \'{DATA_START_DATE}\'
                    """)

Note that I am also suggesting the "=" be changed to a clearer and consistent ">="

files and code impacted:

abr.py:28: and datadate >= '01/01/1959' abr.py:66: where date >= '01/01/1959' abr.py:101: where a.date >= '01/01/1959' abr.py:118: where dlstdt >= '01/01/1959' abr.py:134: where date >= '01/01/1959' abr.py:207: where date >= '01/01/1959' accounting_100.py:88: and f.datadate >= '01/01/1959' accounting_100.py:140: where a.date >= '01/01/1959' accounting_100.py:901: and f.datadate >= '01/01/1959' accounting_100.py:1306: where date >= '01/01/1959' accounting_60_hxz.py:86: and f.datadate >= '01/01/1959' accounting_60_hxz.py:138: where a.date >= '01/01/1959' accounting_60_hxz.py:614: and f.datadate >= '01/01/1959' accounting_60_hxz.py:1019: where date >= '01/01/1959' accounting_60.py:86: and f.datadate >= '01/01/1959' accounting_60.py:138: where a.date >= '01/01/1959' accounting_60.py:614: and f.datadate >= '01/01/1959' accounting_60.py:1002: where date >= '01/01/1959' beta.py:32: where a.date > '01/01/1959' bid_ask_spread.py:32: where a.date > '01/01/1959' ill.py:30: where a.date > '01/01/1959' maxret_d.py:30: where a.date > '01/01/1959' rvar_capm.py:32: where a.date >= '01/01/1959' rvar_ff3.py:32: where a.date > '01/01/1959' rvar_mean.py:23: where date >= '01/01/1959' std_dolvol.py:30: where a.date > '01/01/1959' std_turn.py:30: where a.date > '01/01/1959' sue.py:29: and datadate >= '01/01/1959' sue.py:89: where date >= '01/01/1959' zerotrade.py:30: where a.date > '01/01/1959'