initial import: etf strategy project
This commit is contained in:
26
scripts/smoke.py
Normal file
26
scripts/smoke.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from qfr.factors import winsorize_by_date, zscore_by_date
|
||||
from qfr.metrics import information_coefficient
|
||||
|
||||
|
||||
def main() -> None:
|
||||
dates = pd.to_datetime(["2026-01-01", "2026-01-02", "2026-01-03"])
|
||||
assets = ["A", "B", "C", "D"]
|
||||
idx = pd.MultiIndex.from_product([dates, assets], names=["date", "asset"])
|
||||
|
||||
rng = np.random.default_rng(42)
|
||||
factor = pd.Series(rng.normal(size=len(idx)), index=idx)
|
||||
fwd_ret = pd.Series(rng.normal(scale=0.01, size=len(idx)), index=idx)
|
||||
|
||||
factor2 = zscore_by_date(winsorize_by_date(factor))
|
||||
ic = information_coefficient(factor2, fwd_ret)
|
||||
|
||||
print("IC mean:", float(ic.mean()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user