feat: add time stop rule for stale positions
Sell position if held for TIME_STOP_HOURS (default 24h) with less than TIME_STOP_MIN_GAIN_PCT (default +3%) gain. Frees up capital for fresh momentum opportunities. Priority: trailing stop (-10%) checked first, then time stop. Both thresholds configurable via .env. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import logging
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
import pyupbit
|
||||
@@ -21,7 +22,7 @@ PER_POSITION = MAX_BUDGET // MAX_POSITIONS # 종목당 33만3천원
|
||||
|
||||
_lock = threading.Lock()
|
||||
_positions: dict = {}
|
||||
# 구조: { ticker: { buy_price, peak_price, amount, invested_krw } }
|
||||
# 구조: { ticker: { buy_price, peak_price, amount, invested_krw, entry_time } }
|
||||
|
||||
_upbit: Optional[pyupbit.Upbit] = None
|
||||
|
||||
@@ -73,6 +74,7 @@ def buy(ticker: str) -> bool:
|
||||
"peak_price": current,
|
||||
"amount": amount,
|
||||
"invested_krw": order_krw,
|
||||
"entry_time": datetime.now(),
|
||||
}
|
||||
logger.info(
|
||||
f"[매수] {ticker} @ {current:,.0f}원 | "
|
||||
|
||||
Reference in New Issue
Block a user