Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package and method design #1

Open
chiraganand opened this issue Nov 5, 2022 · 0 comments
Open

Package and method design #1

chiraganand opened this issue Nov 5, 2022 · 0 comments

Comments

@chiraganand
Copy link
Member

chiraganand commented Nov 5, 2022

A lot of functionality of this package is going to be inspired from https:github.com/xKDR/eventstudies.

Software design

  1. Should use TimeFrames.jl for constructing event-time data frame.
  2. There doesn't seem to be a requirement for inventing a new type (struct). Methods can directly accept a TimeFrame object or any other Base type object like AbstractVector{Date}.

Methods

1. Converting from physical (calendar/clock) time to event time.

phy2eventtime(timestamps::AbstractVector{T}, event::T)::AbstractVector{Int} where {T<:Union{Date, DateTime, Time}}

Given a vector of timestamps of any of the supported types (sub-type of TimeType) this function will convert timestamps into event time of Int type based on the value of event which contains the time of the occurrence of the event. event will be looked up in timestamps and the nearest match will be considered as t0. Observations before t0 will be negative time starting from -1 till the start of the series and, similarly, observations after t0 will start from 1 till the end of the series.

phys2eventtime(tf::TimeFrame, events::Dict{Symbol, T}, width:StepRange{Int})::TimeFrame where {T<:Union{Date, DateTime, Time}}

Given a TimeFrame object find t0 of all events inside tf, and realign tf based on the event times. events is a dictionary containing a mapping from column names of tf to the event time of type T. The width column decided whether an event was successfully found in tf or not (outcomes), this information could be stored as DataFrame table-level metadata. Apart from this a list of successful events also needs to be returned, this also could be stored as table-level metadata.

Outcome types

@enum Outcome UnitMissing=1 OutcomeWrongSpan=2 OutcomeWDataMissing=3 OutcomeSuccess=4

2. Market model

marketmodel(firmreturns::TimeFrame, marketreturns::TimeFrame; residuals::Bool=true)

Run the market model (linear regression) using firm returns and market returns and return regression results, return residuals if true. If residuals is true then a TimeFrame object is returned otherwise regression object is returned of type StatsModels.TableRegressionModel.

3. Remapping of event frame

remap(tf::TimeFrame, f::Function)::TimeFrame

Apply the remapping function f on TimeFrame tf. Supported function may include cumsum and cumprod to begin with.

4. Inference procedures

inference(tf::TimeFrame, strategy::Function; args=...)::TimeFrame

Compute confidence intervals using strategy function. Usage will be something like: inference(tf, Bootstrap.bootstrap, [std, BasicSampling(1000)]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant