Skip to content

Commit

Permalink
Fixed start window in EventStudy
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed Apr 8, 2021
1 parent e790450 commit 4320961
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ In finmarketpy/examples you will find several examples, including some simple tr

# finmarketpy log

* 08 Apr 2021
* Fixed EventStudy issue when start window is before time series
* 21 Mar 2021
* Fixed issue with EventStudy
* Refactored TradingModel when constructing weights
Expand Down
12 changes: 11 additions & 1 deletion finmarketpy/economics/eventstudy.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,21 @@ def get_intraday_moves_over_custom_event(self, data_frame_rets, ef_time_frame, v

vals = data_frame_rets.iloc[start_index[i]:finish_index[i]].values

st = ef_time_start[i]
en = ef_time_end[i]

# Add extra "future" history in case we are doing an event study which goes outside our data window
# (will just be filled with NaN)
if len(vals) < len(lst_ords):
extend = np.zeros((len(lst_ords) - len(vals), 1)) * np.nan
vals = np.append(vals, extend)

# If start window date is before we have data
if st < data_frame_rets.index[0]:
vals = np.append(extend, vals)

# If end date window is after we have data
else:
vals = np.append(vals, extend)

data_frame[ef_time_frame.index[i]] = vals

Expand Down

0 comments on commit 4320961

Please sign in to comment.