clippy + reformat
This commit is contained in:
parent
f4431f26c0
commit
a3ce3682ad
@ -123,7 +123,7 @@ impl Client {
|
||||
.active_orders(pair)
|
||||
.await?
|
||||
.into_iter()
|
||||
.filter(|x| &x.pair() == &pair)
|
||||
.filter(|x| x.pair() == pair)
|
||||
.collect())
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ async fn main() -> Result<(), BoxError> {
|
||||
.ok_or("API_SECRET not set!")?;
|
||||
|
||||
let bitfinex = ExchangeDetails::Bitfinex {
|
||||
api_key: api_key.into(),
|
||||
api_secret: api_secret.into(),
|
||||
api_key,
|
||||
api_secret,
|
||||
};
|
||||
|
||||
let mut bot = BfxBot::new(
|
||||
|
@ -416,7 +416,7 @@ impl OrderManager {
|
||||
None => { self.orders_map.clear(); }
|
||||
Some(positions) => {
|
||||
// retain only positions that are open remotely as well
|
||||
self.orders_map.retain(|local_id, _| positions.iter().find(|r| r.id() == *local_id).is_some());
|
||||
self.orders_map.retain(|local_id, _| positions.iter().any(|r| r.id() == *local_id));
|
||||
|
||||
for position in positions {
|
||||
// mapping tracked orders to their ids
|
||||
@ -431,7 +431,7 @@ impl OrderManager {
|
||||
for remote_order in remote_orders.iter().filter(|x| !tracked_orders.contains(&x.id())) {
|
||||
// the only check to bind an active order to an open position,
|
||||
// is to check for their amount which should be identical
|
||||
if remote_order.order_form().amount().abs() == position.amount().abs() {
|
||||
if (remote_order.order_form().amount().abs() - position.amount().abs()).abs() < 0.0001 {
|
||||
trace!("Adding order {} to internal mapping from remote.", remote_order.id());
|
||||
self.add_to_orders_map(position.id(), remote_order.clone());
|
||||
}
|
||||
@ -439,7 +439,7 @@ impl OrderManager {
|
||||
|
||||
// removing local orders that are not in remote
|
||||
for local_orders in self.orders_map.values_mut() {
|
||||
local_orders.retain(|l| remote_orders.iter().find(|r| r.id() == l.id()).is_some());
|
||||
local_orders.retain(|l| remote_orders.iter().any(|r| r.id() == l.id()));
|
||||
}
|
||||
|
||||
// clean-up empty positions in local mapping
|
||||
|
@ -432,7 +432,7 @@ pub struct OrderMetadata {
|
||||
impl Clone for OrderMetadata {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
position_id: self.position_id.clone(),
|
||||
position_id: self.position_id,
|
||||
strategy: self.strategy.as_ref().map(|x| clone_box(&**x)),
|
||||
}
|
||||
}
|
||||
@ -469,6 +469,12 @@ impl OrderMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for OrderMetadata {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
/***************
|
||||
* Positions
|
||||
***************/
|
||||
|
@ -23,14 +23,14 @@ pub trait PositionStrategy: DynClone + Send + Sync {
|
||||
position: Position,
|
||||
current_tick: u64,
|
||||
positions_history: &HashMap<u64, Position>,
|
||||
fees: &Vec<TradingFees>,
|
||||
fees: &[TradingFees],
|
||||
) -> (Position, Option<Vec<Event>>, Option<Vec<ActionMessage>>);
|
||||
fn post_tick(
|
||||
&mut self,
|
||||
position: Position,
|
||||
current_tick: u64,
|
||||
positions_history: &HashMap<u64, Position>,
|
||||
fees: &Vec<TradingFees>,
|
||||
fees: &[TradingFees],
|
||||
) -> (Position, Option<Vec<Event>>, Option<Vec<ActionMessage>>);
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ impl PositionStrategy for TrailingStop {
|
||||
position: Position,
|
||||
current_tick: u64,
|
||||
positions_history: &HashMap<u64, Position>,
|
||||
_: &Vec<TradingFees>,
|
||||
_: &[TradingFees],
|
||||
) -> (Position, Option<Vec<Event>>, Option<Vec<ActionMessage>>) {
|
||||
let pl_perc = position.pl_perc();
|
||||
|
||||
@ -300,7 +300,7 @@ impl PositionStrategy for TrailingStop {
|
||||
position: Position,
|
||||
_: u64,
|
||||
_: &HashMap<u64, Position>,
|
||||
fees: &Vec<TradingFees>,
|
||||
fees: &[TradingFees],
|
||||
) -> (Position, Option<Vec<Event>>, Option<Vec<ActionMessage>>) {
|
||||
let taker_fee = fees
|
||||
.iter()
|
||||
|
Loading…
Reference in New Issue
Block a user