summaryrefslogtreecommitdiff
path: root/shared/tests/test_sentiment.py
blob: 9bd8ea31d9c1bb8b7828af0f36f337e931c63164 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Tests for market sentiment module."""

from shared.sentiment import SentimentData


def test_sentiment_should_buy_default_no_data():
    s = SentimentData()
    assert s.should_buy is True
    assert s.should_block is False


def test_sentiment_should_buy_low_fear_greed():
    s = SentimentData(fear_greed_value=15)
    assert s.should_buy is True


def test_sentiment_should_not_buy_on_greed():
    s = SentimentData(fear_greed_value=75)
    assert s.should_buy is False


def test_sentiment_should_not_buy_negative_news():
    s = SentimentData(news_sentiment=-0.4)
    assert s.should_buy is False


def test_sentiment_should_buy_positive_news():
    s = SentimentData(fear_greed_value=50, news_sentiment=0.3)
    assert s.should_buy is True


def test_sentiment_should_block_extreme_greed():
    s = SentimentData(fear_greed_value=85)
    assert s.should_block is True


def test_sentiment_should_block_very_negative_news():
    s = SentimentData(news_sentiment=-0.6)
    assert s.should_block is True


def test_sentiment_no_block_on_neutral():
    s = SentimentData(fear_greed_value=50, news_sentiment=0.0)
    assert s.should_block is False