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)


!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 =, start=start, end = end, interval=’1d’).Close

df = pd.DataFrame(ihsg)

filename = “JKSE_monthly_data.xlsx”


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

ihsg =, 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 =, 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):


        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)




Otherwise, you have to do it manually in excel.


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


The excel file is HERE:

Published by:

Rayenda Brahmana

About research: google scholar: Others: twitter: @raye_brahm instagram: kolom.riset email: kolom.riset(at) raye_brahm(at)

Categories UncategorizedLeave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s