refactor: remove akshare, use direct Sina/Tencent/eastmoney APIs#10
Merged
Conversation
Move existing direct-API implementations into dedicated source modules (sina.py, tencent.py, eastmoney.py) under market/sources/. Shared utilities (parse_float, market_prefix, bypass_proxy, etc.) go into _common.py. No callers changed yet — akshare_provider.py still works. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add get_financial_indicators() to eastmoney source module, using the datacenter-web.eastmoney.com RPT_LICO_FN_CPD report for ROE, gross margin, and computed profit margin. Gracefully returns empty dict on failure. Includes unit tests with mocked API responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace all akshare imports with calls to source modules: - current_price: Sina (primary) + Tencent (fallback) - price_history: Tencent - basic_info: eastmoney CompanySurvey + Tencent valuation + eastmoney datacenter financial indicators - sector: Sina No more `import akshare` in the codebase. Updated contract tests to mock source modules instead of akshare. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename akshare_provider.py -> ashare_provider.py and class AKShareProvider -> AShareProvider. Update all imports and mock paths across CLI, analysis, and test files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove akshare from pyproject.toml and update lockfile. Update all documentation (CLAUDE.md, README.md) and config to reflect the switch to direct Sina/Tencent/eastmoney APIs. Rename AKSHARE_TIMEOUT config to API_TIMEOUT. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unit tests for each source module: - test_sina.py: current price, sector list, sector constituents - test_tencent.py: current price, price history, valuation - test_eastmoney.py: basic info, financial indicators Expand integration tests with financial indicators, sector list, and sector constituents. Fix unused import and format issues. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use Sina sector name "酿酒行业" instead of eastmoney's "白酒" in sector constituents test - Fix fundamental test to match actual output key "Overall_Valuation" (pre-existing issue on main) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
market/sources/architecture — split by data source (sina.py,tencent.py,eastmoney.py) with shared utilities in_common.pyfor long-term maintainabilityget_financial_indicators()usingdatacenter-web.eastmoney.comRPT_LICO_FN_CPD report (ROE, gross margin, computed profit margin)AKShareProvider→AShareProvider— all references updated across CLI, analysis, and testsSource Priority
hq.sinajs.cnqt.gtimg.cnweb.ifzq.gtimg.cnemweb+ Tencent valuationdatacenternewSinaHy.phpgetHQNodeDataTest Plan
pytest -m "not integration")ruff check . && ruff format --check .)pytest -m integration)grep -r "akshare" haoinvest/ tests/ pyproject.tomlreturns nothing🤖 Generated with Claude Code