gate_spot.rs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. use std::collections::BTreeMap;
  2. use std::io::{Error};
  3. use async_trait::async_trait;
  4. use rust_decimal::Decimal;
  5. use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand};
  6. use exchanges::gate_spot_rest::GateSpotRest;
  7. #[allow(dead_code)]
  8. #[derive(Clone)]
  9. pub struct GateSpot {
  10. exchange: ExchangeEnum,
  11. symbol: String,
  12. is_colo: bool,
  13. params: BTreeMap<String, String>,
  14. request: GateSpotRest,
  15. }
  16. impl GateSpot {
  17. pub fn new(symbol: String, is_colo: bool, params: BTreeMap<String, String>) -> GateSpot {
  18. GateSpot {
  19. exchange: ExchangeEnum::GateSpot,
  20. symbol: symbol.to_uppercase(),
  21. is_colo,
  22. params: params.clone(),
  23. request: GateSpotRest::new(is_colo, params.clone()),
  24. }
  25. }
  26. }
  27. #[async_trait]
  28. impl Platform for GateSpot {
  29. // 克隆方法
  30. fn clone_box(&self) -> Box<dyn Platform + Send + Sync> { Box::new(self.clone()) }
  31. // 获取交易所模式
  32. fn get_self_exchange(&self) -> ExchangeEnum {
  33. ExchangeEnum::GateSpot
  34. }
  35. // 获取交易对
  36. fn get_self_symbol(&self) -> String { self.symbol.clone() }
  37. // 获取是否使用高速通道
  38. fn get_self_is_colo(&self) -> bool {
  39. self.is_colo
  40. }
  41. // 获取params信息
  42. fn get_self_params(&self) -> BTreeMap<String, String> {
  43. self.params.clone()
  44. }
  45. fn get_self_market(&self) -> Market { todo!() }
  46. fn get_request_delays(&self) -> Vec<i64> { todo!() }
  47. fn get_request_avg_delay(&self) -> Decimal { todo!() }
  48. fn get_request_max_delay(&self) -> i64 { todo!() }
  49. async fn get_server_time(&mut self) -> Result<String, Error> {
  50. todo!()
  51. }
  52. // 获取账号信息
  53. async fn get_account(&mut self) -> Result<Account, Error> {
  54. todo!()
  55. }
  56. // 获取仓位信息
  57. async fn get_position(&mut self) -> Result<Vec<Position>, Error> {
  58. todo!()
  59. }
  60. async fn get_positions(&mut self) -> Result<Vec<Position>, Error> {
  61. todo!()
  62. }
  63. // 获取市场行情
  64. async fn get_ticker(&mut self) -> Result<Ticker, Error> {
  65. todo!()
  66. }
  67. async fn get_market(&mut self) -> Result<Market, Error> {
  68. todo!()
  69. }
  70. async fn get_order_detail(&mut self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
  71. async fn get_orders_list(&mut self, _status: &str) -> Result<Vec<Order>, Error> {
  72. todo!()
  73. }
  74. async fn set_dual_mode(&mut self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> { todo!() }
  75. async fn set_dual_leverage(&mut self, _leverage: &str) -> Result<String, Error> {
  76. todo!()
  77. }
  78. async fn wallet_transfers(&mut self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> { todo!() }
  79. async fn take_order(&mut self, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> { todo!() }
  80. async fn cancel_order(&mut self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
  81. async fn cancel_orders(&mut self) -> Result<Vec<Order>, Error> {
  82. todo!()
  83. }
  84. async fn command_order(&mut self, _order_command: OrderCommand) { todo!() }
  85. }