feat(sync): add per-ticker sync mode with relay/proxy API support + data coverage check - #5
Open
827346462 wants to merge 2 commits into
Open
feat(sync): add per-ticker sync mode with relay/proxy API support + data coverage check#5827346462 wants to merge 2 commits into
827346462 wants to merge 2 commits into
Conversation
Add check_coverage rule that validates all expected ETF/stock codes are present in each daily partition. Uses the basic reference table (list_date/delist_date) to compute expected codes per date. - New rule: check_coverage() in rules.py with severity tiers: - FAIL (<80% coverage) - WARN (80-95% coverage) - WARN (missing well-known ETF like 510300.SH) - New method: _expected_codes_for_date() in runner.py - Integrated into _check_frame for fund_daily and daily_kline targets - Well-known ETF codes (510300, 510050, 159915, etc.) trigger WARN even when coverage is above 95%
Add TickerSyncJob that iterates over ETF tickers instead of trading dates, enabling sync through relay/proxy APIs that only support per-ticker date-range queries. Key changes: - New _ProxiedDataApi class: Tushare DataApi-compatible client using X-API-Key header auth + proxy-free session for relay endpoints - TushareFetcher accepts optional proxy_url; auto-selects between standard pro_api and _ProxiedDataApi based on URL pattern - New fetch_fund_daily_range(ts_code, start, end) method for per-ticker queries - New get_etf_codes() helper returning sorted ETF list from etf_basic - TickerSyncJob: iterates tickers, fetches date range per ticker, writes daily partitions with dedup - Pipeline build_registry accepts ticker_mode flag; etf module conditionally creates TickerSyncJob vs DailySyncJob - CLI: '--ticker-mode' flag activates per-ticker sync path
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.
Overview
Two features that together solve the problem of syncing data through relay/proxy APIs that don't support the standard Tushare date-range query pattern.
1. Data Coverage Check (Quality Rule)
Adds
check_coverage()rule that validates all expected ETF/stock codes are present in each daily partition:Integrates into
_check_frameforfund_dailyanddaily_klinetargets.2. Per-Ticker Sync Mode (
--ticker-mode)Adds a new
TickerSyncJobthat syncs data by iterating over ETF tickers instead of trading dates. This is needed when the data source:X-API-Keyheader instead of body tokenArchitecture
_ProxiedDataApi: Tushare DataApi-compatible client using requests.Session withX-API-Keyauth,trust_env=False, and empty proxiesTushareFetcher: accepts optionalproxy_url; auto-selects between standardts.pro_api()and_ProxiedDataApibased on URL patternTickerSyncJob: iterates ETF codes frometf_basic, fetches date range per ticker, writes daily partitions with dedup--ticker-modeflag activates per-ticker sync pathConfig
No breaking changes — existing users without
proxy_urlcontinue using the standardts.pro_api().Testing