lib.rs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. use std::collections::{BTreeMap, HashMap};
  2. use std::fmt;
  3. use std::fmt::Formatter;
  4. use std::io::{Error};
  5. use async_trait::async_trait;
  6. use rust_decimal::Decimal;
  7. use serde_json::Value;
  8. use tokio::time::Instant;
  9. use global::trace_stack::TraceStack;
  10. use crate::exchange::ExchangeEnum;
  11. // 引入工具模块
  12. pub mod utils;
  13. // 引入exchange模块
  14. pub mod exchange;
  15. pub mod handle_info;
  16. // 引入binance模块
  17. mod binance_swap;
  18. mod binance_spot;
  19. pub mod binance_swap_handle;
  20. pub mod binance_spot_handle;
  21. // 引入gate模块
  22. mod gate_swap;
  23. mod gate_spot;
  24. pub mod gate_swap_handle;
  25. mod kucoin_swap;
  26. pub mod kucoin_handle;
  27. mod okx_swap;
  28. pub mod okx_handle;
  29. mod bitget_spot;
  30. pub mod bitget_spot_handle;
  31. mod kucoin_spot;
  32. pub mod kucoin_spot_handle;
  33. mod bybit_swap;
  34. mod bybit_swap_handle;
  35. mod bitget_swap;
  36. mod bitget_swap_handle;
  37. /// 持仓模式枚举
  38. /// - `Both`:单持仓方向
  39. /// - `LONG`:多仓
  40. /// - `SHORT`:空仓
  41. #[derive(Debug, Clone, PartialEq, Eq)]
  42. pub enum PositionModeEnum {
  43. Both,
  44. Long,
  45. Short,
  46. }
  47. /// OrderCommand结构体(下单指令)
  48. /// - `cancel(HashMap<String, Vec<String>)`: 取消订单指令 `{"order_name": [c_id, o_id]}`;
  49. /// - `check(HashMap<String, Vec<String>>)`: balance挂单的冻结数量 `{"order_name": [数量,方向,价格,c_id]}`;
  50. /// - `limits_open(HashMap<String, Vec<String>>)`: 总计交易币数量 `{"order_name": [c_id, o_id]}`;
  51. /// - `limits_close(HashMap<String, Vec<String>>)`: 可用交易币数量 `{"order_name": [c_id, o_id]}`;
  52. #[derive(Debug, Clone, PartialEq, Eq)]
  53. pub struct OrderCommand {
  54. // 取消订单指令,数据结构例子:
  55. pub cancel: HashMap<String, Vec<String>>,
  56. // 检验指令,数据结构例子:(暂没找到例子)
  57. pub check: HashMap<String, Vec<String>>,
  58. // 限开指令,数据结构例子:(暂没找到例子)
  59. pub limits_open: HashMap<String, Vec<String>>,
  60. // 限收指令,数据结构例子:(暂没找到例子)
  61. pub limits_close: HashMap<String, Vec<String>>,
  62. }
  63. impl OrderCommand {
  64. pub fn new() -> OrderCommand {
  65. OrderCommand {
  66. cancel: Default::default(),
  67. check: Default::default(),
  68. limits_open: Default::default(),
  69. limits_close: Default::default(),
  70. }
  71. }
  72. pub fn is_not_empty(&self) -> bool {
  73. let is_empty = self.limits_close.is_empty() && self.limits_open.is_empty() && self.cancel.is_empty() && self.check.is_empty();
  74. if is_empty { false } else { true }
  75. }
  76. }
  77. impl fmt::Display for OrderCommand {
  78. fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
  79. write!(f, "订单触发数据: cancel: {:?}, check: {:?}, limits_open: {:?}, limits_close: {:?}",
  80. self.cancel,
  81. self.check,
  82. self.limits_open,
  83. self.limits_close
  84. )
  85. }
  86. }
  87. /// Account结构体(账户信息)
  88. /// - `coin(String)`: 货币;
  89. /// - `balance(Decimal)`: 总计计价币数量;
  90. /// - `available_balance(Decimal)`: 可用计价币数量;
  91. /// - `frozen_balance(Decimal)`: balance挂单的冻结数量
  92. /// - `stocks(Decimal)`: 总计交易币数量
  93. /// - `available_stocks(Decimal)`: 可用交易币数量
  94. /// - `frozen_stocks(Decimal)`: stocks挂单的冻结数量
  95. #[derive(Debug, Clone, PartialEq, Eq)]
  96. pub struct Account {
  97. pub coin: String,
  98. pub balance: Decimal,
  99. pub available_balance: Decimal,
  100. pub frozen_balance: Decimal,
  101. pub stocks: Decimal,
  102. pub available_stocks: Decimal,
  103. pub frozen_stocks: Decimal,
  104. }
  105. impl Account {
  106. pub fn new() -> Account {
  107. Account {
  108. coin: "".to_string(),
  109. balance: Default::default(),
  110. available_balance: Default::default(),
  111. frozen_balance: Default::default(),
  112. stocks: Default::default(),
  113. available_stocks: Default::default(),
  114. frozen_stocks: Default::default(),
  115. }
  116. }
  117. }
  118. /// Depth结构体(市场深度)
  119. /// - `time(i64)`: 深度更新时间戳(ms);
  120. /// - `asks(Vec<MarketOrder>)`: 卖方深度列表;
  121. /// - `bids(Vec<MarketOrder>)`: 买方深度列表;
  122. #[derive(Debug, Clone, PartialEq, Eq)]
  123. pub struct Depth {
  124. pub time: i64,
  125. pub asks: Vec<MarketOrder>,
  126. pub bids: Vec<MarketOrder>,
  127. }
  128. impl Depth {
  129. pub fn new() -> Depth {
  130. Depth {
  131. time: 0,
  132. asks: vec![],
  133. bids: vec![],
  134. }
  135. }
  136. }
  137. /// 特殊Depth结构体(市场深度)
  138. /// - `name<String>`: 平台信息;
  139. /// - `depth(Vec<Decimal>)`: 深度信息;
  140. /// - `ticker(SpecialTicker)`: 市场行情;
  141. /// - `t(Decimal)`: 数据更新id
  142. /// - `create_at(i64)`: 数据生成时间
  143. #[derive(Debug, Clone, PartialEq, Eq)]
  144. pub struct SpecialDepth {
  145. pub name: String,
  146. pub depth: Vec<Decimal>,
  147. pub ticker: SpecialTicker,
  148. pub t: Decimal,
  149. pub create_at: i64,
  150. }
  151. impl SpecialDepth {
  152. pub fn new() -> SpecialDepth {
  153. SpecialDepth {
  154. name: "".to_string(),
  155. depth: vec![],
  156. ticker: SpecialTicker::new(),
  157. t: Default::default(),
  158. create_at: 0,
  159. }
  160. }
  161. }
  162. /// 特殊Ticker结构体(市场行情)
  163. /// - `sell(Decimal)`: 卖一价
  164. /// - `buy(Decimal)`: 买一价
  165. /// - `mid_price(Decimal)`: 平均价
  166. /// - `t(Decimal)`: 数据更新id
  167. /// - `create_at(i64)`: 数据生成时间
  168. #[derive(Debug, Clone, PartialEq, Eq, Default)]
  169. pub struct SpecialTicker {
  170. pub sell: Decimal,
  171. pub buy: Decimal,
  172. pub mid_price: Decimal,
  173. pub t: Decimal,
  174. pub create_at: i64
  175. }
  176. impl SpecialTicker {
  177. pub fn new() -> SpecialTicker {
  178. SpecialTicker {
  179. sell: Default::default(),
  180. buy: Default::default(),
  181. mid_price: Default::default(),
  182. t: Default::default(),
  183. create_at: 0,
  184. }
  185. }
  186. }
  187. /// MarketOrder结构体(市场深度单)
  188. /// - `price(Decimal)`: 价格
  189. /// - `amount(Decimal)`: 数量
  190. #[derive(Debug, Clone, PartialEq, Eq)]
  191. pub struct MarketOrder {
  192. pub price: Decimal,
  193. pub amount: Decimal,
  194. }
  195. impl MarketOrder {
  196. pub fn new() -> MarketOrder {
  197. MarketOrder {
  198. price: Default::default(),
  199. amount: Default::default(),
  200. }
  201. }
  202. }
  203. /// Record结构体(标准的OHLC结构)
  204. /// - `time(i64)`: 时间戳;
  205. /// - `open(Decimal)`: 开盘价;
  206. /// - `high(Decimal)`: 最高价;
  207. /// - `low(Decimal):` 最低价;
  208. /// - `close(Decimal)`: 收盘价;
  209. /// - `volume(Decimal)`: 交易量;
  210. #[derive(Debug, Clone, PartialEq, Eq)]
  211. pub struct Record {
  212. pub time: i64,
  213. pub open: Decimal,
  214. pub high: Decimal,
  215. pub low: Decimal,
  216. pub close: Decimal,
  217. pub volume: Decimal,
  218. }
  219. impl Record {
  220. pub fn new() -> Record {
  221. Record {
  222. time: 0,
  223. open: Default::default(),
  224. high: Default::default(),
  225. low: Default::default(),
  226. close: Default::default(),
  227. volume: Default::default(),
  228. }
  229. }
  230. }
  231. /// 特殊Order结构体(订单)
  232. /// - `name<String>`: 平台信息;
  233. /// - `order<Vec<Order>>`: 订单信息数组;
  234. #[derive(Debug, Clone, PartialEq, Eq)]
  235. pub struct SpecialOrder {
  236. pub name: String,
  237. pub order: Vec<Order>,
  238. }
  239. impl SpecialOrder {
  240. pub fn new() -> SpecialOrder {
  241. SpecialOrder {
  242. name: "".to_string(),
  243. order: vec![],
  244. }
  245. }
  246. }
  247. /// Order结构体(订单)
  248. /// - `id(String)`: 交易单唯一标识
  249. /// - `custom_id(String)`: 自定义Id
  250. /// - `price(Decimal)`: 下单价格
  251. /// - `amount(Decimal)`: 下单数量
  252. /// - `deal_amount(Decimal)`: 成交数量
  253. /// - `avg_price(Decimal)`: 成交均价
  254. /// - `status(String)`: 订单状态
  255. /// - `order_type(String)`: 订单类型
  256. #[derive(Debug, Clone, PartialEq, Eq)]
  257. pub struct Order {
  258. pub id: String,
  259. pub custom_id: String,
  260. pub price: Decimal,
  261. pub amount: Decimal,
  262. pub deal_amount: Decimal,
  263. pub avg_price: Decimal,
  264. pub status: String,
  265. pub order_type: String,
  266. pub trace_stack: TraceStack,
  267. }
  268. impl Order {
  269. pub fn new() -> Order {
  270. Order {
  271. id: "".to_string(),
  272. custom_id: "".to_string(),
  273. price: Default::default(),
  274. amount: Default::default(),
  275. deal_amount: Default::default(),
  276. avg_price: Default::default(),
  277. status: "".to_string(),
  278. order_type: "".to_string(),
  279. trace_stack: TraceStack::new(0, Instant::now()),
  280. }
  281. }
  282. }
  283. /// Ticker结构体(市场行情)
  284. /// - `time(i64)`: 毫秒级别时间戳
  285. /// - `high(Decimal)`: 最高价
  286. /// - `low(Decimal)`: 最低价
  287. /// - `sell(Decimal)`: 卖一价
  288. /// - `buy(Decimal)`: 买一价
  289. /// - `last(Decimal)`: 最后成交价
  290. /// - `volume(Decimal)`: 最近成交量
  291. #[derive(Debug, Clone, PartialEq, Eq)]
  292. pub struct Ticker {
  293. pub time: i64,
  294. pub high: Decimal,
  295. pub low: Decimal,
  296. pub sell: Decimal,
  297. pub buy: Decimal,
  298. pub last: Decimal,
  299. pub volume: Decimal,
  300. }
  301. impl Ticker {
  302. pub fn new() -> Ticker {
  303. Ticker {
  304. time: 0,
  305. high: Default::default(),
  306. low: Default::default(),
  307. sell: Default::default(),
  308. buy: Default::default(),
  309. last: Default::default(),
  310. volume: Default::default(),
  311. }
  312. }
  313. }
  314. /// Market结构体(交易品种的市场信息)
  315. /// - `symbol(String)`: 交易对
  316. /// - `base_asset(String)`: 交易币
  317. /// - `quote_asset(String)`: 计价币
  318. /// - `tick_size(Decimal)`: 价格最小变动数值
  319. /// - `amount_size(Decimal)`: 下单量最小变动数值
  320. /// - `price_precision(Decimal)`: 价格精度
  321. /// - `amount_precision(Decimal)`: 下单量精度
  322. /// - `min_qty(Decimal)`: 最小下单量
  323. /// - `max_qty(Decimal)`: 最大下单量
  324. /// - `min_notional(Decimal)`: 最小下单金额
  325. /// - `max_notional(Decimal)`: 最大下单金额
  326. /// - `ct_val(Decimal)`: 合约价值
  327. #[derive(Debug, Clone, PartialEq, Eq)]
  328. pub struct Market {
  329. pub symbol: String,
  330. pub base_asset: String,
  331. pub quote_asset: String,
  332. pub tick_size: Decimal,
  333. pub amount_size: Decimal,
  334. pub price_precision: Decimal,
  335. pub amount_precision: Decimal,
  336. pub min_qty: Decimal,
  337. pub max_qty: Decimal,
  338. pub min_notional: Decimal,
  339. pub max_notional: Decimal,
  340. pub ct_val: Decimal,
  341. }
  342. impl Market {
  343. pub fn new() -> Market {
  344. Market {
  345. symbol: "".to_string(),
  346. base_asset: "".to_string(),
  347. quote_asset: "".to_string(),
  348. tick_size: Default::default(),
  349. amount_size: Default::default(),
  350. price_precision: Default::default(),
  351. amount_precision: Default::default(),
  352. min_qty: Default::default(),
  353. max_qty: Default::default(),
  354. min_notional: Default::default(),
  355. max_notional: Default::default(),
  356. ct_val: Default::default(),
  357. }
  358. }
  359. }
  360. /// Position结构体(仓位信息)
  361. /// - `symbol(String)`: 币对
  362. /// - `margin_level(Decimal)`: 持仓杆杠大小
  363. /// - `amount(Decimal)`: 持仓量
  364. /// - `frozen_amount(Decimal)`: 仓位冻结量
  365. /// - `price(Decimal)`: 持仓均价
  366. /// - `profit(Decimal)`: 持仓浮动盈亏
  367. /// - `position_mode(PositionModeEnum)`: 持仓模式
  368. /// - `margin(Decimal)`: 仓位占用的保证金
  369. #[derive(Debug, Clone, PartialEq, Eq)]
  370. pub struct Position {
  371. pub symbol: String,
  372. pub margin_level: Decimal,
  373. pub amount: Decimal,
  374. pub frozen_amount: Decimal,
  375. pub price: Decimal,
  376. pub profit: Decimal,
  377. pub position_mode: PositionModeEnum,
  378. pub margin: Decimal,
  379. }
  380. impl Position {
  381. pub fn new() -> Position {
  382. Position {
  383. symbol: "".to_string(),
  384. margin_level: Default::default(),
  385. amount: Default::default(),
  386. frozen_amount: Default::default(),
  387. price: Default::default(),
  388. profit: Default::default(),
  389. position_mode: PositionModeEnum::Both,
  390. margin: Default::default(),
  391. }
  392. }
  393. }
  394. /// 交易所统一方法接口
  395. ///
  396. /// 使用方法前需实例化
  397. /// ```rust
  398. /// use std::collections::BTreeMap;
  399. /// use standard::exchange::{Exchange, ExchangeEnum};
  400. ///
  401. /// let mut params:BTreeMap<String,String> = BTreeMap::new();
  402. /// params.insert("access_key".to_string(), "your_access_key".to_string());
  403. /// params.insert("access_key".to_string(), "your_secret_key".to_string());
  404. /// // let exchange = Exchange::new(ExchangeEnum::BinanceSwap, "BTC_USDT".to_string(), true, params);
  405. /// ```
  406. /// 获取当前交易所交易模式
  407. /// - fn get_self_exchange(&self) -> ExchangeEnum;
  408. /// ```rust
  409. /// # use std::collections::BTreeMap;
  410. /// # use standard::exchange::{Exchange, ExchangeEnum};
  411. /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
  412. /// # params.insert("access_key".to_string(), "your_access_key".to_string());
  413. /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
  414. /// # // let exchange = Exchange::new(ExchangeEnum::BinanceSwap, "BTC_USDT".to_string(), true, params);
  415. ///
  416. /// // exchange.get_self_exchange();
  417. /// ```
  418. /// 获取当前是否使用高速模式
  419. /// - fn get_self_is_colo(&self) -> bool;
  420. /// ```rust
  421. /// # use std::collections::BTreeMap;
  422. /// # use standard::exchange::{Exchange, ExchangeEnum};
  423. /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
  424. /// # params.insert("access_key".to_string(), "your_access_key".to_string());
  425. /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
  426. /// # // let exchange = Exchange::new(ExchangeEnum::BinanceSwap, "BTC_USDT".to_string(), true, params);
  427. ///
  428. /// // exchange.get_self_is_colo();
  429. /// ```
  430. /// 获取当前是否使用登录
  431. /// - fn get_self_is_login(&self) -> bool;
  432. /// ```rust
  433. /// # use std::collections::BTreeMap;
  434. /// # use standard::exchange::{Exchange, ExchangeEnum};
  435. /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
  436. /// # params.insert("access_key".to_string(), "your_access_key".to_string());
  437. /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
  438. /// # // let exchange = Exchange::new(ExchangeEnum::BinanceSwap, "BTC_USDT".to_string(), true, params);
  439. ///
  440. /// // exchange.get_self_is_login();
  441. /// ```
  442. /// 获取登录params信息
  443. /// - fn get_self_params(&self) -> BTreeMap<String, String>;
  444. /// ```rust
  445. /// # use std::collections::BTreeMap;
  446. /// # use standard::exchange::{Exchange, ExchangeEnum};
  447. /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
  448. /// # params.insert("access_key".to_string(), "your_access_key".to_string());
  449. /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
  450. /// # // let exchange = Exchange::new(ExchangeEnum::BinanceSwap, "BTC_USDT".to_string(), true, params);
  451. ///
  452. /// // exchange.get_self_params();
  453. /// ```
  454. /// 获取账号信息
  455. /// - async fn get_account(&self, symbol: &str) -> Result<Account, Error>;
  456. /// ```rust
  457. /// # use std::collections::BTreeMap;
  458. /// # use standard::exchange::{Exchange, ExchangeEnum};
  459. /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
  460. /// # params.insert("access_key".to_string(), "your_access_key".to_string());
  461. /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
  462. /// # // let exchange = Exchange::new(ExchangeEnum::BinanceSwap, "BTC_USDT".to_string(), true, params);
  463. ///
  464. /// // exchange.get_account()
  465. /// ```
  466. /// 订阅账号信息
  467. /// ```rust
  468. /// # use std::collections::BTreeMap;
  469. /// # use standard::exchange::{Exchange, ExchangeEnum};
  470. /// # let mut params:BTreeMap<String,String> = BTreeMap::new();
  471. /// # params.insert("access_key".to_string(), "your_access_key".to_string());
  472. /// # params.insert("access_key".to_string(), "your_secret_key".to_string());
  473. /// # // let exchange = Exchange::new(ExchangeEnum::BinanceSwap, "BTC_USDT".to_string(), true, params);
  474. ///
  475. /// // exchange.subscribe_account();
  476. /// ```
  477. #[async_trait]
  478. pub trait Platform {
  479. fn clone_box(&self) -> Box<dyn Platform + Send + Sync>;
  480. // 获取当前交易所交易模式
  481. fn get_self_exchange(&self) -> ExchangeEnum;
  482. // 获取交易对
  483. fn get_self_symbol(&self) -> String;
  484. // 获取当前是否使用高速模式
  485. fn get_self_is_colo(&self) -> bool;
  486. // 获取登录params信息
  487. fn get_self_params(&self) -> BTreeMap<String, String>;
  488. // 获取market信息
  489. fn get_self_market(&self) -> Market;
  490. // 获取请求时间
  491. fn get_request_delays(&self) -> Vec<i64>;
  492. // 获取请求平均时间
  493. fn get_request_avg_delay(&self) -> Decimal;
  494. // 获取请求最大时间
  495. fn get_request_max_delay(&self) -> i64;
  496. // 获取服务器时间
  497. async fn get_server_time(&mut self) -> Result<String, Error>;
  498. // 获取账号信息
  499. async fn get_account(&mut self) -> Result<Account, Error>;
  500. // 获取现货账号信息
  501. async fn get_spot_account(&mut self) -> Result<Vec<Account>, Error>;
  502. // 获取持仓信息
  503. async fn get_position(&mut self) -> Result<Vec<Position>, Error>;
  504. // 获取所有持仓
  505. async fn get_positions(&mut self) -> Result<Vec<Position>, Error>;
  506. // 获取市场行情
  507. async fn get_ticker(&mut self) -> Result<Ticker, Error>;
  508. // 获取市场行情自定义交易对
  509. async fn get_ticker_symbol(&mut self, symbol: String) -> Result<Ticker, Error>;
  510. // 查询所有的市场信息
  511. async fn get_market(&mut self) -> Result<Market, Error>;
  512. // 查询所有的市场信息自定义交易对
  513. async fn get_market_symbol(&mut self, symbol: String) -> Result<Market, Error>;
  514. // 查询订单详情
  515. async fn get_order_detail(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error>;
  516. // 获取订单列表
  517. async fn get_orders_list(&mut self, status: &str) -> Result<Vec<Order>, Error>;
  518. // 下单接口
  519. async fn take_order(&mut self, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error>;
  520. // 下单接口自定义交易对
  521. async fn take_order_symbol(&mut self, symbol: String, ct_val: Decimal, custom_id: &str, origin_side: &str, price: Decimal, amount: Decimal) -> Result<Order, Error>;
  522. // 撤销订单
  523. async fn cancel_order(&mut self, order_id: &str, custom_id: &str) -> Result<Order, Error>;
  524. // 批量撤销订单
  525. async fn cancel_orders(&mut self) -> Result<Vec<Order>, Error>;
  526. // 撤销所有订单
  527. async fn cancel_orders_all(&mut self) -> Result<Vec<Order>, Error>;
  528. /// 下一个止损单
  529. /// - stop_price: 触发价
  530. /// - price: 委托价,0就市价委托
  531. /// - side: 止损哪个方向[long多单,short空单]
  532. async fn take_stop_loss_order(&mut self, stop_price: Decimal, price: Decimal, side: &str) -> Result<Value, Error>;
  533. /// 撤销止损订单
  534. /// - order_id: 需要撤销的id
  535. async fn cancel_stop_loss_order(&mut self, order_id: &str) -> Result<Value, Error>;
  536. // 设置持仓模式
  537. async fn set_dual_mode(&mut self, coin: &str, is_dual_mode: bool) -> Result<String, Error>;
  538. // 更新双持仓模式下杠杆
  539. async fn set_dual_leverage(&mut self, leverage: &str) -> Result<String, Error>;
  540. // 设置自动追加保证金
  541. async fn set_auto_deposit_status(&mut self, status: bool) -> Result<String, Error>;
  542. // 交易账户互转
  543. async fn wallet_transfers(&mut self, coin: &str, from: &str, to: &str, amount: Decimal) -> Result<String, Error>;
  544. // 指令下单
  545. async fn command_order(&mut self, order_command: &mut OrderCommand, trace_stack: &TraceStack);
  546. }