lib.rs 19 KB

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