|
|
@@ -88,6 +88,7 @@ impl Platform for OkxSwap {
|
|
|
let frozen_balance = Decimal::from_str(&account_info["fixedBal"].as_str().unwrap()).unwrap();
|
|
|
let balance = available_balance + frozen_balance;
|
|
|
let result = Account {
|
|
|
+ coin: symbol_array[1].to_string(),
|
|
|
balance,
|
|
|
available_balance,
|
|
|
frozen_balance,
|
|
|
@@ -101,6 +102,10 @@ impl Platform for OkxSwap {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async fn get_spot_account(&mut self) -> Result<Vec<Account>, Error> {
|
|
|
+ Err(Error::new(ErrorKind::NotFound, "okx_swap:该交易所方法未实现".to_string()))
|
|
|
+ }
|
|
|
+
|
|
|
async fn get_position(&mut self) -> Result<Vec<Position>, Error> {
|
|
|
let symbol_format = utils::format_symbol(self.symbol.to_string(), "-");
|
|
|
let ct_val = self.market.ct_val;
|
|
|
@@ -111,8 +116,8 @@ impl Platform for OkxSwap {
|
|
|
let position_info = res_data_json.iter().find(|&item| item["instId"].as_str().unwrap() == format!("{}-SWAP", symbol_format));
|
|
|
match position_info {
|
|
|
None => {
|
|
|
- error!("Okx:获取Position信息错误!\nget_position:res_data={:?}", res_data_str);
|
|
|
- panic!("Okx:获取Position信息错误!\nget_position:res_data={:?}", res_data_str)
|
|
|
+ error!("okx_swap:获取Position信息错误!\nget_position:res_data={:?}", res_data_str);
|
|
|
+ panic!("okx_swap:获取Position信息错误!\nget_position:res_data={:?}", res_data_str)
|
|
|
}
|
|
|
Some(value) => {
|
|
|
let result = okx_handle::format_position_item(value.clone(), ct_val);
|
|
|
@@ -146,8 +151,8 @@ impl Platform for OkxSwap {
|
|
|
let ticker_info = res_data_json.iter().find(|item| item["instId"].as_str().unwrap() == format!("{}-SWAP", symbol_format.clone()));
|
|
|
match ticker_info {
|
|
|
None => {
|
|
|
- error!("Okx:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str);
|
|
|
- panic!("Okx:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str)
|
|
|
+ error!("okx_swap:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str);
|
|
|
+ panic!("okx_swap:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str)
|
|
|
}
|
|
|
Some(value) => {
|
|
|
let result = Ticker {
|
|
|
@@ -176,8 +181,8 @@ impl Platform for OkxSwap {
|
|
|
let ticker_info = res_data_json.iter().find(|item| item["instId"].as_str().unwrap() == format!("{}-SWAP", symbol_format.clone()));
|
|
|
match ticker_info {
|
|
|
None => {
|
|
|
- error!("Okx:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str);
|
|
|
- panic!("Okx:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str)
|
|
|
+ error!("okx_swap:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str);
|
|
|
+ panic!("okx_swap:获取Ticker信息错误!\nget_ticker:res_data={:?}", res_data_str)
|
|
|
}
|
|
|
Some(value) => {
|
|
|
let result = Ticker {
|
|
|
@@ -206,8 +211,8 @@ impl Platform for OkxSwap {
|
|
|
let market_info = res_data_json.iter().find(|item| item["instId"].as_str().unwrap() == format!("{}-SWAP", symbol_format));
|
|
|
match market_info {
|
|
|
None => {
|
|
|
- error!("Okx:获取Market信息错误!\nget_market:res_data={:?}", res_data_str);
|
|
|
- panic!("Okx:获取Market信息错误!\nget_market:res_data={:?}", res_data_str)
|
|
|
+ error!("okx_swap:获取Market信息错误!\nget_market:res_data={:?}", res_data_str);
|
|
|
+ panic!("okx_swap:获取Market信息错误!\nget_market:res_data={:?}", res_data_str)
|
|
|
}
|
|
|
Some(value) => {
|
|
|
let base_asset = value["ctValCcy"].as_str().unwrap_or("").to_string();
|
|
|
@@ -255,8 +260,8 @@ impl Platform for OkxSwap {
|
|
|
let market_info = res_data_json.iter().find(|item| item["instId"].as_str().unwrap() == format!("{}-SWAP", symbol_format));
|
|
|
match market_info {
|
|
|
None => {
|
|
|
- error!("Okx:获取Market信息错误!\nget_market:res_data={:?}", res_data_str);
|
|
|
- panic!("Okx:获取Market信息错误!\nget_market:res_data={:?}", res_data_str)
|
|
|
+ error!("okx_swap:获取Market信息错误!\nget_market:res_data={:?}", res_data_str);
|
|
|
+ panic!("okx_swap:获取Market信息错误!\nget_market:res_data={:?}", res_data_str)
|
|
|
}
|
|
|
Some(value) => {
|
|
|
let base_asset = value["ctValCcy"].as_str().unwrap_or("").to_string();
|
|
|
@@ -361,14 +366,14 @@ impl Platform for OkxSwap {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async fn take_order_symbol(&mut self, _symbol: String, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> { Err(Error::new(ErrorKind::NotFound, "okx:该交易所方法未实现".to_string())) }
|
|
|
+ async fn take_order_symbol(&mut self, _symbol: String, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> { Err(Error::new(ErrorKind::NotFound, "okx_swap:该交易所方法未实现".to_string())) }
|
|
|
|
|
|
async fn cancel_order(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error> {
|
|
|
let symbol_format = utils::format_symbol(self.symbol.clone(), "-");
|
|
|
let res_data = self.request.cancel_order(symbol_format, order_id.to_string(), custom_id.to_string()).await;
|
|
|
if order_id == "" {
|
|
|
- error!("Okx:撤销订单错误,该交易所为提供自定义订单号撤销订单!\ncancel_order:order_id={:?},custom_id={:?}", order_id, custom_id);
|
|
|
- panic!("Okx:撤销订单错误,该交易所为提供自定义订单号撤销订单!\ncancel_order:order_id={:?},custom_id={:?}", order_id, custom_id)
|
|
|
+ error!("okx_swap:撤销订单错误,该交易所为提供自定义订单号撤销订单!\ncancel_order:order_id={:?},custom_id={:?}", order_id, custom_id);
|
|
|
+ panic!("okx_swap:撤销订单错误,该交易所为提供自定义订单号撤销订单!\ncancel_order:order_id={:?},custom_id={:?}", order_id, custom_id)
|
|
|
}
|
|
|
if res_data.code == "200" {
|
|
|
let res_data_str = &res_data.data;
|
|
|
@@ -385,7 +390,7 @@ impl Platform for OkxSwap {
|
|
|
avg_price: Decimal::ZERO,
|
|
|
status: "REMOVE".to_string(),
|
|
|
order_type: "".to_string(),
|
|
|
- trace_stack: TraceStack::default().on_special("388 okx_handle".to_string()),
|
|
|
+ trace_stack: TraceStack::default().on_special("393 okx_handle".to_string()),
|
|
|
};
|
|
|
Ok(result)
|
|
|
} else {
|
|
|
@@ -394,11 +399,11 @@ impl Platform for OkxSwap {
|
|
|
}
|
|
|
|
|
|
async fn cancel_orders(&mut self) -> Result<Vec<Order>, Error> {
|
|
|
- Err(Error::new(ErrorKind::NotFound, "okx:该交易所方法未实现".to_string()))
|
|
|
+ Err(Error::new(ErrorKind::NotFound, "okx_swap:该交易所方法未实现".to_string()))
|
|
|
}
|
|
|
|
|
|
async fn cancel_orders_all(&mut self) -> Result<Vec<Order>, Error> {
|
|
|
- Err(Error::new(ErrorKind::NotFound, "okx:该交易所方法未实现".to_string()))
|
|
|
+ Err(Error::new(ErrorKind::NotFound, "okx_swap:该交易所方法未实现".to_string()))
|
|
|
}
|
|
|
|
|
|
async fn set_dual_mode(&mut self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> {
|
|
|
@@ -424,9 +429,9 @@ impl Platform for OkxSwap {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async fn set_auto_deposit_status(&mut self, _status: bool) -> Result<String, Error> { Err(Error::new(ErrorKind::NotFound, "okx:该交易所方法未实现".to_string())) }
|
|
|
+ async fn set_auto_deposit_status(&mut self, _status: bool) -> Result<String, Error> { Err(Error::new(ErrorKind::NotFound, "okx_swap:该交易所方法未实现".to_string())) }
|
|
|
|
|
|
- async fn wallet_transfers(&mut self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> { Err(Error::new(ErrorKind::NotFound, "okx:该交易所方法未实现".to_string())) }
|
|
|
+ async fn wallet_transfers(&mut self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> { Err(Error::new(ErrorKind::NotFound, "okx_swap:该交易所方法未实现".to_string())) }
|
|
|
|
|
|
async fn command_order(&mut self, order_command: OrderCommand, trace_stack: TraceStack) {
|
|
|
let mut handles = vec![];
|