File size: 1,837 Bytes
f23faaf
d6ae237
65b751b
 
 
d6ae237
65b751b
 
 
 
 
 
 
 
 
 
 
 
f23faaf
65b751b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f23faaf
65b751b
 
f23faaf
65b751b
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
45
46
47
48
49
50
51
52
53
54
def grade_task2(action, observation):
    """
    Task 2: News Sentiment Analysis with Explanation
    Grades: Quality of reasoning, financial knowledge, clarity
    This is your unique innovation!
    """
    score = 0.0
    
    # Get the agent's explanation
    explanation = action.get('explanation', '') if action else ''
    
    # 1. Check explanation length and detail (0-0.3 points)
    if len(explanation) > 100:
        score += 0.3
    elif len(explanation) > 50:
        score += 0.2
    elif len(explanation) > 20:
        score += 0.1
    else:
        score += 0.02
    
    # 2. Check for financial terminology (0-0.3 points)
    financial_terms = [
        'pe', 'p/e', 'valuation', 'earnings',
        'moving average', 'trend', 'momentum', 'rsi',
        'support', 'resistance', 'breakout',
        'risk', 'volatility', 'drawdown', 'sharpe',
        'sentiment', 'market cap', 'liquidity'
    ]
    terms_found = sum(1 for term in financial_terms if term in explanation.lower())
    score += min(0.3, terms_found * 0.05)
    
    # 3. Check for logical reasoning (0-0.2 points)
    reasoning_words = ['because', 'therefore', 'since', 'due to', 'based on', 'as a result']
    if any(word in explanation.lower() for word in reasoning_words):
        score += 0.2
    
    # 4. Check for specific data references (0-0.1 points)
    import re
    if re.search(r'\d+', explanation):  # Contains numbers
        score += 0.05
    if '%' in explanation:
        score += 0.05
    
    # 5. Check if recommendation is clear (0-0.1 points)
    recommendations = ['buy', 'sell', 'hold', 'accumulate', 'reduce']
    if any(word in explanation.lower() for word in recommendations):
        score += 0.1
    
    # Ensure score is strictly between 0 and 1
    score = max(0.01, min(0.99, score))
    
    return round(score, 2)