|
|
@@ -193,8 +193,37 @@ impl Platform for BinanceSwap {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async fn get_record(&mut self, _interval: String) -> Result<Vec<Record>, Error> {
|
|
|
- Err(Error::new(ErrorKind::NotFound, "binance_usdt_swap:该交易所方法未实现".to_string()))
|
|
|
+ async fn get_record(&mut self, interval: String) -> Result<Vec<Record>, Error> {
|
|
|
+ let symbol_format = utils::format_symbol(self.symbol.clone(), "");
|
|
|
+
|
|
|
+ let params = json!({
|
|
|
+ "symbol": symbol_format.clone(),
|
|
|
+ "interval": "USDT-FUTURES",
|
|
|
+ "granularity": interval,
|
|
|
+ "limit": "500"
|
|
|
+ });
|
|
|
+
|
|
|
+ let res_data = self.request.get_records(params).await;
|
|
|
+ if res_data.code == 200 {
|
|
|
+ let mut records: Vec<Record> = vec![];
|
|
|
+ info!("{}", res_data.data.to_string());
|
|
|
+ for record_value in res_data.data.as_array().unwrap() {
|
|
|
+ records.push(Record {
|
|
|
+ time: Decimal::from_str(record_value[0].as_str().unwrap()).unwrap(),
|
|
|
+ open: Decimal::from_str(record_value[1].as_str().unwrap()).unwrap(),
|
|
|
+ high: Decimal::from_str(record_value[2].as_str().unwrap()).unwrap(),
|
|
|
+ low: Decimal::from_str(record_value[3].as_str().unwrap()).unwrap(),
|
|
|
+ close: Decimal::from_str(record_value[4].as_str().unwrap()).unwrap(),
|
|
|
+ volume: Decimal::from_str(record_value[5].as_str().unwrap()).unwrap(),
|
|
|
+ symbol: symbol_format.clone(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ records.reverse();
|
|
|
+ Ok(records)
|
|
|
+ } else {
|
|
|
+ Err(Error::new(ErrorKind::Other, res_data.to_string()))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async fn get_ticker_symbol(&mut self, symbol: String) -> Result<Ticker, Error> {
|