eventstudy.Multiple.from_text

classmethod Multiple.from_text(text: str, event_study_model, event_window: tuple = (-10, 10), estimation_size: int = 300, buffer_size: int = 30, *, date_format: str = '%Y-%m-%d', keep_model: bool = False, ignore_errors: bool = True)

Compute an aggregate of event studies from a multi-line string containing each event’s parameters.

Parameters
  • text (str) – List of events in a multi-line string format. The first line must contains the name of each parameter needed to compute the event_study_model. All value must be separated by a comma (see example for more details).

  • event_study_model – Function returning an eventstudy.Single class instance. For example, eventstudy.Single.market_model() (a custom functions can be created).

  • event_window (tuple, optional) – Event window specification (T2,T3), by default (-10, +10). A tuple of two integers, representing the start and the end of the event window. Classically, the event-window starts before the event and ends after the event. For example, event_window = (-2,+20) means that the event-period starts 2 periods before the event and ends 20 periods after.

  • estimation_size (int, optional) – Size of the estimation for the modelisation of returns [T0,T1], by default 300

  • buffer_size (int, optional) – Size of the buffer window [T1,T2], by default 30

  • date_format (str, optional) – Format of the date provided in the event_date column, by default “%Y-%m-%d”. Refer to datetime standard library for more details date_format: https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior

  • keep_model (bool, optional) – If true the model used to compute each single event study will be stored in memory. They will be accessible through the class attributes eventStudy.Multiple.singles[n].model, by default False

  • ignore_errors (bool, optional) – If true, errors during the computation of single event studies will be ignored. In this case, these events will be removed from the computation. However, a warning message will be displayed after the computation to warn for errors. Errors can also be accessed using print(eventstudy.Multiple.error_report()). If false, the computation will be stopped by any error encounter during the computation of single event studies, by default True

Example

>>> text = """security_ticker, market_ticker, event_date
...     AAPL, SPY, 05/11/2018
...     AAPL, SPY, 03/11/2017
...     AAPL, SPY, 26/10/2016
...     AAPL, SPY, 28/10/2015
... """
>>> agg = eventstudy.Multiple.from_text(
...     text = text,
...     event_study_model = eventstudy.Single.market_model,
...     event_window = (-5,+10),
...     date_format = "%d/%m/%Y"
... )