filter active orders based on pair

This commit is contained in:
Giulio De Pasquale 2021-01-26 17:13:14 +00:00
parent fbdb481aa0
commit 7230b7c67d

View File

@ -1,4 +1,5 @@
use std::convert::{TryFrom, TryInto};
use std::error::Error;
use std::fmt::{Debug, Formatter};
use std::str::FromStr;
use std::sync::Arc;
@ -10,6 +11,7 @@ use bitfinex::ticker::TradingPairTicker;
use futures_retry::{FutureRetry, RetryPolicy, StreamRetryExt};
use futures_util::task::FutureObj;
use log::trace;
use tokio::macros::support::Future;
use tokio::time::Duration;
use crate::currency::SymbolPair;
@ -18,8 +20,6 @@ use crate::models::{
PriceTicker, TradingPlatform,
};
use crate::BoxError;
use std::error::Error;
use tokio::macros::support::Future;
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub enum Exchange {
@ -83,7 +83,13 @@ impl Client {
}
pub async fn active_orders(&self, pair: &SymbolPair) -> Result<Vec<ActiveOrder>, BoxError> {
self.inner.active_orders(pair).await
Ok(self
.inner
.active_orders(pair)
.await?
.into_iter()
.filter(|x| &x.symbol == pair)
.collect())
}
pub async fn submit_order(&self, order: &OrderForm) -> Result<ActiveOrder, BoxError> {