feat: implement timezone-based global market auto-selection
Some checks failed
CI / test (pull_request) Has been cancelled

Implement comprehensive multi-market trading system with automatic
market selection based on timezone and trading hours.

## New Features
- Market schedule module with 10 global markets (KR, US, JP, HK, CN, VN)
- Overseas broker for KIS API international stock trading
- Automatic market detection based on current time and timezone
- Next market open waiting logic when all markets closed
- ConnectionError retry with exponential backoff (max 3 attempts)

## Architecture Changes
- Market-aware trading cycle with domestic/overseas broker routing
- Market context in AI prompts for better decision making
- Database schema extended with market and exchange_code columns
- Config setting ENABLED_MARKETS for market selection

## Testing
- 19 new tests for market schedule (timezone, DST, lunch breaks)
- All 54 tests passing
- Lint fixes with ruff

## Files Added
- src/markets/schedule.py - Market schedule and timezone logic
- src/broker/overseas.py - KIS overseas stock API client
- tests/test_market_schedule.py - Market schedule test suite

## Files Modified
- src/main.py - Multi-market main loop with retry logic
- src/config.py - ENABLED_MARKETS setting
- src/db.py - market/exchange_code columns with migration
- src/brain/gemini_client.py - Dynamic market context in prompts

Resolves #5

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
agentson
2026-02-04 09:29:25 +09:00
parent 2e63ac4a29
commit b26ff0c1b8
16 changed files with 877 additions and 79 deletions

View File

@@ -33,6 +33,9 @@ class Settings(BaseSettings):
# Trading mode
MODE: str = Field(default="paper", pattern="^(paper|live)$")
# Market selection (comma-separated market codes)
ENABLED_MARKETS: str = "KR"
model_config = {"env_file": ".env", "env_file_encoding": "utf-8"}
@property
@@ -42,3 +45,8 @@ class Settings(BaseSettings):
@property
def account_product_code(self) -> str:
return self.KIS_ACCOUNT_NO.split("-")[1]
@property
def enabled_market_list(self) -> list[str]:
"""Parse ENABLED_MARKETS into list of market codes."""
return [m.strip() for m in self.ENABLED_MARKETS.split(",") if m.strip()]