update file
Browse files- graders/task1_grader.py +17 -14
- graders/task2_grader.py +25 -18
- graders/task3_grader.py +23 -19
graders/task1_grader.py
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def grade_task1(agent_action, observation):
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# Check if
|
| 6 |
-
if
|
| 7 |
-
score += 0.45
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# Check if
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
# Check if
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 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 |
-
|
| 24 |
-
score = 0.
|
| 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 |
-
|
| 4 |
-
|
| 5 |
-
|
| 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 |
-
#
|
| 16 |
-
|
| 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 |
-
|
| 24 |
-
score = 0.
|
| 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)
|