π νκ΅μ΄λ‘ 보기
Toss Auto-Trading Dev Journal Series (Phase 7-8 / 26 posts total)
- Phase 0 β Foundation (#0)
- Phase 0-1 β Currency Bug Fix (#0-1)
- Phase 1 β Config & Retry Logic (#3)
- Phase 1-2 β Config/Retry Follow-up (#4)
- Phase 1-3 β Introducing pytest (#5)
- Phase 1-4 β Log Rotation (#6)
- Phase 2-1 β Strategy Class Design (#7)
- Phase 2-2 β Multi-Symbol Monitoring (#8)
- Phase 3-1 β Data Persistence Design (#9)
- Phase 3-2 β DB Module Implementation (#10)
- Phase 3-3 β DB Integration (#11)
- Phase 2-3 β Strategy Plugin Interface (#12)
- Phase 4 β Backtest Engine (#13)
- Phase 4 β Candle API Pagination (#14)
- Phase 5 β Read-Only Dashboard (#15)
- Phase 5 β Telegram Control Logic (#16)
- Phase 5 β Telegram Control Logic Follow-up (#17)
- Phase 6 β Scheduler & Watchdog (#18)
- Phase 7 β Order Limit Guard (#19)
- Phase 7 β Loss Limit Auto-Pause (#20)
- Phase 7-3 β Dual-Channel Notifications (#21)
- Phase 7-4 β Security Diagnostics (#22)
- Phase 7-5 β Per-Symbol Take-Profit/Stop-Loss (#23)
- Phase 7-6 β FastAPI Dashboard Integration (#24)
- Phase 7-7 β Holdings Dashboard (#25)
- Phase 7-8 β One-Click Sell Condition UI (#26) Β· current post
Previous: Phase 7-7 Holdings Dashboard β | Next: to be added after publishing
You’re on Phase 7-8 / 26th of the series
π‘ Phase 7-8 at a glance
- Goal: Let a user set a sell target directly from the holdings table, with independent BUY/SELL/BOTH conditions per symbol
- Key decision: A FastAPI Form API (backed by
python-multipart) writes straight tostrategy_configs, and a newstock_namescache table powers a “Samsung Electronics (005930)”-style display - Verification: Live API token diagnostics passed, 130/130 pytest cases green
One-click sell condition setup is finally live on my Toss Securities dashboard as of Phase 7-8. My dashboard used to show a wall of ticker codes I had to look up every time, and setting a sell condition meant editing the code by hand.
Holdings Visualization & One-Click Sell Condition UI
Holdings pulled via toss_portfolio.fetch_holdings now render at the top of the dashboard β quantity, average price, current price, unrealized P&L, and return rate β each row with an inline form to set a sell target on the spot.
@app.post("/api/strategies")
async def create_strategy(
symbol: str = Form(...),
side: str = Form(...), # BUY / SELL / BOTH
target_price: float = Form(...),
):
save_strategy_config(symbol, side, target_price)
return RedirectResponse("/", status_code=303)
Forgot to install the form dependency first and hitRuntimeError: Form data requires "python-multipart" to be installed. Fixed withpip install python-multipart.
In a mock account, if Samsung Electronics (005930) is held at an average price of β©71,000 for 10 shares, entering a target of β©78,000 writes to strategy_configs instantly and monitoring starts right away.
Independent Buy/Sell Conditions & Stock-Name Display
The old setup only supported a single buy condition. I split it into a side column with three values: BUY, SELL, and BOTH β so a symbol you already hold can be watched for SELL only, a new symbol for BUY only, or both at once.
The stock_names Cache Table
Every API response now caches its stock name into a stock_names table, and a single get_display_name() helper standardizes the label across the whole dashboard.
def get_display_name(code: str) -> str:
name = get_cached_stock_name(code)
return f"{name} ({code})" if name else code
No more raw codes like “005930” β it now reads “Samsung Electronics (005930)” everywhere, same for SK Hynix (000660).
Dry-Run Buy/Sell Cycle, Dual-Channel Alerts & Security Diagnostics
With DRY_RUN = True, hitting a target price now runs a full dry-run cycle β buy β track return β take-profit/stop-loss sell β and logs it to the trades table, so I can validate strategy logic without placing real orders.
Alerts got redundant too: anything WARNING or above now goes out over both Telegram and email (SMTP) via a reworked notifier.py. security_check.py non-destructively checks .env Git protection, the five safety-brake states, and OAuth2 token connectivity in one report.
Finally, start_all_daemons.bat / stop_all_daemons.bat now bring up all four daemons β auto_trader, bot_server, scheduler, dashboard β with a single click on Windows boot.
Verification: 130 pytest Cases
Live API token diagnostics passed, and all 130 pytest cases β including the new python-multipart form handling β passed as well. Since this phase touched UI, DB, alerts, and security all at once, the regression suite mattered more than usual.
Wrap-Up
The one-click sell condition goal is basically done for this phase. Next up: adding a stop-loss ratio slider to the same UI.