-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudy.wj.Part.2.txt
50 lines (36 loc) · 1.64 KB
/
study.wj.Part.2.txt
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Part 2 studies the subexpressions from Part 1.
// Before you start Part 2, you should have proved that t1,t2,t3,t4,t5 yield same result as wj.
/------------------------------------------------------------------
/ preliminaries...
/------------------------------------------------------------------
/ These are the inputs needed for this section.
Tables used for study: (copy and paste into q console)
q)show t:([]sym:4#`aapl;time:09:30:01 09:30:04 09:30:05 09:30:08;price:100 103 101 99);
q)show q:([] sym:8#`aapl;time:09:30:01+(til 5),7 8 9;ask:101 103 103 104 105 103 102 100;bid:98 99 102 103 103 100 100 99);
/ input into q console, these initialized variables normally passed to wj.
q)w:-2 1+\:t `time;
q)c:`sym`time;
/ note t and q are tables previously defined, above
q)z:(q;(::;`ask);(::;`bid));
/ input into q console, a default parameter of ww function.
q)a:0 1;
/ input into q console, variables from wwX's function body.
q)c,:();
q)k)e:+1_z;
q)k)z:*z;
/------------------------------------------------------------------
// subexpression t1.
/------------------------------------------------------------------
q)k)t1:a+$[#g:-1_c;(c#z)bin@[c#t;*|c;:;]@;z[*c]bin]'w
TBD
/------------------------------------------------------------------
// subexpression t2.
/------------------------------------------------------------------
/ find indices of g#t in g#z then these indices are a max that replaces any 'less then' in t1
/ Then we flip it.
q)k)t2:+$[#g;(g#z)?g#t;0]|/:t1
TBD
/------------------------------------------------------------------
// subexpression t3, t4 and t5
/------------------------------------------------------------------
TBD