Astocoder commited on
Commit
26f8631
·
1 Parent(s): 38c4774

update file

Browse files
graders/task1_grader.py CHANGED
@@ -1,20 +1,23 @@
 
 
 
 
 
1
  def grade_task1(agent_action, observation):
 
2
 
3
- score = 0.0
 
 
4
 
5
- # Check if action was GET_PRICE (0.01 to 0.49 range)
6
- if agent_action.get("type") == "GET_PRICE":
7
- score += 0.45 # Not 0.5 to avoid exactly 0.5
8
 
9
- # Check if observation has a valid price (0.01 to 0.49 range)
10
- price = observation.get("price", 0)
11
- if price > 0:
12
- score += 0.45 # Not 0.5 to avoid exactly 0.5
13
-
14
- # Ensured score is never 0.0 or 1.0
15
- if score == 0.0:
16
- score = 0.01 # Minimum positive score
17
- elif score >= 0.99:
18
- score = 0.98 # Maximum score below 1.0
19
 
20
  return round(score, 2)
 
1
+ """
2
+ Task 1: Fetch Market Data
3
+ Score must be strictly between 0 and 1 (never 0.0 or 1.0)
4
+ """
5
+
6
  def grade_task1(agent_action, observation):
7
+ score = 0.01 # Start with minimum positive score
8
 
9
+ # Check if action type is GET_PRICE (adds 0.45)
10
+ if agent_action and agent_action.get("type") == "GET_PRICE":
11
+ score += 0.45
12
 
13
+ # Check if observation has a valid price (adds 0.45)
14
+ if observation and observation.get("price", 0) > 0:
15
+ score += 0.45
16
 
17
+ # Clamp between 0.01 and 0.99
18
+ if score < 0.01:
19
+ score = 0.01
20
+ if score > 0.99:
21
+ score = 0.99
 
 
 
 
 
22
 
23
  return round(score, 2)
graders/task2_grader.py CHANGED
@@ -1,26 +1,33 @@
 
 
 
 
 
1
  def grade_task2(agent_action, observation):
 
2
 
3
- score = 0.0
 
 
 
 
4
 
5
- # Check if agent gave an explanation (0.01 to 0.49 range)
6
- explanation = agent_action.get("explanation", "")
7
- if explanation and len(explanation) > 10:
8
- score += 0.45
 
9
 
10
- # Check if action type is valid (BUY/SELL/GET_NEWS)
11
- action_type = agent_action.get("type", "")
12
- if action_type in ["BUY", "SELL", "GET_NEWS", "HOLD"]:
13
- score += 0.45
 
14
 
15
- # Check if news sentiment was considered
16
- sentiment = observation.get("last_news", {}).get("sentiment", "")
17
- if sentiment in ["positive", "negative", "neutral"]:
18
- score += 0.05
19
-
20
- # Ensure score is never 0.0 or 1.0
21
- if score == 0.0:
22
  score = 0.01
23
- elif score >= 0.99:
24
- score = 0.98
25
 
26
  return round(score, 2)
 
1
+ """
2
+ Task 2: News Sentiment Analysis
3
+ Score must be strictly between 0 and 1 (never 0.0 or 1.0)
4
+ """
5
+
6
  def grade_task2(agent_action, observation):
7
+ score = 0.01 # Start with minimum positive score
8
 
9
+ # Check if agent provided an explanation
10
+ if agent_action and agent_action.get("explanation"):
11
+ explanation = agent_action.get("explanation", "")
12
+ if len(explanation) > 10:
13
+ score += 0.30
14
 
15
+ # Check if action type is valid (BUY/SELL/HOLD/GET_NEWS)
16
+ if agent_action:
17
+ action_type = agent_action.get("type", "")
18
+ if action_type in ["BUY", "SELL", "HOLD", "GET_NEWS"]:
19
+ score += 0.30
20
 
21
+ # Check if news sentiment was analyzed
22
+ if observation and observation.get("last_news"):
23
+ sentiment = observation.get("last_news", {}).get("sentiment", "")
24
+ if sentiment in ["positive", "negative", "neutral"]:
25
+ score += 0.35
26
 
27
+ # Clamp between 0.01 and 0.99
28
+ if score < 0.01:
 
 
 
 
 
29
  score = 0.01
30
+ if score > 0.99:
31
+ score = 0.99
32
 
33
  return round(score, 2)
graders/task3_grader.py CHANGED
@@ -1,26 +1,30 @@
 
 
 
 
 
1
  def grade_task3(agent_action, observation):
 
2
 
3
- score = 0.0
4
-
5
- # Check if backtest results exist (0.01 to 0.49 range)
6
- backtest_results = observation.get("backtest_results")
7
- if backtest_results:
8
- score += 0.45
9
-
10
- # Check for Sharpe ratio (0.01 to 0.49 range)
11
- sharpe = backtest_results.get("sharpe_ratio", 0) if backtest_results else 0
12
- if sharpe > 0:
13
  score += 0.45
 
 
 
 
 
 
 
 
 
 
14
 
15
- # Small bonus for reasonable drawdown
16
- drawdown = backtest_results.get("max_drawdown", 1) if backtest_results else 1
17
- if drawdown < 0.5:
18
- score += 0.05
19
-
20
- # Ensure score is never 0.0 or 1.0
21
- if score == 0.0:
22
  score = 0.01
23
- elif score >= 0.99:
24
- score = 0.98
25
 
26
  return round(score, 2)
 
1
+ """
2
+ Task 3: Backtest Strategy
3
+ Score must be strictly between 0 and 1 (never 0.0 or 1.0)
4
+ """
5
+
6
  def grade_task3(agent_action, observation):
7
+ score = 0.01 # Start with minimum positive score
8
 
9
+ # Check if backtest results exist
10
+ if observation and observation.get("backtest_results"):
11
+ backtest_results = observation.get("backtest_results", {})
 
 
 
 
 
 
 
12
  score += 0.45
13
+
14
+ # Check for Sharpe ratio
15
+ sharpe = backtest_results.get("sharpe_ratio", 0)
16
+ if sharpe > 0:
17
+ score += 0.25
18
+
19
+ # Check for max drawdown
20
+ drawdown = backtest_results.get("max_drawdown", 1)
21
+ if drawdown < 0.5:
22
+ score += 0.25
23
 
24
+ # Clamp between 0.01 and 0.99
25
+ if score < 0.01:
 
 
 
 
 
26
  score = 0.01
27
+ if score > 0.99:
28
+ score = 0.99
29
 
30
  return round(score, 2)