ZKIZ Archives

Ztrader – the Data 港股博弈


Oct 1, 2013

Recently busy in developing a new TA system, named Ztrader, which targets high performance, fast new indicator development, fast real-time scanning, portfolio management and etc. Later I will share more about this new system’s capability and new features.




The Data


Ztrader is the 3rd system I developed for stock trading. The reason to develop my own system was backed to few years ago. I’ve attended Mr Sky Cheung’s training course, at that time, my TA knowledge was zero and I was a “simple FA” guy. The course did only teach very basic TA skills which likely you can learn by yourself from reading several TA books in library.


As discussed previously in http://clcheung.wordpress.com/2012/06/09/%E7%B3%BB%E7%B5%B1%E6%96%B0%E5%8A%9F%E8%83%BD%EF%BC%9A%E7%B5%82%E6%A5%B5%E5%9C%96%E8%A1%A8%E5%8A%9F%E8%83%BD%E6%9B%B4%E6%96%B0/

in 除淨因素, the dividend effect was not count in most free service providers.


The first good thing I learn in the course was : TA system depends on good data. The software using at the course was Metastock, which is a simple to use software for beginner. So I subscribed Metastock data from a local vendor. Unfortunately, the data provider regularly gave wrong data in a delayed manner. It was frustrating. Also, I was trying to build cross market data functions, like sectors and market indicators, which seems not easy to do so at that version of Metastock. Metastock’s capability also imposed quite a lot of limitations and it was difficult to program complicated indicators in the environment. (I am not sure if the latest version of Metastock has any improvement.)


Although my system seems fixed the data issue, which I do ex-dividend, split and merge, and stock code migration, ex-right, board switching, etc., properly. The data issue is still not completely solved. Re-quote the example here:


Day 1: 股價 $95

Day 2: 股價 $100 股價上升 5%+$5 (5.26%)

Day 3: 股價 $10 ,因為派息 $90

Day 4: 股價 $5 股價下跌 50%-$5 (-50%)


How to handle this dividend payout is complicated. Now consider again another example:


Day 1:

Close $100

High $105


Day 2

Price +$1

Close $101 +1%

High $106


Day 3

Pay $50 Dividend, Price close at $51

Close $51 0%

High $56


Day 4

Price +2

Close $53 +3.92%

High $57


Day 100

Price from Day 5 to Day 100 +$53

Close $103 +100% relative to Day 4

High $110


Day 101

Pay $100 dividend, Price close at $6

Close $6 +100%

High $7


This stock totally paid $150 dividend. If the dividend is not excluded from the historical stock price, all TA indicators will be useless. If dividend is excluded from the historical stock price, you will see the historical price goes below zero. This makes quite a few indicators failed or information changed. For example, the ROC indicator. Failing means back-testing of the effectiveness of the indicators or any trading system failed.


To deal with the situation properly, a new delta adjusted method will be used, which worked like the current “price comparing” function. This delta adjusted method assuming the dividend of a stock can be re-invest on the stock immediately. Not 100% correct, but makes the system more practical and almost any indicators will be functioned as expected.


To illustrate with a practical case, consider 2088 this year, it paid 0.75 sp dividend on July 4:


from Google:



Definitely the chart is not helpful, it only tags a special dividend there.


from aastock:




the chart data seems correctly ex-dividend. However, the ROC indicator got confused. Also, aastock system does not showing negative prices.


From my existing stockmaster system:


same problem as in aastock, ROC indicator is confused.


In the new Ztrader system, the data is delta adjusted accordingly, instead of one-off ex-dividend:



ROC is correctly displayed. The rate of return on this stock can be much better calculated in this system.


In fact the Stockmaster or aastock ex-dividend method changes also the historical volatility. The candle height relative to the closing price are amplified by the ex-dividend effects.

PermaLink: https://articles.zkiz.com/?id=77003

Next Page

ZKIZ Archives @ 2019