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.

README.md 697B

1234567891011121314151617181920212223242526272829303132
  1. # markets
  2. Market-specific primitives in Rust. WIP.
  3. ```rust
  4. use markets::crypto::{Exchange, Currency, Ticker, Side};
  5. #[derive(Serialize, Deserialize)]
  6. pub struct Trade {
  7. pub exch: Exchange, // 4-character symbol (bmex, btfx, etc.)
  8. pub ticker: Ticker, // i.e. btc/usd
  9. pub side: Side, // Bid/Ask
  10. pub price: f64,
  11. pub size: f64,
  12. pub time: u64, // unix nanos
  13. }
  14. let json = r#"
  15. {
  16. "exch": "bmex",
  17. "ticker": "btc_usd",
  18. "side": "bid",
  19. "price": 7890.12345,
  20. "size": 12.345,
  21. "time": 1584600884388889367
  22. }
  23. "#;
  24. let trade: Trade = serde_json::from_str(&json).unwrap();
  25. assert_eq!(trade.ticker.base, Currency::btc);
  26. ```