From 7de2a6ad77f1f4551047da63aaf01b42f13d2dcb Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Sun, 24 Jan 2021 20:53:33 +0000 Subject: [PATCH] cargo fix --- rustybot/src/bot.rs | 9 +++------ rustybot/src/connectors.rs | 4 +--- rustybot/src/currency.rs | 3 +-- rustybot/src/events.rs | 10 +++------- rustybot/src/managers.rs | 12 ++++-------- rustybot/src/models.rs | 8 +++----- rustybot/src/strategy.rs | 6 +----- 7 files changed, 16 insertions(+), 36 deletions(-) diff --git a/rustybot/src/bot.rs b/rustybot/src/bot.rs index b332147..ca30b78 100644 --- a/rustybot/src/bot.rs +++ b/rustybot/src/bot.rs @@ -1,14 +1,11 @@ use core::time::Duration; -use std::collections::HashMap; -use log::{debug, error, info}; +use log::{error, info}; use tokio::time::delay_for; -use crate::connectors::{Client, ExchangeDetails}; +use crate::connectors::ExchangeDetails; use crate::currency::{Symbol, SymbolPair}; -use crate::events::Event; -use crate::managers::{ExchangeManager, OrderManager, PositionManager, PriceManager}; -use crate::strategy::PositionStrategy; +use crate::managers::ExchangeManager; use crate::ticker::Ticker; use crate::BoxError; diff --git a/rustybot/src/connectors.rs b/rustybot/src/connectors.rs index 8fbdff9..355cd20 100644 --- a/rustybot/src/connectors.rs +++ b/rustybot/src/connectors.rs @@ -7,8 +7,6 @@ use async_trait::async_trait; use bitfinex::api::Bitfinex; use bitfinex::orders::{CancelOrderForm, OrderMeta, OrderResponse}; use bitfinex::ticker::TradingPairTicker; -use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc}; -use log::debug; use crate::currency::SymbolPair; use crate::models::{ @@ -64,7 +62,7 @@ impl Client { let (best_ask, best_bid) = (order_book.lowest_ask(), order_book.highest_bid()); // updating positions with effective profit/loss - positions.iter_mut().flatten().for_each(|mut x| { + positions.iter_mut().flatten().for_each(|x| { if x.is_short() { x.update_profit_loss(best_ask, 0.2); } else { diff --git a/rustybot/src/currency.rs b/rustybot/src/currency.rs index ae4a618..0798c87 100644 --- a/rustybot/src/currency.rs +++ b/rustybot/src/currency.rs @@ -1,12 +1,11 @@ use core::fmt; use std::borrow::Cow; -use std::convert::TryFrom; use std::fmt::{Display, Formatter}; +use std::str::FromStr; use regex::Regex; use crate::BoxError; -use std::str::FromStr; #[derive(Clone, PartialEq, Hash, Debug, Eq)] pub struct Symbol { diff --git a/rustybot/src/events.rs b/rustybot/src/events.rs index 57c5968..085b3f8 100644 --- a/rustybot/src/events.rs +++ b/rustybot/src/events.rs @@ -1,12 +1,8 @@ -use std::collections::HashMap; -use std::future::Future; - -use tokio::task::JoinHandle; - -use crate::managers::{OptionUpdate, OrderManager, PositionManager, PriceManager}; -use crate::models::{OrderForm, OrderKind, Position, PositionProfitState}; use tokio::sync::oneshot; +use crate::managers::OptionUpdate; +use crate::models::OrderForm; + #[derive(Debug)] pub struct ActorMessage { pub(crate) message: Message, diff --git a/rustybot/src/managers.rs b/rustybot/src/managers.rs index 7ebdfdf..165d394 100644 --- a/rustybot/src/managers.rs +++ b/rustybot/src/managers.rs @@ -1,15 +1,13 @@ use std::collections::HashMap; -use std::ops::{Deref, Neg}; +use std::ops::Neg; -use bitfinex::ticker::TradingPairTicker; use futures_util::stream::FuturesUnordered; use log::{debug, error, info, trace}; use merge::Merge; -use tokio::signal::unix::Signal; use tokio::stream::StreamExt; use tokio::sync::mpsc::channel; use tokio::sync::mpsc::{Receiver, Sender}; -use tokio::sync::{oneshot, RwLock}; +use tokio::sync::oneshot; use crate::connectors::{Client, ExchangeDetails}; use crate::currency::SymbolPair; @@ -395,9 +393,7 @@ impl OrderManager { Message::Update { .. } => { self.update().await?; } - Message::ClosePosition { - position_id: position_id, - } => self.close_position(position_id).await?, + Message::ClosePosition { position_id } => self.close_position(position_id).await?, _ => {} }; @@ -522,7 +518,7 @@ impl OrderManager { self.client.active_orders(&self.pair), self.client.active_positions(&self.pair) ); - let (open_orders, opt_open_positions) = (open_orders?, opt_open_positions?); + let (_open_orders, _opt_open_positions) = (open_orders?, opt_open_positions?); Ok((None, None)) } diff --git a/rustybot/src/models.rs b/rustybot/src/models.rs index 70e0cfe..3285dab 100644 --- a/rustybot/src/models.rs +++ b/rustybot/src/models.rs @@ -2,12 +2,8 @@ use std::fmt; use std::fmt::{Display, Formatter}; use std::hash::{Hash, Hasher}; -use chrono::{DateTime, TimeZone}; -use float_cmp::ApproxEq; - -use crate::connectors::{Exchange, ExchangeDetails}; +use crate::connectors::Exchange; use crate::currency::SymbolPair; -use crate::BoxError; /*************** * Prices @@ -190,6 +186,7 @@ pub enum OrderKind { amount: f64, }, } + impl OrderKind { pub fn as_str(&self) -> &'static str { match self { @@ -460,6 +457,7 @@ impl PartialEq for Position { self.id() == other.id() } } + impl Eq for Position {} #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] diff --git a/rustybot/src/strategy.rs b/rustybot/src/strategy.rs index bcf8b30..b93b151 100644 --- a/rustybot/src/strategy.rs +++ b/rustybot/src/strategy.rs @@ -1,13 +1,9 @@ use std::collections::HashMap; use std::fmt::{Debug, Formatter}; -use std::ops::Neg; use dyn_clone::DynClone; -use log::{debug, info}; -use tokio::sync::{oneshot, RwLock}; use crate::events::{Event, EventKind, EventMetadata, Message}; -use crate::managers::{OrderManager, PositionManager, TrackedPositionsMap}; use crate::models::{ ActiveOrder, OrderBook, OrderBookEntry, OrderForm, OrderKind, Position, PositionProfitState, PositionState, TradingPlatform, @@ -228,7 +224,7 @@ impl PositionStrategy for TrailingStop { if let Some(profit_state) = position.profit_state() { match profit_state { PositionProfitState::Critical => { - return (position, None, Some(vec![close_message])) + return (position, None, Some(vec![close_message])); } _ => {} }