| 11 | |
| 12 | |
| 13 | def main() -> None: |
| 14 | ds = openquant.research.make_synthetic_futures_dataset(n_bars=160, seed=11) |
| 15 | out = openquant.research.run_flywheel_iteration(ds) |
| 16 | |
| 17 | assert out["frames"]["events"].height > 5 |
| 18 | assert out["frames"]["signals"].height == len(ds.timestamps) |
| 19 | assert out["frames"]["weights"]["weight"].sum() == out["frames"]["weights"]["weight"].sum() |
| 20 | |
| 21 | label_endtime = [(0, 3), (1, 4), (2, 6), (5, 8)] |
| 22 | bar_index = list(range(12)) |
| 23 | ind_mat = openquant.sampling.get_ind_matrix(label_endtime, bar_index) |
| 24 | samples = openquant.sampling.seq_bootstrap(ind_mat, sample_length=6, warmup_samples=[0, 1]) |
| 25 | assert len(samples) == 6 |
| 26 | |
| 27 | payload = openquant.viz.prepare_feature_importance_payload( |
| 28 | ["term_structure", "roll_yield", "carry", "momentum"], |
| 29 | [0.32, 0.28, 0.19, 0.21], |
| 30 | ) |
| 31 | assert payload["chart"] == "bar" |
| 32 | |
| 33 | grid = openquant.research.run_flywheel_grid( |
| 34 | ds, |
| 35 | configs=[{"step_size": 0.05}, {"step_size": 0.1, "commission_bps": 2.5}], |
| 36 | run_names=["base", "alt"], |
| 37 | ) |
| 38 | assert grid["leaderboard"].height == 2 |
| 39 | |
| 40 | screen = openquant.feature_diagnostics.feature_screen_report( |
| 41 | [[1.0, 1.01, 2.0], [2.0, 2.01, 2.0], [3.0, 3.01, 2.0], [4.0, 4.01, 2.0]], |
| 42 | min_coverage=1.0, |
| 43 | max_corr=0.95, |
| 44 | ) |
| 45 | assert "table" in screen |
| 46 | |
| 47 | print("python notebook smoke: ok") |
| 48 | |
| 49 | |
| 50 | if __name__ == "__main__": |