This repository has been archived by the owner on Aug 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Home
michaelwittig edited this page Mar 19, 2012
·
25 revisions
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();
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();
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();
Learn more about how to subscribe to q kdb+tick environement.