Skip to content
This repository has been archived by the owner on Aug 8, 2020. It is now read-only.
michaelwittig edited this page Mar 19, 2012 · 25 revisions

Home

Hej folks! Again and again we have to interact with a kdb+ and kdb+tick. The guys from KX Systems provide us c.java to interact with their product. You might experienced that c.java is not really using an object oriented style, so we started to write our own wrapper and called it Q Connector. Fell free to create Issues if something is missing for you. And now: have fun:)

Learn more about the Features.

Encapsulation

You do not need to be a Q god to use this library! We encapsulate all the q stuff for you! It's just simple java.

Select select = trade.select()
	.column(size.sum())
	.column(price.avg())
	.group(sym.group())
	.group(time.xbar(LongValue.from(60000L)))
	.filter(sym.filterIn(SymbolValue.froms(new String[] {"AAA", "BBB"})))
	.order(Direction.descending, time)
	.build();

Schema definition

Your schema is defined by code not by text! You get easy refactoring and lesser typos for free:)

Learn more about how to define your schema with a few lines of code.

final MyTable table = MyTable.get();

Synchronous Access

Queries using select

Learn more about how to create a q query.

MyTable table = MyTable.get();

// create select
Select select = table.select()
	.column(table.size().sum())
	.column(table.price().avg())
	.group(table.sym().group())
	.filter(table.sym().filterIn(SymbolValue.froms(new String[] {"AAA", "BBB"})))
	.order(Direction.descending, table.time())
	.build();
System.out.println("Q: " + select.toQ());

// connect to kdb+
KXConnectorSync kx = KXConnectorFactory.create("localhost", 5011);
kx.connect();

// execute select and print the result
final Result result = kx.select(select);
for (final TableRow row : table.read(result)) {
	System.out.println(row.get(table.time()));
	System.out.println(row.get(table.sym()));
	System.out.println(row.get(table.price()));
	System.out.println(row.get(table.size()));
}

// close connection
kx.disconnect();

Asynchronous Access

Subscription using .u.sub[]

Learn more about how to subscribe to q kdb+tick environement.

Clone this wiki locally