"""Tests for OBV indicator."""
import pytest
import pyita as ta

from conftest import TEST_DATA_FILENAME, arrays_equal_with_nan
from stock_indicators_helpers import get_si_ref


def test_obv_vs_si(test_ohlcv_data):
    """Test OBV calculation against stock-indicators reference."""
    quotes = ta.Quotes(
        test_ohlcv_data['open'],
        test_ohlcv_data['high'],
        test_ohlcv_data['low'],
        test_ohlcv_data['close'],
        test_ohlcv_data['volume'],
        test_ohlcv_data['time'],
    )

    obv_result = ta.obv(quotes)

    ref = get_si_ref(TEST_DATA_FILENAME, 'get_obv')

    assert arrays_equal_with_nan(
        obv_result.obv, ref.obv
    ), f"OBV does not match stock-indicators"
