create_order/
create_order.rs1use gateio_rs::{api::spot, http::Credentials, ureq::GateHttpClient};
2use serde_json::Value;
3
4fn main() -> Result<(), Box<gateio_rs::ureq::Error>> {
5 dotenv::dotenv().ok();
6
7 let api_key = std::env::var("GATE_API_KEY").expect("GATE_API_KEY not set");
8 let api_secret = std::env::var("GATE_API_SECRET").expect("GATE_API_SECRET not set");
9 let credentials = Credentials::new(api_key, api_secret);
10
11 let client = GateHttpClient::default().credentials(credentials.clone());
12
13 let req = spot::create_order("DUREV_USDT", "buy", "800")
15 .order_type("limit")
16 .price("0.004")
17 .time_in_force("gtc")
18 .account("spot");
19
20 let resp = client.send(req)?;
27 let body = resp.into_body_str()?;
28 let resp_obj: Value = serde_json::from_str(&body).unwrap();
29 println!("{:?}", resp_obj);
30
31 Ok(())
32}