pub struct CreatePriceOrder {
pub trigger: SpotPriceTrigger,
pub put: SpotPricePutOrder,
pub market: String,
pub x_gate_exp_time: Option<u128>,
pub credentials: Option<Credentials>,
}Expand description
§Create a price-triggered order
A price-triggered order (also known as conditional order) will not enter the order book until the trigger condition is met. Once triggered, it will attempt to place a limit order at the preset price and amount.
§Important Notes:
- The conditional order does not occupy your balance until it is triggered
- Make sure to set aside enough balance for this order
- A price condition order can only be triggered one time
- When using “<=”, the trigger price should be less than the current market price
- When using “>=”, the trigger price should be greater than the current market price
- Only limit orders are supported as the triggered order type
§Status Values:
- “open” : Waiting to trigger
- “cancelled” : Manually cancelled
- “finish” : Successfully executed
- “failed” : Failed to execute
- “expired” : Expired
Fields§
§trigger: SpotPriceTriggerTrigger conditions for the order
put: SpotPricePutOrderOrder details to execute when triggered
market: StringCurrency pair for the order
x_gate_exp_time: Option<u128>Request expiration time in milliseconds
credentials: Option<Credentials>API credentials for authentication
Implementations§
Source§impl CreatePriceOrder
impl CreatePriceOrder
Sourcepub fn new(
market: &str,
trigger_price: &str,
trigger_rule: &str,
order_side: &str,
order_price: &str,
order_amount: &str,
) -> Self
pub fn new( market: &str, trigger_price: &str, trigger_rule: &str, order_side: &str, order_price: &str, order_amount: &str, ) -> Self
Create a new price-triggered order request
Sourcepub fn trigger(self, trigger: SpotPriceTrigger) -> Self
pub fn trigger(self, trigger: SpotPriceTrigger) -> Self
Set the trigger conditions
Sourcepub fn put(self, put: SpotPricePutOrder) -> Self
pub fn put(self, put: SpotPricePutOrder) -> Self
Set the order details to execute when triggered
Sourcepub fn trigger_expiration(self, expiration: i64) -> Self
pub fn trigger_expiration(self, expiration: i64) -> Self
Set the trigger expiration time in seconds
Examples found in repository?
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 // Create a price-triggered order
14 // This example creates a buy order that will trigger when BTC price goes above $50,000
15 // When triggered, it will place a limit buy order for 0.001 BTC at $49,900
16 let req = spot::create_price_order(
17 "BTC_USDT", // market (currency pair)
18 "120000", // trigger_price
19 ">=", // trigger_rule (trigger when price >= $50,000)
20 "buy", // order_side
21 "49900", // order_price (limit price when triggered)
22 "0.001", // order_amount
23 )
24 .account("normal") // use normal spot account
25 .time_in_force("gtc") // good till cancelled
26 .trigger_expiration(86400); // expire after 24 hours if not triggered
27
28 println!("Sending price-triggered order request...");
29
30 let resp = client.send(req)?;
31 let body = resp.into_body_str()?;
32 let resp_obj: Value = serde_json::from_str(&body).unwrap();
33
34 println!("Response: {:#}", resp_obj);
35
36 Ok(())
37}Sourcepub fn account(self, account: &str) -> Self
pub fn account(self, account: &str) -> Self
Set the trading account type for the triggered order
Examples found in repository?
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 // Create a price-triggered order
14 // This example creates a buy order that will trigger when BTC price goes above $50,000
15 // When triggered, it will place a limit buy order for 0.001 BTC at $49,900
16 let req = spot::create_price_order(
17 "BTC_USDT", // market (currency pair)
18 "120000", // trigger_price
19 ">=", // trigger_rule (trigger when price >= $50,000)
20 "buy", // order_side
21 "49900", // order_price (limit price when triggered)
22 "0.001", // order_amount
23 )
24 .account("normal") // use normal spot account
25 .time_in_force("gtc") // good till cancelled
26 .trigger_expiration(86400); // expire after 24 hours if not triggered
27
28 println!("Sending price-triggered order request...");
29
30 let resp = client.send(req)?;
31 let body = resp.into_body_str()?;
32 let resp_obj: Value = serde_json::from_str(&body).unwrap();
33
34 println!("Response: {:#}", resp_obj);
35
36 Ok(())
37}Sourcepub fn time_in_force(self, time_in_force: &str) -> Self
pub fn time_in_force(self, time_in_force: &str) -> Self
Set the time in force for the triggered order
Examples found in repository?
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 // Create a price-triggered order
14 // This example creates a buy order that will trigger when BTC price goes above $50,000
15 // When triggered, it will place a limit buy order for 0.001 BTC at $49,900
16 let req = spot::create_price_order(
17 "BTC_USDT", // market (currency pair)
18 "120000", // trigger_price
19 ">=", // trigger_rule (trigger when price >= $50,000)
20 "buy", // order_side
21 "49900", // order_price (limit price when triggered)
22 "0.001", // order_amount
23 )
24 .account("normal") // use normal spot account
25 .time_in_force("gtc") // good till cancelled
26 .trigger_expiration(86400); // expire after 24 hours if not triggered
27
28 println!("Sending price-triggered order request...");
29
30 let resp = client.send(req)?;
31 let body = resp.into_body_str()?;
32 let resp_obj: Value = serde_json::from_str(&body).unwrap();
33
34 println!("Response: {:#}", resp_obj);
35
36 Ok(())
37}Sourcepub fn x_gate_exp_time(self, x_gate_exp_time: u128) -> Self
pub fn x_gate_exp_time(self, x_gate_exp_time: u128) -> Self
Specify the expiration time (milliseconds); If the GATE receives the request time greater than the expiration time, the request will be rejected
Sourcepub fn credentials(self, creds: Credentials) -> Self
pub fn credentials(self, creds: Credentials) -> Self
Set API credentials for authentication