In an event studies we need to pick up data for the event window which can vary from company to company. If you have the time series of data where prices of all the companies are in the same format and you want the data only for a certain event window. You can use the VBA code as user defined function for getting the prices for a event window.
Go to tool > Macro > Visual basic Editor > Insert > Module . Copy the VBA code in the module and save. Select the event window, that is if you want 3 day on both side of the event , 7 column and go the user define function and select the function , “test_adj” . it will ask for four input variable. Date1 is the time series of the date where you collected the data , match is the event date , price is the stock price data for a company and eve for number days in the event. Then Ctrl + shift +enter gives you the prices for the company on the event window. The VBA code given below
Function test_adj(date1 As Variant, match, price, eve)
'Created by C A Yoonus and Surender Komera
Dim m, n, i, j, b, c As Variant, t, k, d
t = 1
m = Application.WorksheetFunction.Count(date1)
n = 1
ReDim b(n)
ReDim c(t)
'test_adj = m
For i = 1 To m
b(i) = date1(i) - match
n = n + 1
ReDim Preserve b(n)
If b(i) = 0 Then
j = i
End If
Next i
For k = j - eve To j + eve
c(t) = price(k)
t = t + 1
ReDim Preserve c(t)
Next k
d = Application.WorksheetFunction.Transpose(c)
test_adj = d
End Function
No comments:
Post a Comment