feat(data): 移植 v1 validator + 适配接口 + 测试
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import pandas as pd
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def good_daily_df():
|
||||
return pd.DataFrame({
|
||||
"date": ["2026-01-01", "2026-01-02"],
|
||||
"open": [10.0, 11.0], "high": [10.5, 11.5],
|
||||
"low": [9.8, 10.8], "close": [10.2, 11.2],
|
||||
"volume": [10000, 12000],
|
||||
})
|
||||
|
||||
@pytest.fixture
|
||||
def bad_daily_df():
|
||||
return pd.DataFrame({
|
||||
"date": ["2026-01-01"],
|
||||
"open": [0.0], "high": [0.0], "low": [0.0], "close": [0.0],
|
||||
"volume": [100],
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
from sanguo_data.validator import validate_daily
|
||||
|
||||
def test_validate_daily_keeps_good_rows(good_daily_df):
|
||||
assert len(validate_daily(good_daily_df)) == 2
|
||||
|
||||
def test_validate_daily_drops_zero_price(bad_daily_df):
|
||||
assert len(validate_daily(bad_daily_df)) == 0
|
||||
Reference in New Issue
Block a user