Expand description
API Clients (REST, WebSocket) for Tardis.dev.
tardis-rs
allows you to easily replay historical market data and stream live market data through
Tardis.dev’s API.
⚠️ NOTE: The feature machine
must be enabled in order to interact with Tardis Machine Server.
§Table of contents
§Quickstart
Cargo.toml
[package]
name = "example"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tardis-rs = { version = "0.1", features = ["machine"] }
main.rs
ⓘ
use tardis_rs::{Exchange, machine::{Client, Message}};
use chrono::NaiveDate;
#[tokio::main]
async function main() {
let client = Client::new(std::env::var("TARDIS_MACHINE_WS_URL").unwrap());
let stream = client
.replay_normalized(vec![ReplayNormalizedRequestOptions {
exchange: Exchange::Bybit,
symbols: Some(vec!["BTCUSDT".to_string()]),
from: NaiveDate::from_ymd_opt(2022, 10, 1).unwrap(),
to: NaiveDate::from_ymd_opt(2022, 10, 2).unwrap(),
data_types: vec!["trade_bar_60m".to_string()],
with_disconnect_messages: None,
}])
.await
.unwrap();
pin_mut!(stream);
while let Some(msg) = stream.next().await {
println!("Received trade bar: {:?}", message);
}
}
§Crate features
To avoid compiling unused dependencies, tardis-rs gates certain features, some of which are disabled by default:
Feature | Description |
---|---|
machine | Enables the client for Tardis Machine Server. |
Modules§
- machine
- The API Client and types specific to Tardis Machine Server.
Structs§
- Client
- The client for interacting with Tardis API.
- Instrument
Changes - The changes info returned by exchanges API. Note that is meant to be accurate and complete only for contractMultiplier values (we monitor exchanges announcements for that), rest of the changes are done on best effort basis and not always complete
- Instrument
Info - The metadata of a particular instrument, see https://docs.tardis.dev/api/instruments-metadata-api.
Enums§
- Error
- The error that could happen while sending / receiving requests.
- Exchange
- Supported exchanges on Tardis Visit https://api.tardis.dev/v1/exchanges to get the list of all supported exchanges that historical market data is available for.
- Option
Type - The type of an option symbol eg. Call, Put
- Response
- The response format for Tardis.dev API.
- Symbol
Type - The type of the symbol eg. Spot, Perpetual, Future, Option.
Type Aliases§
- Result
- A helper Result type.