1 FinDEL A Language-Based Approach to Financial Analysis Principal Investigator: A/Prof Khoo Siau...

Post on 11-Jan-2016

216 views 0 download

Transcript of 1 FinDEL A Language-Based Approach to Financial Analysis Principal Investigator: A/Prof Khoo Siau...

1

FinDELA Language-Based

Approach to Financial Analysis

Principal Investigator: A/Prof Khoo Siau ChengCo-Principal Investigator: A/Prof Chin Wei Ngan

School of Computing

External Collaborator: Professor Ng Kah HwaCentre of Financial Engineering

Contact: Khoosc@comp.nus.edu.sg

2

Temporal Domain

Time-series information are expressed using patterns

Financial Forecasting

Medical Informatics

Weather Forecasting

etc.

3

Financial Patterns

sell

sell

Head & ShoulderFlag

More on stock chart patterns: http://www.incrediblecharts.com/technical/chart_patterns.htm

Technical Analysis

4

Medical Patterns

Hemoglobin

Week 1 Week 2 Week 3 Week 4

Anemia Anemia Anemia Anemia

Weekly Repeating Anemia

buy Vitamin

B12

Abstracting Patterns of Anemia level from series of hemoglobin tests

More on medical patterns: http://smi-web.stanford.edu/projects/resume/

5

Control Chart Patterns

More on process control chart patterns: http://deming.eng.clemson.edu/pub/tutorials/qctools/ccmain1.htm

System out of control

6

Problem

Extracting useful information/patterns from temporal domain can be non-trivial:

The “usefulness” can be user-dependent,intuitively simple, but hard to specify.

Extracting information for explorative purpose requires sophisticated IT skill.

7

Opportunities (User Perspective)

A user-centered technology can bring the power ofexploratory information extraction to domain expertsand users

The technology should speak the same jargon as the domain experts.

The technology should emphasize on problemdescription rather than solution prescription.

8

Opportunities (Technology Perspective)

Technology can be reused over a broad rangeof temporal domains:

financial forecastingmedical informativeweather forecasting

Unified base that can easily accommodate the advancement in technology

neural networkpattern recognitiondata mining

9

Research Objective of FinDEL

Using programming language technology to providea unified framework for

Supporting user-centered tools for extractinginformation from financial domains

Ensuring the adaptability of existing domainsolutions to technology advances.

10

Roles of a Language

Language Constructs

Domain Experts

Algorithms Compilers

Users

11

Why is Language Important?

It defines a representation (temporal abstract) that is:

Abstract enough to capture user-defined patterns

Concrete enough for numerous techniques tomanipulate

It defines a set of terminologies that is:

Abstract enough to match domain jargons

Accurate enough to ensure meaningful manipulations

12

What Kind of Language is Good?

Simple

Elegant

Extensible

Manipulative

Embedded Language

13

Business OpportunitiesWe have not seen any commercial products that are as expressive and versatile as what we have suggested.

Some of the available products:

Chart Pattern Recognition plugin for MetaStock

Patterns (http://www.marketsonline.com/software/patterns.htm)

Bull’s-Eye Broker (http://www.archeranalysis.com/beb/index.html)

Please refer to slide 39 for more information

14

Research Collaboration

We need domain experts to help us in defining the problem, and in perfecting the techniques and solutions.

Financial experts Researchers from the Centre of Financial Engineering

15

A Prototype of FinDEL

The following slides (16 – 38)Demonstrates how financial chart patterns can be effectively specified and manipulated by an elegant, concise, and yet “high-level” programming language.

Technical detail is available the paper “Charting Patterns on Price History”,downloadable in http://www.comp.nus.edu.sg/~khoosc/research.html

16

Outline Introduction Specifying Technical Indicators Specifying Patterns

Simple Patterns Composite Patterns

Pattern Definitions Conclusion

17

Design Objectives of aChart Pattern Language Define patterns with the help of

constraints and technical indicators. The language should be “high-level ”. It should be complete enough to

specify all the well-known patterns. Pattern definitions should be reusable

and composable.

18

Outline Introduction Specifying Technical Indicators Specifying Patterns

Simple Patterns Composite Patterns

Pattern Definitions Conclusion

19

Technical Indicator A mathematical formula that

quantifies the market behavior. It is a time-series data. Basics indicators:

Low, high, close, open of a dayTransaction volume of a day open, low, high, close, volume

20

Using Technical Indicators

4.94.94.54.64.34.34.54.33.83.63.94.14.04.44.7High

low

Day

4.54.44.14.24.24.14.03.93.63.53.73.93.84.04.5

14131211109876543210

low 3 = Just 3.9 high 10 = Just 4.3

low 15 = Nothing

21

Composing Indicators

tPrice :: Indicator PricetPrice = (high + low + close) / 3.0

Typical Price:

(#) operator: (high # 10) t = high (t-10)

avgOfLast3 = (high#2 + high#1 + high)/3.0

tprice t gives value of typical price for t

Indexing into price History:

22

Moving Average Denotes the trend of the market. “n days moving Average” is

calculated by averaging the prices of last n days.

mvAvgt = (hight+hight-1+hight-2+…+hight-n+1)/n

23

Example

4.94.94.54.64.34.34.54.33.83.63.94.14.04.44.7High

low

Day

4.54.44.14.24.24.14.03.93.63.53.73.93.84.04.5

14131211109876543210

movingAvg 10 11 = sum(…)/10 = Just 4.15

movingAvg 10 8 = Nothing

movingAvg n = (high + high#1 + high#2 + …. + high#n)/n

“10 days moving average” is, movingAvg 10“10 days moving average” for 11th day is, movingAvg 10

11

24

Microsoft stock

Moving average

price cross below mvAvg

SELL

price cross above mvAvg

BUY

25

Buy and Sell signals buy = close `riseAbove` (movingAvg 14)sell = close `fallBelow` (movingAvg 14)

f1 `riseAbove` f2 = (f1 > f2) && (f1 # 1) < (f2 # 1)f1 `fallBelow` f2 = (f1 < f2) && (f1 # 1) > (f2 # 1)

26

Outline Introduction Specifying Technical Indicators Specifying Patterns

Simple Patterns Composite Patterns

Pattern Definitions Conclusion

27

Patterns Simple Patterns

Bar, Up, Down, Horizontal, Support Line, Resistance Line

28

Landmarks & sub-Components

Landmarks are critical points of a pattern.

lms :: Patt -> [Bar]

sub :: Patt -> [Patt]

returns the landmarks for e.g. a, b, c, d, e, f, g

returns the sub-components for e.g. ab,

bc, cd, de, ef, fg

29

Operations on Patterns Imposing constraints Composing horizontally Overlaying patterns

30

∞ : Imposing Constraints

∞ :: Pattern -> Constraints -> Pattern

in [ low t > low (t-1), high t < high (t-1)

]

insideDay = bar ∞ u. let [t] = lms u

Inside day

t

31

Inside Days

Yesterday was an

inside-day

Buy 1Million stocks

32

Fuzzy ConstraintsEg : ‘bigDown’ is a primitive down pattern, with

the decrease in price being usually greater than 10 units.

a

b

bigDown = down ∞ u. let [a,b] = lms uin [ high a – low b >F 10 ]

<F, >F , =F are the fuzzy comparison operators

33

Followed-By composition

p1 p2

hill = (up » down) ∞ h . let [a,b,c] = lms h

in [low a =F low c]

a c

b

» :: Pattern -> Pattern -> Pattern

34

Head & Shoulderhead_shoulder = hill » hill » hill ∞ hs. let [a,b,c,d,e,f,g] = lms hs in [

high d > high b, high d > high f, high b =F high f

]

35

Overlay Composition

s

p

◇ :: Pattern -> Pattern ->Pattern

36

Overlay Composition

rect = res ◇ sprt ∞ u. let [r,s] = sub u [m,n] = lms r in [slope r =F slope s, breakout r n]

r

s

breakout

37

Diamonddiamond = ((res » res) ◇ (sprt » sprt)) ∞ u. let [rl,sl] = sub u

[m,n] = sub rl [p,q] = sub sl [c,d] = lms q in [diverge m p, converge n q, breakout q d]

38

Outline Introduction Specifying Technical Indicators Specifying Patterns

Simple Patterns Composite Patterns Making Patterns Reusable

Conclusion

39

Related Products Most popular one is,

John Murphy’s Chart Pattern Recognition plugin for MetaStock (http://www.murphymorris.com/products/cpr.html)

Others, Patterns

(http://www.marketsonline.com/software/patterns.htm) Bull’s-Eye Broker

(http://www.archeranalysis.com/beb/index.html) Fxtrek.com

(http://www.fxtrek.com/universityEN/ai/ai_stock_trading01.asp) http://www.pitstock.com/support/index.html http://www.tarnsoft.com/headandshoulder.html

40

Business Opportunities

We believe our solution is

unique in the marketplace

technically advantageous

more expressive than existing tools

41

Research Opportunities Efficient implementation From graphical patterns to

language Pattern Mining Similarity Pattern matching Other domain applications

42

Related Mini-ProjectsUser-Centered

Tech: GUI Design Predictive Power

of Technical Patterns

Trading Strategy

Algorithmic Tech: Analyzing use of

patterns Optimizing use of

pattern Discovery of

Patterns Refinement of

Patterns

43

Predictive Power of Patterns To determine the ability of a

pattern in determining the trend of the market performance

Tools required: Statistical testing Adjusting patterns and data for such

test

44

Trading Strategy To enable user to make trading

decision Two phases:

On historical data Real-time data

Tools required: Extended CPL with trading operators

45

Analyzing use of Patterns A type system to ensure the

correct use of patterns, and to identify potential optimization

Tools required: Type-based/Constrain-based analysis Possibly Cameleon system

46

Optimizing use of Patterns To improve the efficiency of

pattern matching Tools required:

Constraint solving Meta-Haskell for the purpose of meta-

programming

47

Discovery of Patterns To discover profitable patterns

automatically Tools required:

Genetic programming Neural network Machine learning Statistical testing

48

Refinement of Patterns To refine a pattern so as to

increase its predictive power Tools required:

Machine learning Statistical testing

49

Projects in the future: Inclusion of Financial Derivatives

Futures and Options Running FinDEL in different platform

.NET platform Compiled to FPGA Mobile Computing

Application to other temporal domains Medical Clinic tests

50

Thank you

Contact: Khoosc@comp.nus.edu.sg