HK data calculation

HK data calculation. Due to data quality issue its disabled by default.

Write data only when needed. Extremely improve performance of history
data calculation.
Merge pull request #14 from miuzel/master

HK data calculation