Stock time series pattern matching: Template-based vs. rule-based approaches