Ver código fonte

修改bitget 获取market

gepangpang 2 anos atrás
pai
commit
fb20242605
1 arquivos alterados com 24 adições e 8 exclusões
  1. 24 8
      standard/src/bitget_spot.rs

+ 24 - 8
standard/src/bitget_spot.rs

@@ -164,8 +164,16 @@ impl Platform for BitgetSpot {
                     let min_qty = Decimal::from_str(&value["minTradeAmount"].as_str().unwrap()).unwrap();
                     let max_qty = Decimal::from_str(&value["maxTradeAmount"].as_str().unwrap()).unwrap();
 
-                    let tick_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(price_precision).unwrap()))).unwrap();
-                    let amount_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(amount_precision).unwrap()))).unwrap();
+                    let tick_size = if price_precision > dec!(0) {
+                        Decimal::from_str(&format!("0.{}1", "0".repeat(usize::try_from(price_precision - dec!(1)).unwrap()))).unwrap()
+                    } else {
+                        Decimal::ONE
+                    };
+                    let amount_size = if amount_precision > dec!(0) {
+                        Decimal::from_str(&format!("0.{}1", "0".repeat(usize::try_from(amount_precision - dec!(1)).unwrap()))).unwrap()
+                    } else {
+                        Decimal::ONE
+                    };
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
@@ -209,8 +217,16 @@ impl Platform for BitgetSpot {
                     let min_qty = Decimal::from_str(&value["minTradeAmount"].as_str().unwrap()).unwrap();
                     let max_qty = Decimal::from_str(&value["maxTradeAmount"].as_str().unwrap()).unwrap();
 
-                    let tick_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(price_precision).unwrap()))).unwrap();
-                    let amount_size = Decimal::from_str(&format!("0.{}", "0".repeat(usize::try_from(amount_precision).unwrap()))).unwrap();
+                    let tick_size = if price_precision > dec!(0) {
+                        Decimal::from_str(&format!("0.{}1", "0".repeat(usize::try_from(price_precision - dec!(1)).unwrap()))).unwrap()
+                    } else {
+                        Decimal::ONE
+                    };
+                    let amount_size = if amount_precision > dec!(0) {
+                        Decimal::from_str(&format!("0.{}1", "0".repeat(usize::try_from(amount_precision - dec!(1)).unwrap()))).unwrap()
+                    } else {
+                        Decimal::ONE
+                    };
 
                     let result = Market {
                         symbol: format!("{}_{}", base_asset, quote_asset),
@@ -305,7 +321,7 @@ impl Platform for BitgetSpot {
                 avg_price: Decimal::ZERO,
                 status: "NEW".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("308 bitget_spot".to_string()),
+                trace_stack: TraceStack::default().on_special("324 bitget_spot".to_string()),
             };
             Ok(result)
         } else {
@@ -357,7 +373,7 @@ impl Platform for BitgetSpot {
                 avg_price: Decimal::ZERO,
                 status: "NEW".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("360 bitget_spot".to_string()),
+                trace_stack: TraceStack::default().on_special("376 bitget_spot".to_string()),
             };
             Ok(result)
         } else {
@@ -380,7 +396,7 @@ impl Platform for BitgetSpot {
                 avg_price: Decimal::ZERO,
                 status: "REMOVE".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("383 bitget_spot".to_string()),
+                trace_stack: TraceStack::default().on_special("399 bitget_spot".to_string()),
             };
             Ok(result)
         } else {
@@ -411,7 +427,7 @@ impl Platform for BitgetSpot {
                             avg_price: Decimal::ZERO,
                             status: "REMOVE".to_string(),
                             order_type: "".to_string(),
-                            trace_stack: TraceStack::default().on_special("414 bitget_spot".to_string()),
+                            trace_stack: TraceStack::default().on_special("430 bitget_spot".to_string()),
                         });
                     };
                 } else {