feat: block US BUY entries below minimum price threshold (#320)
Some checks failed
Gitea CI / test (pull_request) Waiting to run
Gitea CI / test (push) Has been cancelled

This commit is contained in:
agentson
2026-02-28 14:40:19 +09:00
parent 13a6d6612a
commit 08607eaa56
2 changed files with 37 additions and 0 deletions

View File

@@ -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)

View File

@@ -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: