You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jonathan Strong 984c276f4f derive Debug on iso::Market and also add serde(rename_all = "lowercase") attribute 4 years ago
src derive Debug on iso::Market and also add serde(rename_all = "lowercase") attribute 4 years ago
.gitignore initial commit 4 years ago
Cargo.toml derive Debug on iso::Market and also add serde(rename_all = "lowercase") attribute 4 years ago
LICENSE spruce things up before publishing to jstrong-dev registry 4 years ago
README.md spruce things up before publishing to jstrong-dev registry 4 years ago

README.md

markets

Market-specific primitives in Rust. WIP.

use markets::crypto::{Exchange, Currency, Ticker, Side};

#[derive(Serialize, Deserialize)]
pub struct Trade {
    pub exch: Exchange, // 4-character symbol (bmex, btfx, etc.)
    pub ticker: Ticker, // i.e. btc/usd
    pub side: Side,     // Bid/Ask
    pub price: f64,
    pub size: f64,
    pub time: u64,      // unix nanos
}

let json = r#"
    {
        "exch": "bmex",
        "ticker": "btc_usd",
        "side": "bid",
        "price": 7890.12345,
        "size": 12.345,
        "time": 1584600884388889367
    }
"#;

let trade: Trade = serde_json::from_str(&json).unwrap();

assert_eq!(trade.ticker.base, Currency::btc);