Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Stock Merger/Split. #991

Closed
ChiahungTai opened this issue Mar 18, 2022 · 5 comments
Closed

About Stock Merger/Split. #991

ChiahungTai opened this issue Mar 18, 2022 · 5 comments
Labels
question Further information is requested

Comments

@ChiahungTai
Copy link
Collaborator

❓ Questions and Help

Hi, @you-n-g and there,
The stock price source from the brokers in Taiwan is not included the adj close price like Yahoo. That will cause un-reasonable backtest result. Do you have some suggestion for this problems?
Below are some solutions, do you have any comments?

  1. Adjusted the price of sotck befor the date of stock merger/split, like Yahoo finance.
  2. Modify backtest code to reduce the amount of holding stocks. This is much like the actual behaviour of real world.
  3. Any other thoughts?

Thanks.

@ChiahungTai ChiahungTai added the question Further information is requested label Mar 18, 2022
@ChiahungTai
Copy link
Collaborator Author

  1. Change the factor field?

@you-n-g
Copy link
Collaborator

you-n-g commented Mar 18, 2022

All the volume, holding positions, prices in Qlib are adjusted values.
IIUC, such special cases are handled by the field $factor

Could you give us a concrete case of merger/split? (e.g. a specific stock id & timestamp)?
I want to make sure that I didn't misunderstand it.

@ChiahungTai
Copy link
Collaborator Author

All the volume, holding positions, prices in Qlib are adjusted values. IIUC, such special cases are handled by the field $factor

Could you give us a concrete case of merger/split? (e.g. a specific stock id & timestamp)? I want to make sure that I didn't misunderstand it.

Thanks for your reply.
The cases are below link.
https://www.twse.com.tw/zh/page/trading/exchange/TWTAUU.html
I am trying to change the HLOC in the dump_bin process in my local branch.
The idea is to multiple the reference change rate before the adjusted date.
For example:
Screen Shot 2022-03-18 at 8 24 06 PM
Take 2412 as an example:
100/1/5 is the adjusted date.
The price of 100/1/4 is 73.1. The reference price is 88.87 because the total shares will be reduced by capital reduction(stock merger). The shares reduction rate is 73.1/88.87=0.82. The price change rate 88.87/73.1=1.21. The total value is the same but the outstanding share will be reduced.
So my idea is any OHLC before 100/1/4 is multilple by 1.21(88.87/73.1).
Any suggstions are welcome.

@you-n-g
Copy link
Collaborator

you-n-g commented Mar 22, 2022

@ChiahungTai
I think dividing OHLC after 100/1/4 by 1.21 will be a better idea

  1. You can keep the historical data the same when appending new data.
  2. It will avoid introduce look-ahead bias
    image

@ChiahungTai
Copy link
Collaborator Author

@ChiahungTai I think dividing OHLC after 100/1/4 by 1.21 will be a better idea

  1. You can keep the historical data the same when appending new data.
  2. It will avoid introduce look-ahead bias
    image

Thanks for your comment. I will try it. The only problem of dividing OHLC after 100/1/4 is hard to check the K chart with other program for the ongoing prices.
Your comment is very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants