Background: Strategy Migration Leads to Backtesting Failure
In April 2026, a senior quantitative strategy developer attempted to migrate a successful high-dividend strategy from the JoinQuant platform to the PTrade platform. The core logic of the strategy involved three steps:
- Financial Screening: Select stocks with Return on Equity (ROE), net profit growth, and operating cash flow all greater than 0.
- Dividend Stability: Require target stocks to have a dividend yield greater than 0 in the current, one-year-ago, and two-year-ago reporting periods.
- Sector-based Selection: In each primary industry sector, select the single stock with the highest dividend yield to form the final portfolio.
In theory, this should have been a straightforward migration. However, the backtesting results on the PTrade platform were drastically different from the JoinQuant version. The strategy’s performance was far below expectations, barely outperforming the benchmark index, indicating a severe problem in the code implementation.
Anomaly: Financial Common Sense Reveals a Code Flaw
During the initial investigation, the developer printed logs and discovered that the “high-dividend” stocks selected by the strategy generally had dividend yields below 1%. This immediately raised a red flag. Based on basic market knowledge, well-known high-dividend stocks like Yangtze Power typically have dividend yields above 3%, far higher than the stocks selected by the strategy. This anomaly suggested that genuinely high-quality, high-dividend stocks were not being correctly identified and were being filtered out during the screening process.
The developer manually verified the data for Yangtze Power, confirming that it met all financial screening criteria and had a stable dividend yield above 3% for the past three years. According to the strategy’s logic, if no other stock in Yangtze Power’s industry had a higher dividend yield, it should have been selected. But the fact that all the finally selected “sector champions” had yields below 1% proved that Yangtze Power must have been incorrectly excluded at some stage, pointing directly to a flaw in the code.
Debugging Divergence: The Diagnostic Paths of Different AI Models
The developer first used their usual combination of Claude Code and Minimax 2.7 for debugging assistance. After several rounds of conversation, the AI proposed three possible lines of investigation:
- Missing Data Issue: Suspected that dividend yield data for Yangtze Power might be null for a specific
query_date, causing it to be filtered out.
- Data Timeliness Issue: Pointed out that the historical data used in backtesting might differ from the data on the current date of manual verification, potentially causing discrepancies in dividend yields.
- Industry Classification Issue: Guessed that the stock might have been excluded during the data cleaning step due to missing industry classification information.
However, after verifying each point, all three hypotheses were proven false. The debugging process hit a dead end, and as the conversation context grew, the quality of the AI’s responses began to decline.

Seeking a breakthrough, the developer switched to a combination of Codex and GPT-5.5. After submitting the complete strategy code and a document detailing the previous failed investigation attempts, GPT-5.5 provided a remarkably precise diagnosis: “The problem lies in the to_ratio function. A dividend yield of 3.4% is being incorrectly divided by 100, compressing it to 0.034%.”
Root Cause Analysis: The Fatal Trap of Data Unit Conversion
As prompted by the Codex & GPT-5.5 models, the core of the problem was traced to a custom data processing function named to_ratio(). This function contained the logic: return number / 100.0 if number > 1 else number.
The intended purpose of this logic was to handle data that might come in different units, based on the assumption that:
- If the input value is greater than 1 (e.g., 6.21), it represents a percentage multiple (621%) and needs to be normalized by dividing by 100.
- If the input value is less than or equal to 1 (e.g., 0.53), it represents the actual percentage as a decimal and requires no processing.
However, the dividend yield data returned by the PTrade platform’s API is in “percentage points.” This means a value of 3.4 directly represents 3.4%, not 340%. The function incorrectly identified Yangtze Power’s 3.4 dividend yield (which is > 1) as the type that needed processing, executing the division by 100 and converting it to 0.034. In the subsequent sorting step, this incorrectly processed 0.034% naturally couldn’t compete with a stock that had an actual yield of 0.9%, leading to the systematic elimination of high-dividend stocks.
This subtle misunderstanding of data units was the root cause of the entire strategy’s failure. After fixing the logic in the to_ratio function, the overall trend of the strategy’s backtesting curve aligned with the JoinQuant version, confirming that the problem had been resolved.
Takeaway: The Value of Advanced AI Models in Critical Debugging
This incident clearly demonstrates the capability gap between different AI models in handling complex, hidden problems in the era of AI-assisted development. While conventional AI tools perform well in code generation and general Q&A, when faced with debugging tasks that require a deep understanding of context, data specifications, and potential logical fallacies, more advanced models (like Codex and GPT-5.5 in this case) can cut straight to the heart of the matter with their superior analytical and reasoning abilities, significantly reducing time spent on fruitless investigations.
This case study shows that for developers in specialized fields like quantitative finance, investing in top-tier AI models is valuable not just for improving development efficiency, but more importantly, for breaking through critical bottlenecks and avoiding massive time costs due to tool limitations. It reinforces the idea that in the AI era, the most precious resources are a developer’s time and focus.