Alice — an open-source AI trading bot covering equities, crypto, commodities, forex, and macro
Add tests for clean_ohlcv function
Added tests for the clean_ohlcv function to ensure it drops NaN and inf rows, and handles DataFrames without OHLC columns.
Cameron “Camo” De Vries committed
Nov 6, 2026 at 03:22 UTC
50c0febf7b81ef990ff4220c44e663065396c1dd
1 file changed
+25
tests/test_data.py
new
+25
@@ -0,0 +1,25 @@
1
+"""Tests for market data cleaning."""
2
+
3
+import numpy as np
4
+import pandas as pd
5
+
6
+from open_alice.data import clean_ohlcv
7
+
8
+
9
+def test_clean_ohlcv_drops_nan_and_inf_rows() -> None:
10
+ df = pd.DataFrame(
11
+ {
12
+ "Open": [1.0, np.nan, 3.0, 4.0],
13
+ "High": [1.0, 2.0, 3.0, 4.0],
14
+ "Low": [1.0, 2.0, np.inf, 4.0],
15
+ "Close": [1.0, 2.0, 3.0, np.nan],
16
+ }
17
+ )
18
+ clean = clean_ohlcv(df)
19
+ assert len(clean) == 1
20
+ assert np.isfinite(clean[["Open", "High", "Low", "Close"]].to_numpy()).all()
21
+
22
+
23
+def test_clean_ohlcv_passthrough_without_ohlc_columns() -> None:
24
+ df = pd.DataFrame({"Other": [1.0, np.nan]})
25
+ assert len(clean_ohlcv(df)) == 2