Request data from Kx Systems, Inc. kdb+ databases
d = fetch(k,ksql)
d = fetch(k,ksql,p1)
d = fetch(k,ksql,p1,p2)
d = fetch(k,ksql,p1,p2,p3)
k |
Kx
Systems®, Inc. kdb+ connection object created with |
ksql |
The Kx Systems, Inc. kdb+ command. |
p1,p2,p3 |
Input parameters for the |
d = fetch(k,ksql)
returns data from a Kx
Systems, Inc. kdb+ database in a MATLAB® structure where k
is the Kx
Systems, Inc. kdb+ object and ksql
is the Kx
Systems, Inc. kdb+ command. ksql
can be any valid kdb+ command. The
output of the fetch
function is any data resulting from the command
specified in ksql
.
d = fetch(k,ksql,p1)
executes the command specified in
ksql
with one input parameter, and returns the data from this
command.
d = fetch(k,ksql,p1,p2)
executes the command with two input
parameters.
d = fetch(k,ksql,p1,p2,p3)
executes the command with three input
parameters.
Run the following command from a DOS prompt to specify the port number
5001
:
q tradedata.q -p 5001
Connect to a Kx
Systems, Inc. server using IP address 'localhost'
and port number
5001
:
k = kx('localhost',5001);
Retrieve data using the command 'select from trade'
:
d = fetch(k,'select from trade'); d = sec: {5000x1 cell} price: [5000x1 double] volume: [5000x1 int32] exchange: [5000x1 double] date: [5000x1 double]
Retrieve data, passing an input parameter 'ACME'
to the command
'totalvolume'
:
d = fetch(k,'totalvolume','ACME'); d = volume: [1253x1 int32]
This is the total trading volume for the security ACME
in the table
trade
. The function totalvolume
is defined in the
sample Kx
Systems, Inc. kdb+ file, tradedata.q
.