The official Rust client library for the Kite Connect trading APIs
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
examples
mocks
src
.gitignore
.travis.yml
Cargo.toml
LICENSE
README.md

README.md

kiteconnect-rs

Crates.io Travis

API wrapper for kiteconnect in rust

Docs

https://docs.rs/kiteconnect

Usage

Head on to https://crates.io/crates/kiteconnect

Copy kiteconnect = "<VERSION>" dependency to Cargo.toml file

KiteConnect REST APIs

extern crate kiteconnect;
extern crate serde_json as json;

use kiteconnect::connect::KiteConnect;

fn main() {
    let kiteconnect = KiteConnect::new("<API-KEY>", "<ACCESS-TOKEN>");
    let holdings: json::Value = kiteconnect.holdings().unwrap();
    println!("{:?}", holdings);
}

Kite Ticker Websocket

extern crate kiteconnect;
extern crate serde_json as json;

use kiteconnect::ticker::{KiteTicker, KiteTickerHandler, WebSocketHandler}

#[derive(Debug)]
struct CustomHandler {
    count: u32
}

impl KiteTickerHandler for CustomHandler {
    fn on_open<T>(&mut self, ws: &mut WebSocketHandler<T>)
    where T: KiteTickerHandler {
        // Subscribe to a list of tokens on opening the websocket connection
        ws.subscribe(vec![123456]);
        println!("Fellow on_open callback");
    }
    fn on_ticks<T>(&mut self, ws: &mut WebSocketHandler<T>, tick: Vec<json::Value>)
    where T: KiteTickerHandler {
        println!("{:?}", tick);
        println!("Fellow on_ticks callback");
    }

    fn on_close<T>(&mut self, ws: &mut WebSocketHandler<T>)
    where T: KiteTickerHandler {
        println!("Fellow on_close callback");
    }

    fn on_error<T>(&mut self, ws: &mut WebSocketHandler<T>)
    where T: KiteTickerHandler {
        println!("Fellow on_error callback");
    }
}

fn main() {
    let mut ticker = KiteTicker::new("<API-KEY>", "<ACCESS-TOKEN>");

    let custom_handler = CustomHandler {
        count: 0
    };

    ticker.connect(custom_handler, None);

    loop {}
}

Running Examples

KiteConnect REST API sample

cargo run --example connect_sample

KiteConnect Websocket sample

cargo run --example ticker_sample

TODO

  • Add serializer structs for all kiteconnect returning datastructures
  • Reconnection mechanism