Skip to content

Commit

Permalink
new init mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrizian committed Apr 22, 2019
1 parent b472f8d commit a0ad577
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 49 deletions.
8 changes: 8 additions & 0 deletions .ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[paper]
port: 4002

[DEFAULT]
host: 127.0.0.1
so: ./bin/qib.0.0.2
load: ib.q
cast: `host`so`port!"SSJ"
6 changes: 0 additions & 6 deletions .qib

This file was deleted.

31 changes: 0 additions & 31 deletions cfg.q

This file was deleted.

2 changes: 1 addition & 1 deletion ib.q
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ u.oe:{u.o string[x],":",u.fmt y}
/////////////// End of Utilities ////////


.ib,:(`:./bin/qib.0.0.2 2:(`LoadLibrary;1))` / requests
.ib,:(hsym[x.so] 2:(`LoadLibrary;1))` / requests
.ib.cb:()!(); / callbacks function!code

\d .ib
Expand Down
19 changes: 19 additions & 0 deletions ini.q
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/ q ini.q [initfile] [section]
.utl.require"qutil/opts.q"
.utl.require"qutil/config_parse.q"

.utl.addArg["S";".ini";0; / [initfile] cmdline arg
(`x;{.utl.parseConfig hsym x})]
.utl.addArg["*";"";0; / [section] cmdline arg: selects section of file or first section
{.[`x;();@;] $[count x;x;first key get `x]}]
.utl.parseArgs[] / parse declarations above

x:{ / cast: keys as symbols, values according to "cast" key
`cast _x!$[99h=type z;"*"^z x;"*"]$y
}[`$key x;value x;eval parse x"cast"]

if[count x`load; / load files, if provided via "load" key
{system"l ",x}each " " vs x`load];


/ output: global var x holding a dictionary of typed program parameters
2 changes: 0 additions & 2 deletions init.q

This file was deleted.

File renamed without changes.
16 changes: 7 additions & 9 deletions test/test_qib.q
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
\l test/fixtures/timer.q
\l test/fixtures/ty.q
\l tree.q
\l test/fixtures/tree.q

paperCfg:{
.tst.mock[`.utl.arg.posArgs;()];
.tst.mock[`.utl.arg.boolOpts;()];
.tst.mock[`.utl.arg.regOpts;()];
.tst.mock[`.utl.arg.regDefOpts;()];
.tst.mock[`.utl.arg.args ; (
"--cfg";".qib";"--profile";"paper")];
system"l cfg.q";
.tst.mock[`.utl.arg.args ; (".ini";"paper")];
system"l ini.q";
}

mockCallbacks:{
Expand Down Expand Up @@ -62,16 +61,15 @@ mockCallbacks[];
before {
};
should["support configuration from file"]{
Cfg.host mustmatch `127.0.0.1;
Cfg.port mustmatch 4002;
Cfg.profile mustmatch `paper;
x.host mustmatch `127.0.0.1;
x.port mustmatch 4002;
};
should["start disconnected"]{
0b musteq .ib.isConnected[];
};
should["connect and disconnect successfully"]{
must[;"connect"]
.ib.connect[ Cfg.host;Cfg.port;1i];
.ib.connect[x.host;x.port;1i];
mustReturn[`connectAck];
.ib.isConnected[] must "show connected status";
-14 -19 -11h mustmatch type each
Expand Down Expand Up @@ -127,7 +125,7 @@ mockCallbacks[];
mustReturn[`symbolSamples];
};
should["get exchange source of the quote"]{
.ib.reqSmartComponents[1;"a6"];
.ib.reqSmartComponents[1;"a6"]; / only testable when exchange is open
mustReturn[`smartComponents];
};
should["request bond details"]{
Expand Down

0 comments on commit a0ad577

Please sign in to comment.