qlib icon indicating copy to clipboard operation
qlib copied to clipboard

How Qlib handles dividend by factor data?

Open hensejiang opened this issue 3 years ago • 2 comments

❓ Questions and Help

I've been seeking a solution to update Qlib database to reflect the real stock market in China, while found that the 'factor' is supposed to be the bridge connecting qlib data to real world. But this Qlib factor appreas to reflect the real dividend date but somehow not the value itself. Example for instrument SH600016 in datetime, instrument, $close, $factor, $close/$factor, Real_close, Real_foreAdjustFactor 2019-07-04, SH600016, 10.784764, 1.6746529, 6.4399996, 6.4399996, 0.850308 2019-07-04, SH600016, 10.775917, 1.7694445, 6.09, 6.09, 0.850308

When the stock executed dividend plan and the price changed accordingly, Qlib seems taking the non-dividend values as its price data and put them into storate. In above my test it shows $close/$factor = Real_close (non-dividend price)

I calculated these two qlib $factors and found: 1.6746529 / 1.7694445 = 0.946429 != 0.850308, it made my question: when it comes to a day that I got the real stock price together with a new real adjust factor, how could I decide a proper $factor for qlib so to make all prices for Qlib data to update?

hensejiang avatar Aug 27 '22 09:08 hensejiang

Qlib team, can I ask your favour to this question? You must know that Yahoo Finance has banned all the requests coming from China, thus injecting data from outer source is must-have to keep Qlib programs continue working. Any idea to share about how Qlib determines the factor? Thanks.

hensejiang avatar Sep 08 '22 13:09 hensejiang

Qlib team, can I ask your favour to this question? You must know that Yahoo Finance has banned all the requests coming from China, thus injecting data from outer source is must-have to keep Qlib programs continue working. Any idea to share about how Qlib determines the factor? Thanks.

hensejiang avatar Sep 08 '22 13:09 hensejiang

I'm sorry to reply your issue so late. Qlib uses the post-recovery price. To ensure this, qlib sets the first day price to 1 to calculate the post-recovery price, which is not the same as the recovery you are using, so the difference you are seeing will appear.

SunsetWolf avatar Oct 28 '22 12:10 SunsetWolf

This issue is stale because it has been open for three months with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

github-actions[bot] avatar Jan 26 '23 15:01 github-actions[bot]