23 lines
608 B
Python
23 lines
608 B
Python
# -*- coding: utf-8 -*-
|
|
"""Tests for structured technical analyzer."""
|
|
|
|
import pandas as pd
|
|
|
|
from backend.tools.technical_signals import StockTechnicalAnalyzer
|
|
|
|
|
|
def test_technical_analyzer_detects_bullish_trend():
|
|
df = pd.DataFrame(
|
|
{
|
|
"time": pd.date_range("2024-01-01", periods=40, freq="D"),
|
|
"close": [100 + i for i in range(40)],
|
|
},
|
|
)
|
|
analyzer = StockTechnicalAnalyzer()
|
|
|
|
result = analyzer.analyze("AAPL", df)
|
|
|
|
assert result.current_price == 139.0
|
|
assert result.trend in {"BULLISH", "STRONG BULLISH"}
|
|
assert result.momentum_20d_pct > 0
|