Crates.io | rsq |
lib.rs | rsq |
version | 0.1.1 |
source | src |
created_at | 2021-03-27 01:04:15.276389 |
updated_at | 2021-04-02 00:26:52.690067 |
description | A native rust interface for q/kdb+ |
homepage | |
repository | |
max_upload_size | |
id | 374031 |
size | 34,138 |
Connect to a kdb+ service using native rust. Provides support for kdb+ connectivity using uncompressed serialization and deserialization, following the Kx Documentation.
rsq::KObj
to kdb+ readable format i.e. (`TSLA;`Q;653.20;200)
Since rsq
is written natively in Rust, it is capable of running
on any stable version of the language. This comes at the cost of
not using compression/decompression, which is only possible using the
proprietary Kx provided c.so
. Therefore, this library is primarily
for applications where compression is not needed. This would include
feedhandlers, realtime consumers, etc. as kdb+ only compresses
under certain conditions
Put this in your Cargo.toml
:
[dependencies]
rsq = "0.1"
The following code will subscribe to a vanilla tickerplant
for all symbols and print the realtime data to stdout
using the basic println!
macro
use rsq::{Kdb, KObj, KType};
let mut kdb = Kdb::new("localhost", 5001, "username", "password");
kdb.send_async(&KObj::List(vec![
KObj::Atom(KType::Symbol(".u.sub".to_string())),
KObj::Atom(KType::Symbol("trade".to_string())),
KObj::Atom(KType::Symbol("".to_string()))
])).unwrap();
loop {
println!("{}",kdb.read());
};
Output
(`upd;`trade;flip (`time;`sym;`price;`size)!((enlist 20:57:00.000);(enlist `TSLA);(enlist 653.1f);(enlist 50j)))
(`upd;`trade;flip (`time;`sym;`price;`size)!((enlist 20:59:00.000);(enlist `TSLA);(enlist 653.2f);(enlist 30j)))
(`upd;`trade;flip (`time;`sym;`price;`size)!((enlist 20:59:30.000);(enlist `TSLA);(enlist 653.1f);(enlist 100j)))