MCPcopy Create free account
hub / github.com/Open-Quant/openquant / test_viz_payloads

Function test_viz_payloads

python/tests/test_adapters_viz.py:63–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61 positions=[0.0, 1.0],
62 )
63 assert bt.columns == ["ts", "equity", "returns", "position"]
64 assert bt.height == 2
65
66
67def test_viz_payloads():
68 fi = openquant.viz.prepare_feature_importance_payload(
69 ["f1", "f2", "f3"], [0.2, 0.7, 0.1], std=[0.01, 0.02, 0.03], top_n=2
70 )
71 assert fi["chart"] == "bar"
72 assert fi["x"] == ["f2", "f1"]
73
74 dd = openquant.viz.prepare_drawdown_payload(
75 ["2024-01-01 09:30:00", "2024-01-01 09:31:00", "2024-01-01 09:32:00"],
76 [100.0, 99.0, 101.0],
77 )
78 assert dd["chart"] == "line"
79 assert len(dd["drawdown"]) == 3
80
81 reg = openquant.viz.prepare_regime_payload(["t1", "t2", "t3"], [0.3, -0.2, 0.1], threshold=0.0)
82 assert reg["regime"] == [1, -1, 1]
83
84 frontier = openquant.viz.prepare_frontier_payload([0.1, 0.2], [0.08, 0.12], sharpe=[0.8, 0.6])
85 assert frontier["chart"] == "scatter"
86 assert frontier["color"] == [0.8, 0.6]
87
88 comparison = openquant.viz.prepare_feature_importance_comparison_payload(
89 ["f1", "f2"], [0.6, 0.4], ["pc1", "pc2"], [0.55, 0.45]
90 )
91 assert comparison["chart"] == "grouped_bar"
92

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected