feat: block US BUY entries below minimum price threshold (#320)
This commit is contained in:
@@ -60,6 +60,7 @@ class Settings(BaseSettings):
|
|||||||
# This value is used as a fallback when the balance API returns 0 in paper mode.
|
# 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)
|
PAPER_OVERSEAS_CASH: float = Field(default=50000.0, ge=0.0)
|
||||||
USD_BUFFER_MIN: float = Field(default=1000.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
|
OVERNIGHT_EXCEPTION_ENABLED: bool = True
|
||||||
|
|
||||||
# Trading frequency mode (daily = batch API calls, realtime = per-stock calls)
|
# Trading frequency mode (daily = batch API calls, realtime = per-stock calls)
|
||||||
|
|||||||
36
src/main.py
36
src/main.py
@@ -1291,6 +1291,24 @@ async def trading_cycle(
|
|||||||
stock_code,
|
stock_code,
|
||||||
market.name,
|
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":
|
if decision.action == "HOLD":
|
||||||
open_position = get_open_position(db_conn, stock_code, market.code)
|
open_position = get_open_position(db_conn, stock_code, market.code)
|
||||||
@@ -2442,6 +2460,24 @@ async def run_daily_session(
|
|||||||
stock_code,
|
stock_code,
|
||||||
market.name,
|
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":
|
if decision.action == "HOLD":
|
||||||
daily_open = get_open_position(db_conn, stock_code, market.code)
|
daily_open = get_open_position(db_conn, stock_code, market.code)
|
||||||
if not daily_open:
|
if not daily_open:
|
||||||
|
|||||||
Reference in New Issue
Block a user