forked from mortensorensen/QInteractiveBrokers
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ib.q
31 lines (22 loc) · 1.01 KB
/
ib.q
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
/////////////// Utilities /////////////////
\d .ib
u.o:{-1 string[.z.Z]," ",x;} / output timestamped x string
u.zu:{"z"$-10957+x%8.64e4} / kdb+ datetime from unix
u.fmt:{ssr[ssr[;"\"";""] .j.j x;",";", "]} / format
u.oe:{u.o string[x],":",u.fmt y}
\d .
/////////////// End of Utilities ////////
.ib,:(hsym[x.so] 2:(`LoadLibrary;1))` / requests
.ib.cb:()!(); / callbacks function!code
\d .ib
cb[`unknown]:{[fname;args] / unknown callback handler
u.o" unknown function ",string[fname], / print fname and args
", args:\n", args;
}
onrecv:{[fname;args] / on receive call fname
f:$[null f:cb fname;cb`unknown;f];
a:(::;enlist) type[args] in 0 10 98 99h;
value enlist[f],a args}
reg:{[fname;code] @[`.ib.cb;fname;:;code];} / register callback fname
dreg:{[fname] cb _::fname;} / deregister callback fname
\d .