tastyworks-rs

Unofficial Tastyworks API for Rust.
Example
use tastyworks::Context;
use num_traits::ToPrimitive;
#[tokio::main]
async fn main() {
let token = "your-token-here";
let context = Context::from_token(token);
let accounts = tastyworks::accounts(&context)
.await.expect("Failed to fetch accounts");
let account = accounts.first().expect("No accounts found");
let positions = tastyworks::positions(account, &context)
.await.expect("Failed to fetch positions");
println!("Your active positions:");
for position in &positions {
let signed_quantity = position.signed_quantity();
println!(
"{:>10} x {}",
if signed_quantity.is_integer() {
signed_quantity.to_integer().to_string()
} else {
signed_quantity.to_f64().unwrap().to_string()
},
position.symbol
);
}
}
API Token
Your API token can be found by logging in to https://trade.tastyworks.com/ while your browser developer tools are open on the Network tab.
Select one of the requests made to https://api.tastyworks.com/ and in the Request Headers section that appears, find the Authorization header item.
The value of this item can be used as your token in this API.