2 people like it.

DSL for Price Patterns (Demo)

Examples that use domain-specific langauge for detecting price patterns. To run the sample, load the previous snippet in TryF#. It opens the sample automatically.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
open Price

let win = ClassifierWindow()
win.Run("MSFT")
win.Stop()

win.Add("Always rising", rising)
win.Add("Mostly rising", regression rising)
 
let upDown = sequenceAnd (regression rising) (regression declining)
win.Add("Up & Down", upDown)

win.Add("Minimum", minimum)
win.Add("Minimum", maximum)
win.Add("Average", average)

let diff = both minimum maximum |> map (fun (l, h) -> h - l)
win.Add("Difference", diff)

let averageInRange (lo, hi) =
  average |> map (fun v -> v > lo && v < hi)
let risingAround20 = 
  bothAnd rising (averageInRange (19.0, 21.0))
win.Add("Rising ~20", risingAround20)

win.Clear()
val win : obj

Full name: Script.win
val upDown : obj

Full name: Script.upDown
val diff : obj

Full name: Script.diff
val averageInRange : lo:'a * hi:'b -> 'c

Full name: Script.averageInRange
val lo : 'a
val hi : 'b
val risingAround20 : obj

Full name: Script.risingAround20

More information

Link:http://fssnip.net/bL
Posted:12 years ago
Author:Tomas Petricek
Tags: dsl