https://github.com/databento/databento-rs
The official Rust client library for Databento
https://github.com/databento/databento-rs
async databento historical-data http market-data real-time tcp tick-data
Last synced: 6 months ago
JSON representation
The official Rust client library for Databento
- Host: GitHub
- URL: https://github.com/databento/databento-rs
- Owner: databento
- License: apache-2.0
- Created: 2023-06-13T20:29:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-09T14:14:17.000Z (6 months ago)
- Last Synced: 2025-04-10T02:18:54.142Z (6 months ago)
- Topics: async, databento, historical-data, http, market-data, real-time, tcp, tick-data
- Language: Rust
- Homepage: https://databento.com
- Size: 293 KB
- Stars: 52
- Watchers: 8
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# databento-rs
[](https://github.com/databento/dbn/actions/workflows/build.yaml)
[](https://docs.rs/databento/latest/databento/)
[](./LICENSE)
[](https://crates.io/crates/databento)
[](https://to.dbn.to/slack)The official Rust client library for [Databento](https://databento.com).
The clients support fast and safe streaming of both real-time and historical market data
through similar interfaces.## Installation
To add the crate to an existing project, run the following command:
```sh
cargo add databento
```## Usage
### Live
Real-time and intraday replay is provided through the Live clients.
Here is a simple program that fetches the next ES mini futures trade:```rust
use std::error::Error;use databento::{
dbn::{Dataset, PitSymbolMap, SType, Schema, TradeMsg},
live::Subscription,
LiveClient,
};#[tokio::main]
async fn main() -> Result<(), Box> {
let mut client = LiveClient::builder()
.key_from_env()?
.dataset(Dataset::GlbxMdp3)
.build()
.await?;
client
.subscribe(
Subscription::builder()
.symbols("ES.FUT")
.schema(Schema::Trades)
.stype_in(SType::Parent)
.build(),
)
.await
.unwrap();
client.start().await?;let mut symbol_map = PitSymbolMap::new();
// Get the next trade
while let Some(rec) = client.next_record().await? {
if let Some(trade) = rec.get::() {
let symbol = &symbol_map[trade];
println!("Received trade for {symbol}: {trade:?}");
break;
}
symbol_map.on_record(rec)?;
}
Ok(())
}
```
To run this program, set the `DATABENTO_API_KEY` environment variable with an API key and run `cargo run --example historical`### Historical
Here is a simple program that fetches 10 minutes worth of historical trades for the entire CME Globex market:
```rust
use std::error::Error;use databento::{
dbn::{Schema, TradeMsg},
historical::timeseries::GetRangeParams,
HistoricalClient, Symbols,
};
use time::macros::{date, datetime};#[tokio::main]
async fn main() -> Result<(), Box> {
let mut client = HistoricalClient::builder().key_from_env()?.build()?;
let mut decoder = client
.timeseries()
.get_range(
&GetRangeParams::builder()
.dataset("GLBX.MDP3")
.date_time_range((
datetime!(2022-06-10 14:30 UTC),
datetime!(2022-06-10 14:40 UTC),
))
.symbols(Symbols::All)
.schema(Schema::Trades)
.build(),
)
.await?;
let symbol_map = decoder
.metadata()
.symbol_map_for_date(date!(2022 - 06 - 10))?;
while let Some(trade) = decoder.decode_record::().await? {
let symbol = &symbol_map[trade];
println!("Received trade for {symbol}: {trade:?}");
}
Ok(())
}
```To run this program, set the `DATABENTO_API_KEY` environment variable with an API key and run `cargo bin --example live`.
## Documentation
You can find more detailed examples and the full API documentation on the [Databento docs site](https://databento.com/docs/quickstart?historical=rust&live=rust).
## License
Distributed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0.html).