Debunking Seasonality Data

So, this is the stata syntax, python code, and data for my latest twit about seasonality.

Because I don’t have the data, I retrieved from yahoo finance. This is the python code (I use google colab)

PYTHON CODE

!pip install yfinance

import pandas as pd

import yfinance as yf

import datetime

import time

ticker = “^JKSE”

start = datetime.datetime(1994, 12, 1)

end = datetime.datetime(2022, 12, 31)

ihsg = yf.download(ticker, start=start, end = end, interval=’1d’).Close

df = pd.DataFrame(ihsg)

filename = “JKSE_monthly_data.xlsx”

df.to_excel(filename)

p.s: If you want to change the data to monthly data:

ihsg = yf.download(ticker, start=start, end = end, interval=’1mo’).Close

If you want to calculate Sep-Mar Returns, you can MODIFY this:

ticker = “^JKSE”

start = “1995-01-01”

end = “2022-03-31”

df = yf.download(ticker, start=start, end=end, interval=’1d’)

# Create a new column with the year

df[‘Year’] = pd.DatetimeIndex(df.index).year

# Create a DataFrame to store the March returns

march_returns = pd.DataFrame(columns=[‘Year’, ‘Return’])

for year in range(1995, 2023):

    try:

        march_price = df.loc[str(year)+’-03-01′][‘Close’]

        september_price = df.loc[str(year-1)+’-09-30′][‘Close’]

        march_return = (march_price – september_price) / march_price * 100

        march_returns = march_returns.append({‘Year’: year, ‘Return’: march_return}, ignore_index=True)

    except:

        pass

print(march_returns)

Otherwise, you have to do it manually in excel.

STATA

Then, I use STATA to run the seasonality under dummy model. Note that, you need to calculate the monthly returns first. Then, make a dummy variable for each month. Refer to my attached excel file.

The Syntax:

tsset month

reg returns january february march april may june july august september october november december, nocons

reg returns february march april may june july august september october november december, robust

DATA

The excel file is HERE:

Published by:

Rayenda Brahmana

About research: google scholar: https://scholar.google.com/citations?hl=id&user=jlvpW3QAAAAJ&view_op=list_works&sortby=pubdate https://publons.com/researcher/1457129/rayenda-brahmana/ Others: twitter: @raye_brahm instagram: kolom.riset email: kolom.riset(at)gmail.com raye_brahm(at)yahoo.com

Categories UncategorizedLeave a comment

Leave a comment