|
|
@@ -76,7 +76,6 @@ impl Platform for KucoinSwap {
|
|
|
if res_data.code == "200" {
|
|
|
let res_data_str = &res_data.data;
|
|
|
let result = res_data_str.clone();
|
|
|
- println!("{}", res_data.data);
|
|
|
Ok(result)
|
|
|
} else {
|
|
|
Err(Error::new(ErrorKind::Other, res_data.message))
|
|
|
@@ -114,7 +113,7 @@ impl Platform for KucoinSwap {
|
|
|
let res_data_str = &res_data.data;
|
|
|
let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
|
|
|
let result = kucoin_handle::format_position_item(&res_data_json, amount_size);
|
|
|
- Ok(result)
|
|
|
+ Ok(vec![result])
|
|
|
} else {
|
|
|
Err(Error::new(ErrorKind::Other, res_data.message))
|
|
|
}
|
|
|
@@ -129,7 +128,7 @@ impl Platform for KucoinSwap {
|
|
|
let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
|
|
|
let mut result = Vec::new();
|
|
|
for item in res_data_json.iter() {
|
|
|
- result.extend(kucoin_handle::format_position_item(item, amount_size))
|
|
|
+ result.push(kucoin_handle::format_position_item(item, amount_size))
|
|
|
}
|
|
|
Ok(result)
|
|
|
} else {
|
|
|
@@ -165,6 +164,7 @@ impl Platform for KucoinSwap {
|
|
|
let res_data = self.request.get_market_details().await;
|
|
|
if res_data.code == "200" {
|
|
|
let res_data_str = &res_data.data;
|
|
|
+ println!("{}", res_data_str);
|
|
|
let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
|
|
|
let market_info = res_data_json.iter().find(|item| item["symbol"].as_str().unwrap() == symbol_format);
|
|
|
match market_info {
|
|
|
@@ -176,8 +176,11 @@ impl Platform for KucoinSwap {
|
|
|
let quote_asset = value["quoteCurrency"].as_str().unwrap_or("").to_string();
|
|
|
let tick_size = Decimal::from_str(&value["tickSize"].to_string()).unwrap();
|
|
|
let amount_size = Decimal::from_str(&value["multiplier"].to_string()).unwrap();
|
|
|
+ let min_qty = Decimal::from_str(&value["lotSize"].to_string()).unwrap();
|
|
|
+
|
|
|
let price_precision = Decimal::from_u32(tick_size.scale()).unwrap();
|
|
|
let amount_precision = Decimal::from_u32(amount_size.scale()).unwrap();
|
|
|
+ let min_notional = min_qty * amount_size;
|
|
|
|
|
|
let result = Market {
|
|
|
symbol: format!("{}_{}", base_asset, quote_asset),
|
|
|
@@ -187,9 +190,9 @@ impl Platform for KucoinSwap {
|
|
|
amount_size,
|
|
|
price_precision,
|
|
|
amount_precision,
|
|
|
- min_qty: Decimal::from_str(&value["lotSize"].to_string()).unwrap(),
|
|
|
+ min_qty,
|
|
|
max_qty: Decimal::from_str(&value["maxOrderQty"].to_string()).unwrap(),
|
|
|
- min_notional: Default::default(),
|
|
|
+ min_notional,
|
|
|
max_notional: Decimal::from_str(&value["maxPrice"].to_string()).unwrap(),
|
|
|
ct_val: Default::default(),
|
|
|
};
|
|
|
@@ -233,7 +236,6 @@ impl Platform for KucoinSwap {
|
|
|
async fn take_order(&mut self, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error> {
|
|
|
let symbol_format = format!("{}M", utils::format_symbol(self.symbol.clone(), ""));
|
|
|
let amount_size = self.market.amount_size;
|
|
|
- let mut status = "";
|
|
|
let mut params = json!({
|
|
|
"clientOid": custom_id,
|
|
|
"symbol": symbol_format,
|
|
|
@@ -245,19 +247,15 @@ impl Platform for KucoinSwap {
|
|
|
match origin_side {
|
|
|
"kd" => {
|
|
|
params["side"] = json!("buy");
|
|
|
- status = "NEW";
|
|
|
}
|
|
|
"pd" => {
|
|
|
- params["side"] = json!("sell");
|
|
|
- status = "REMOVE";
|
|
|
+ params["side"] = json!("sell")
|
|
|
}
|
|
|
"kk" => {
|
|
|
params["side"] = json!("sell");
|
|
|
- status = "NEW";
|
|
|
}
|
|
|
"pk" => {
|
|
|
params["side"] = json!("buy");
|
|
|
- status = "REMOVE";
|
|
|
}
|
|
|
_ => { error!("下单参数错误"); }
|
|
|
};
|
|
|
@@ -274,7 +272,7 @@ impl Platform for KucoinSwap {
|
|
|
amount,
|
|
|
deal_amount: dec!(0),
|
|
|
avg_price: dec!(0),
|
|
|
- status: status.to_string(),
|
|
|
+ status: "NEW".to_string(),
|
|
|
order_type: "".to_string(),
|
|
|
};
|
|
|
Ok(result)
|
|
|
@@ -365,6 +363,11 @@ impl Platform for KucoinSwap {
|
|
|
result_sd.send(result).await.unwrap();
|
|
|
}
|
|
|
Err(error) => {
|
|
|
+ let mut err_order = Order::new();
|
|
|
+ err_order.custom_id = (*cid).clone();
|
|
|
+ err_order.status = "REMOVE".to_string();
|
|
|
+
|
|
|
+ result_sd.send(err_order).await.unwrap();
|
|
|
err_sd.send(error).await.unwrap();
|
|
|
}
|
|
|
}
|