update files
Browse files- graders/__init__.py +5 -1
- graders/task1_grader.py +15 -8
- graders/task2_grader.py +20 -8
- graders/task3_grader.py +21 -10
graders/__init__.py
CHANGED
|
@@ -1 +1,5 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .task1_grader import grade_task1
|
| 2 |
+
from .task2_grader import grade_task2
|
| 3 |
+
from .task3_grader import grade_task3
|
| 4 |
+
|
| 5 |
+
__all__ = ['grade_task1', 'grade_task2', 'grade_task3']
|
graders/task1_grader.py
CHANGED
|
@@ -1,13 +1,20 @@
|
|
| 1 |
def grade_task1(agent_action, observation):
|
| 2 |
-
|
| 3 |
score = 0.0
|
| 4 |
|
| 5 |
-
# Check if
|
| 6 |
-
if agent_action.type == "GET_PRICE":
|
| 7 |
-
score += 0.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
if
|
| 11 |
-
score
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
return score
|
|
|
|
| 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)
|
graders/task2_grader.py
CHANGED
|
@@ -1,14 +1,26 @@
|
|
| 1 |
def grade_task2(agent_action, observation):
|
| 2 |
-
|
| 3 |
score = 0.0
|
| 4 |
|
| 5 |
-
# Check if agent gave an explanation
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
# Check if action is valid (BUY/SELL/
|
| 10 |
action_type = agent_action.get("type", "")
|
| 11 |
-
if action_type in ["BUY", "SELL", "GET_NEWS"]:
|
| 12 |
-
score += 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
return score
|
|
|
|
| 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)
|
graders/task3_grader.py
CHANGED
|
@@ -1,15 +1,26 @@
|
|
| 1 |
def grade_task3(agent_action, observation):
|
| 2 |
-
|
| 3 |
score = 0.0
|
| 4 |
|
| 5 |
-
# Check if backtest results exist
|
| 6 |
backtest_results = observation.get("backtest_results")
|
| 7 |
if backtest_results:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|