So, let's define the estimation task in terms of type classes and datatypes. At first, in this chapter we are going to work with bars. They have open, low, high, and close prices. We should define timestamps and time intervals. A conversion to day duration is quite useful for further volatility annualizing, that is, casting to volatility in one year interval. This is found in BarTypes.hs
.
Also we add the derivations of common instances Eq
, Show
, and Enum
. Please note that we did not define duration _
, because if function is not defined on some of BarType
, the compiler running with the -Wall
option will produce the warning. For example, if the line with Bar4Hours
is commented, then the compiler will warn you:
$ ghc BarTypes.hs -Wall [1 of 1] Compiling BarType ( BarTypes.hs, BarTypes.o ) BarTypes.hs:16:1: Warning: Pattern match(es) are non-exhaustive In an equation for `duration': Patterns not matched: Bar4Hours
This allows us to be sure that all...