📊 sunnypoint

[2026-08-02] Work Log

6 min read

CMDP Integration and Korean Market Data Boundary Restoration

We thoroughly reviewed the 7 failure types that occurred in the LangAlpha analysis pipeline last week and fully implemented the quality improvement master plan determined in the actual code. In this task, to avoid compromising the stability of the production system, instead of blindly merging the entire trunk, we cherry-picked only the core CMDP implementation PR #312 and necessary accuracy follow-up commits for clean integration. Most importantly, we significantly shifted the data validation location, reducing the heavy runtime burden of re-calculating through APIs or LLMs every time an answer is generated. We store and propagate the results validated once at the ingest point as DataQualityMeta metadata, and in the answer generation stage, we immediately reference only these quality tags, greatly improving overall response speed and resource efficiency.

We also significantly reorganized the Korean market data stack boundaries. Even for the same instrument identity, we strictly isolated KRX, NXT, and integrated feeds into separate cache and pin namespaces based on feed_variant. Along with this, we raised the cache envelope version to v6, fundamentally blocking conflicts with old format cache data. For daily price data processing, we clearly divided Kiwoom daily data as provisional data and KRX official daily data as final data. When provisional data is replaced with final data, we designed it to increase the revision number even if OHLC (open, high, low, close) values are identical, ensuring data traceability. We also carefully maintained exception handling to return 404 in environments where the CMDP feature flag is disabled, allowing web clients to immediately fallback to the legacy bar feed.

Enhanced Data Quality Contracts and Claim Ledger System Construction

To enhance the reliability of analysis reports, we strengthened quality contracts across currency, consensus, and validation expressions. For Korean-listed instruments, we strictly maintained KRW as the base price currency, but configured it to strongly block only when currencies mismatch without FX application timing or source information. When currency information itself is missing, we downgraded to a "limited" quality label instead of blocking the entire answer, maintaining flexibility. We normally allowed converted values marked with USD or explicit FX source for Korean companies listed in the US (ADR), but immediately blocked target prices with zero coverage (coverage=0), while reducing insufficient sample size or aggregation period to limited expressions to clearly explain the source and limitations. Additionally, we thoroughly prohibited expressions definitively stating earnings over/under performance until final confirmation from authorized data sources like DART or KRX.

To track analysis evidence output by the model, we precisely classified the validation expression stages into three types: calculation verification, same-series reconciliation, and independent verification. During answer generation, we made the model directly output structured claim blocks (terminal claim blocks) for immediate storage in the database, requiring each claim to specify values, currency, units, and reference timepoints. To maintain connections with previous claims, we injected active claim identifiers, stance, and time horizon into the model, ensuring that when the model modifies existing opinions, it clearly records reasons for change and evidence differences (evidence_delta). We built the pipeline to automatically judge arbitrary changes without explanation as "unexplained_revision".

Automated Diagnostics, Real-time Language Correction and Comprehensive Regression Testing

We also elevated the operational automation and error diagnostic system. We applied database migration (023) to safely store error occurrence stages and detailed error codes in dedicated fields. Particularly, when generating Korean reports, we excluded code blocks, URLs, numbers, tickers, ASCII identifiers, and claim JSON configurations from inspection targets, significantly reducing false positives that occurred during language violation checks. If a language violation is detected during automatic briefing publication, we equipped it with automatic recovery logic that attempts immediate redeployment once using a correction prompt reflecting the violation details, while maintaining the same collected dataset.

After completing the migration (024) that creates a new claim ledger structure, we implemented a weekly claim evaluation script (score_claims_weekly.py) to automatically aggregate direction hit rate, target price entry status, and maximum adverse excursion percentage (max_adverse_excursion_pct) based on 5 trading days. To clarify terminology confusion that occurred in previous error notation, we clearly separated absolute error and percentage error fields. In the actual measurement verification phase, we successfully conducted KRX and Kiwoom live shadow tests with real listed instruments such as Samsung Electronics (005930), and fundamentally downgraded price missing occurrences from NXT unsupported instruments to no-coverage status. Including 5,391 backend unit tests and 1,902 frontend tests, we passed all code style and static analysis, completing stable deployment preparations.

Today's Thoughts

I tried to fix things well, but it seems that completely fixing exchange rates and information errors across different countries is not as easy as I thought.

In the financial market, starting with exchange rates, it might seem simpler than expected, but there are many exceptions that need to be handled by request.

Comments

💬 GitHub Discussions comment widget (Giscus integration pending)