use coinbase_advanced::models::ListFillsParams;
use coinbase_advanced::{Credentials, RestClient};
#[tokio::main]
async fn main() -> coinbase_advanced::Result<()> {
tracing_subscriber::fmt::init();
let credentials = Credentials::from_env()?;
let client = RestClient::builder()
.credentials(credentials)
.sandbox(true) .build()?;
println!("Connected to Coinbase (sandbox mode)");
println!("\n--- Open Orders ---");
let response = client.orders().list_all().await?;
if response.orders.is_empty() {
println!("No open orders");
} else {
for order in &response.orders {
println!(
"{}: {} {} @ {:?} ({:?})",
order.order_id,
order.side,
order.product_id,
order.created_time.as_deref().unwrap_or("unknown"),
order.status
);
}
}
println!("\n--- Recent Fills ---");
let fills_response = client.orders().list_fills(ListFillsParams::default()).await?;
for fill in fills_response.fills.iter().take(5) {
println!(
"{}: {} {} @ {} (fee: {})",
fill.trade_id,
fill.product_id,
fill.size,
fill.price,
fill.commission
);
}
println!("\n--- Order Builders Available ---");
println!("client.market_order() - Market IOC order");
println!("client.limit_order_gtc() - Limit Good-Til-Cancelled");
println!("client.limit_order_gtd() - Limit Good-Til-Date");
println!("client.stop_limit_order_gtc() - Stop-Limit GTC");
println!("\nExample usage:");
println!(" client.market_order()");
println!(" .buy(\"BTC-USD\")");
println!(" .quote_size(\"100.00\") // Buy $100 worth");
println!(" .send().await?;");
println!("\nDone!");
Ok(())
}