diff --git a/Qtests.csv b/Qtests.csv index 0fb656b..26f95e4 100644 --- a/Qtests.csv +++ b/Qtests.csv @@ -13,4 +13,4 @@ til 10,⍳10,Int64 List `a`b`c!(1 2;3 5;7 11),"(,¨'abc')⍪⍉↑(1 2)(3 5)(7 11)",Dictionary flip `a`b`c!(1 2;3 5;7 11),"(,¨'abc')⍪⍉↑(1 2)(3 5)(7 11)",Table select from p where weight=17,(ptable[;3]∊'weight' 17)⌿ptable,Keyed Table -"select from trade where date=last date, sym=`AMD",tradeq1,Table +"select from trade where sym=`AMD",(trade[;2]∊'sym' 'AMD')⌿trade,Table diff --git a/README.md b/README.md index 9279a5b..8e1e408 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # qconnect An interface from Dyalog APL to Q. To use it, start q specifying -a port to listen on: +a port to listen on and, if you want to run the unit tests, loading th UTtest.q script: ``` - q -p 5000 + q qconnect\UTtest.q -p 5000 ``` Then from APL (replacing "qconnect" below with folder name which you have cloned or unzipped this repository to): @@ -12,9 +12,8 @@ you have cloned or unzipped this repository to): )copy conga DRC q←⎕NEW Q ('127.0.0.1' 5000 'user') q.x 'sum til 10' - ⍝ Now run unit tests (some will fail due to missing tables) Qtests←⎕CSV 'qconnect/QTests.csv' ]load qconnect/UT UT 0 ``` -Prerequisites: Only tested with version 16.0, but should work with Dyalog version 13.1 or later. The use of ⎕CSV above requires Dyalog version 15.0 or later. +Prerequisites: Only tested with Dyalog versions 16.0 & 17.0, but should work with Dyalog version 13.1 or later. The use of ⎕CSV above requires Dyalog version 15.0 or later. diff --git a/UT.dyalog b/UT.dyalog index 50e9354..cd09114 100644 --- a/UT.dyalog +++ b/UT.dyalog @@ -1,4 +1,4 @@ - failed←UT debug;q;⎕IO;shouldbe;name;aplx;qx;OK;start;expected;got + failed←UT debug;q;⎕IO;shouldbe;name;aplx;qx;OK;start;expected;got;trade;ptable ⍝ if debug = 1, stop on error ⎕IO←0 @@ -6,9 +6,12 @@ start←2⊃⎕AI q←⎕NEW Q('127.0.0.1' 5000 'mkrom') ⍝ Connect to Q - {}q.x'\l sp.q' ⍝ Load Suppliers and Parts - :Trap 11 ⍝ Will fail if TAQ already loaded - {}q.x'\l db/taq' ⍝ Load Trades and Quotes + + :Trap 0 + ptable←q.x'p' + trade←q.x'trade' + :Else + 'Unable to load p and trade - did you run UTdata.q?'⎕SIGNAL 11 :EndTrap failed←⍬ diff --git a/UTdata.q b/UTdata.q new file mode 100644 index 0000000..a1d7f50 --- /dev/null +++ b/UTdata.q @@ -0,0 +1,12 @@ +p:([p:`p1`p2`p3`p4`p5`p6] + name:`nut`bolt`screw`screw`cam`cog; + color:`red`green`blue`red`blue`red; + weight:12 17 17 14 12 19; + city:`london`paris`rome`london`paris`london); + + trade:asc([]date:10?.z.d; + time:10?.z.t; + sym:10?`AMD`AAPL`GOOG; + price:10?1000f; + size:10?100; + ex:10?"AB")