Sina Finance provides APIs to retrieve adjustment factors for calculating adjusted prices. This is useful for identifying ex-dividend dates and calculating true returns.
Adjustment APIs
- Forward Adjustment (前复权):
https://finance.sina.com.cn/realstock/company/{stock_id}/qfq.js - Backward Adjustment (后复权):
https://finance.sina.com.cn/realstock/company/{stock_id}/hfq.js
Data Format
The response is a series of JSON objects containing:
d: The date of the adjustment.f: The adjustment factor.
Calculation Logic
To calculate the adjusted return using these factors, use the following logic:
Using Forward Adjustment (qfq):
To compare a price at date $T_1$ with a price at date $T_2$ (where $T_2$ is the more recent date):
$$\text{Return} = \frac{\text{Price}{T2} / f{T2}}{\text{Price}{T1} / f{T1}}$$
Using Backward Adjustment (hfq):
$$\text{Return} = \frac{\text{Price}{T2} \times f{T2}}{\text{Price}{T1} \times f{T1}}$$
Note: The ratio of factors in hfq is the inverse of the ratio in qfq.
// Example response from qfq.js
[{"d":"2019-06-03", "f":"1.0000000000000000"}, {"d":"2007-01-18", "f":"1.3000000000000000"}]