Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(goal): an objective that is an order is still refused after #1562

Haozhe Wubbe1a69c74ce
diff --git a/agent/src/goal/policy.py b/agent/src/goal/policy.py
index ed4a62ef2..0d0919991 100644
--- a/agent/src/goal/policy.py
+++ b/agent/src/goal/policy.py
@@ -16,6 +16,16 @@ _EXECUTION_PATTERNS = (
re.I,
),
re.compile(r"(下单|市价单|限价单|马上买|立即买|现在买|马上卖|立即卖|现在卖)"),
+ # What the asset-noun list above used to catch, without its false
+ # positives: an objective that IS an order -- it opens with the verb
+ # ("Buy NVDA", "Please sell my TSLA") or names a quantity right after it
+ # ("then buy 100 shares", "short 2 ES", "买入100股"). A research goal
+ # frames the verb ("whether to buy", "should sell", "a short thesis").
+ # A leading "short" is left out: "Short interest ...", "Short-term ..."
+ # open research goals, so a bare "Short TSLA" passes.
+ re.compile(r"^\s*(?:please\s+)?(?:buy|sell)\b", re.I),
+ re.compile(r"\b(?:buy|sell|short)\s+\d", re.I),
+ re.compile(r"(?:买入|卖出|做空|买|卖)\s*\d+(?:\.\d+)?\s*(?:股|手|张|份|个)"),
)
diff --git a/agent/tests/test_goal_policy.py b/agent/tests/test_goal_policy.py
index 28c2e75a9..8c9b9c707 100644
--- a/agent/tests/test_goal_policy.py
+++ b/agent/tests/test_goal_policy.py
@@ -14,6 +14,11 @@ from src.goal.policy import reject_live_execution_objective
"Assess if the fund should sell its GOOGL shares given antitrust risk",
"Determine whether to short TSLA contracts based on delivery numbers",
"Evaluate a long AAPL thesis versus a short thesis on valuation grounds",
+ "Evaluate whether to buy NVDA at this valuation",
+ "Long-term outlook for AAPL versus its sector",
+ "Short interest trends in regional banks",
+ "Short-term momentum in semiconductors",
+ "研究茅台是否值得买入",
],
)
def test_ordinary_research_objectives_are_accepted(objective: str) -> None:
@@ -31,6 +36,13 @@ def test_ordinary_research_objectives_are_accepted(objective: str) -> None:
"Sell TSLA immediately, submit the order right away",
"Place an order to buy BTC right away",
"Buy 100 shares of NVDA right away using a limit order",
+ # Rejected before #1562 through the asset-noun list, and still orders.
+ "Buy 100 shares of NVDA",
+ "Short 2 ES contracts",
+ "buy 0.5 BTC",
+ "Please buy AAPL",
+ "Research the setup, then sell 50 TSLA",
+ "买入100股贵州茅台",
],
)
def test_genuine_execution_requests_are_still_rejected(objective: str) -> None: