|
|
@@ -10,8 +10,8 @@ use tracing::{error, info, trace};
|
|
|
use exchanges::gate_swap_rest::GateSwapRest;
|
|
|
use exchanges::gate_swap_ws::{GateSwapLogin, GateSwapSubscribeType, GateSwapWs, GateSwapWsType};
|
|
|
|
|
|
-const ACCESS_KEY: &str = "4181c882718a95e72122ac1d52c88533";
|
|
|
-const SECRET_KEY: &str = "de82d1507b843ff08d81a0e9b878b721359f274937216b307834b570b676fa3c";
|
|
|
+const ACCESS_KEY: &str = "";
|
|
|
+const SECRET_KEY: &str = "";
|
|
|
|
|
|
//ws-订阅公共频道信息
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
|
@@ -106,30 +106,31 @@ async fn price_order_test() {
|
|
|
global::log_utils::init_log_with_info();
|
|
|
|
|
|
let mut rest = get_rest();
|
|
|
- let params = json!({
|
|
|
- "initial": {
|
|
|
- "contract": "XRP_USDT",
|
|
|
- "price": "0",
|
|
|
- "tif": "ioc",
|
|
|
- "text": "t-1232131abc",
|
|
|
- "reduce_only": true,
|
|
|
- "auto_size": "close_long"
|
|
|
- },
|
|
|
- "trigger": {
|
|
|
- // [平多:close-long-position, 平空:close-short-position]
|
|
|
- "order_type": "close-long-position",
|
|
|
- // 一般都默认用0
|
|
|
- "strategy_type": 0,
|
|
|
- // [0 - 最新成交价,1 - 标记价格,2 - 指数价格]
|
|
|
- "price_type": 0,
|
|
|
- // [1: 引用价格大于等于我们传的价格,2:引用价格小于等于我们传的价格]
|
|
|
- // 在止损的情况下:
|
|
|
- // 1 可以理解为向上突破止损位(一般是给空单用)
|
|
|
- // 2 可以理解为向下突破止损位(一般是给多单用)
|
|
|
- "rule": 2,
|
|
|
- // 我们传的价格,在止损的情况在就是止损触发价格
|
|
|
- "price": "0.5700",
|
|
|
- }
|
|
|
+ let mut params = json!({});
|
|
|
+
|
|
|
+ params["initial"] = json!({
|
|
|
+ "contract": "XRP_USDT",
|
|
|
+ "price": "0",
|
|
|
+ "tif": "ioc",
|
|
|
+ "reduce_only": true,
|
|
|
+ // [平多:close_long, 平空:close_short]
|
|
|
+ "auto_size": "close_long"
|
|
|
+ });
|
|
|
+
|
|
|
+ params["trigger"] = json!({
|
|
|
+ // [平多:close-long-position, 平空:close-short-position]
|
|
|
+ "order_type": "close-long-position",
|
|
|
+ // 一般都默认用0
|
|
|
+ "strategy_type": 0,
|
|
|
+ // [0 - 最新成交价,1 - 标记价格,2 - 指数价格]
|
|
|
+ "price_type": 0,
|
|
|
+ // [1: 引用价格大于等于我们传的价格,2:引用价格小于等于我们传的价格]
|
|
|
+ // 在止损的情况下:
|
|
|
+ // 1 可以理解为向上突破触发价(一般是给空单用)
|
|
|
+ // 2 可以理解为向下突破触发价(一般是给多单用)
|
|
|
+ "rule": 2,
|
|
|
+ // 订单触发价格
|
|
|
+ "price": "0.5600",
|
|
|
});
|
|
|
|
|
|
let response_data = rest.place_price_order("usdt".to_string(), params).await;
|
|
|
@@ -142,6 +143,17 @@ async fn price_order_test() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#[tokio::test]
|
|
|
+async fn price_order_cancel_test() {
|
|
|
+ global::log_utils::init_log_with_info();
|
|
|
+
|
|
|
+ let mut rest = get_rest();
|
|
|
+
|
|
|
+ // 这边取消订单只能使用系统返回的
|
|
|
+ let rst = rest.cancel_price_order("usdt".to_string(), "58002898".to_string()).await;
|
|
|
+ info!(?rst);
|
|
|
+}
|
|
|
+
|
|
|
//rest-查询合约账户变更历史
|
|
|
#[tokio::test]
|
|
|
async fn rest_account_book_test() {
|