From 08607eaa567b0f9f6785ba1ada5e62a4c5bee290 Mon Sep 17 00:00:00 2001 From: agentson Date: Sat, 28 Feb 2026 14:40:19 +0900 Subject: [PATCH] feat: block US BUY entries below minimum price threshold (#320) --- src/config.py | 1 + src/main.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/config.py b/src/config.py index 0e60e32..7f27aeb 100644 --- a/src/config.py +++ b/src/config.py @@ -60,6 +60,7 @@ class Settings(BaseSettings): # This value is used as a fallback when the balance API returns 0 in paper mode. PAPER_OVERSEAS_CASH: float = Field(default=50000.0, ge=0.0) USD_BUFFER_MIN: float = Field(default=1000.0, ge=0.0) + US_MIN_PRICE: float = Field(default=5.0, ge=0.0) OVERNIGHT_EXCEPTION_ENABLED: bool = True # Trading frequency mode (daily = batch API calls, realtime = per-stock calls) diff --git a/src/main.py b/src/main.py index cc158a2..a0c716e 100644 --- a/src/main.py +++ b/src/main.py @@ -1291,6 +1291,24 @@ async def trading_cycle( stock_code, market.name, ) + elif market.code.startswith("US"): + min_price = float(getattr(settings, "US_MIN_PRICE", 5.0) if settings else 5.0) + if current_price <= min_price: + decision = TradeDecision( + action="HOLD", + confidence=decision.confidence, + rationale=( + f"US minimum price filter blocked BUY " + f"(price={current_price:.4f} <= {min_price:.4f})" + ), + ) + logger.info( + "BUY suppressed for %s (%s): US min price filter %.4f <= %.4f", + stock_code, + market.name, + current_price, + min_price, + ) if decision.action == "HOLD": open_position = get_open_position(db_conn, stock_code, market.code) @@ -2442,6 +2460,24 @@ async def run_daily_session( stock_code, market.name, ) + elif market.code.startswith("US"): + min_price = float(getattr(settings, "US_MIN_PRICE", 5.0)) + if stock_data["current_price"] <= min_price: + decision = TradeDecision( + action="HOLD", + confidence=decision.confidence, + rationale=( + f"US minimum price filter blocked BUY " + f"(price={stock_data['current_price']:.4f} <= {min_price:.4f})" + ), + ) + logger.info( + "BUY suppressed for %s (%s): US min price filter %.4f <= %.4f", + stock_code, + market.name, + stock_data["current_price"], + min_price, + ) if decision.action == "HOLD": daily_open = get_open_position(db_conn, stock_code, market.code) if not daily_open: