# Ceteris Lab downloadable Python script
# Course: Fundamentals of Python for Financial Econometrics

import numpy as np
import pandas as pd

prices = pd.Series([100, 102, 101, 104], index=pd.date_range("2026-01-01", periods=4, freq="D"))
simple = prices.pct_change()
log_return = np.log(prices).diff()
print(simple.dropna().round(4).tolist())
print(log_return.dropna().round(4).tolist())

import pandas as pd

idx = pd.date_range("2026-01-01", periods=60, freq="D")
daily = pd.DataFrame({"rate": range(60), "volume": [100]*60}, index=idx)
monthly = daily.resample("ME").agg(rate=("rate", "last"), volume=("volume", "sum"))
print(monthly)

import numpy as np
import pandas as pd
simple = prices.pct_change()
log_return = np.log(prices).diff()
print(simple.dropna().round(4).tolist())
print(log_return.dropna().round(4).tolist())
