fix: handle empty strings in price data parsing (issue #49) #50

Merged
jihoson merged 2 commits from feature/issue-49-valueerror-empty-string into main 2026-02-05 00:45:06 +09:00
Collaborator

Summary

  • Fixes ValueError crashes when KIS API returns empty strings for price data
  • Applies consistent or "0" pattern to handle empty strings across main.py and scanner.py
  • Adds comprehensive test coverage for empty string scenarios

Changes

  • src/main.py:110 - Add or "0" for current_price parsing
  • src/analysis/scanner.py:86-87 - Add or "0" for price/volume parsing
  • tests/test_main.py - Add test_overseas_price_empty_string
  • tests/test_volatility.py - Add test_scan_stock_overseas_empty_price

Before/After

Before:

ERROR: ValueError: could not convert string to float: ''
at src/main.py:110

Trading cycle crashes, system stops processing stocks.

After:
Empty strings default to 0.0, trading cycle continues normally.

Test Results

  • All 279 tests pass
  • Coverage: 80% (maintained)
  • New tests verify empty string handling

Impact

  • Severity: HIGH fix - prevents trading cycle crashes
  • Markets affected: Overseas markets (US_NASDAQ, US_NYSE)
  • Frequency: Common during market hours when API is busy

Closes #49

🤖 Generated with Claude Code

## Summary - Fixes ValueError crashes when KIS API returns empty strings for price data - Applies consistent `or "0"` pattern to handle empty strings across main.py and scanner.py - Adds comprehensive test coverage for empty string scenarios ## Changes - **src/main.py:110** - Add `or "0"` for `current_price` parsing - **src/analysis/scanner.py:86-87** - Add `or "0"` for price/volume parsing - **tests/test_main.py** - Add `test_overseas_price_empty_string` - **tests/test_volatility.py** - Add `test_scan_stock_overseas_empty_price` ## Before/After **Before:** ``` ERROR: ValueError: could not convert string to float: '' at src/main.py:110 ``` Trading cycle crashes, system stops processing stocks. **After:** Empty strings default to `0.0`, trading cycle continues normally. ## Test Results - All 279 tests pass - Coverage: 80% (maintained) - New tests verify empty string handling ## Impact - **Severity**: HIGH fix - prevents trading cycle crashes - **Markets affected**: Overseas markets (US_NASDAQ, US_NYSE) - **Frequency**: Common during market hours when API is busy Closes #49 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-05 00:31:26 +09:00
fix: handle empty strings in price data parsing (issue #49)
Some checks failed
CI / test (pull_request) Has been cancelled
854931bed2
Apply consistent empty-string handling across main.py and scanner.py
to prevent ValueError when KIS API returns empty strings.

Changes:
- src/main.py:110 - Add 'or "0"' for current_price parsing
- src/analysis/scanner.py:86-87 - Add 'or "0"' for price/volume parsing
- tests/test_main.py - Add test_overseas_price_empty_string
- tests/test_volatility.py - Add test_scan_stock_overseas_empty_price

Before: ValueError crashes trading cycle
After: Empty strings default to 0.0, trading continues

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
agentson added 1 commit 2026-02-05 00:44:12 +09:00
Merge main into feature/issue-49-valueerror-empty-string
Some checks failed
CI / test (pull_request) Has been cancelled
702653e52e
Resolved conflict in src/main.py by using safe_float() from main
instead of float(...or '0') pattern.

Changes:
- src/main.py: Use safe_float() for consistent empty string handling
- All 16 tests pass including test_overseas_price_empty_string
jihoson merged commit cf5072cced into main 2026-02-05 00:45:06 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#50