cargo fix

This commit is contained in:
Giulio De Pasquale 2021-01-24 20:53:33 +00:00
parent 64a687445d
commit 7de2a6ad77
7 changed files with 16 additions and 36 deletions

View File

@ -1,14 +1,11 @@
use core::time::Duration; use core::time::Duration;
use std::collections::HashMap;
use log::{debug, error, info}; use log::{error, info};
use tokio::time::delay_for; use tokio::time::delay_for;
use crate::connectors::{Client, ExchangeDetails}; use crate::connectors::ExchangeDetails;
use crate::currency::{Symbol, SymbolPair}; use crate::currency::{Symbol, SymbolPair};
use crate::events::Event; use crate::managers::ExchangeManager;
use crate::managers::{ExchangeManager, OrderManager, PositionManager, PriceManager};
use crate::strategy::PositionStrategy;
use crate::ticker::Ticker; use crate::ticker::Ticker;
use crate::BoxError; use crate::BoxError;

View File

@ -7,8 +7,6 @@ use async_trait::async_trait;
use bitfinex::api::Bitfinex; use bitfinex::api::Bitfinex;
use bitfinex::orders::{CancelOrderForm, OrderMeta, OrderResponse}; use bitfinex::orders::{CancelOrderForm, OrderMeta, OrderResponse};
use bitfinex::ticker::TradingPairTicker; use bitfinex::ticker::TradingPairTicker;
use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc};
use log::debug;
use crate::currency::SymbolPair; use crate::currency::SymbolPair;
use crate::models::{ use crate::models::{
@ -64,7 +62,7 @@ impl Client {
let (best_ask, best_bid) = (order_book.lowest_ask(), order_book.highest_bid()); let (best_ask, best_bid) = (order_book.lowest_ask(), order_book.highest_bid());
// updating positions with effective profit/loss // 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() { if x.is_short() {
x.update_profit_loss(best_ask, 0.2); x.update_profit_loss(best_ask, 0.2);
} else { } else {

View File

@ -1,12 +1,11 @@
use core::fmt; use core::fmt;
use std::borrow::Cow; use std::borrow::Cow;
use std::convert::TryFrom;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use std::str::FromStr;
use regex::Regex; use regex::Regex;
use crate::BoxError; use crate::BoxError;
use std::str::FromStr;
#[derive(Clone, PartialEq, Hash, Debug, Eq)] #[derive(Clone, PartialEq, Hash, Debug, Eq)]
pub struct Symbol { pub struct Symbol {

View File

@ -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 tokio::sync::oneshot;
use crate::managers::OptionUpdate;
use crate::models::OrderForm;
#[derive(Debug)] #[derive(Debug)]
pub struct ActorMessage { pub struct ActorMessage {
pub(crate) message: Message, pub(crate) message: Message,

View File

@ -1,15 +1,13 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::ops::{Deref, Neg}; use std::ops::Neg;
use bitfinex::ticker::TradingPairTicker;
use futures_util::stream::FuturesUnordered; use futures_util::stream::FuturesUnordered;
use log::{debug, error, info, trace}; use log::{debug, error, info, trace};
use merge::Merge; use merge::Merge;
use tokio::signal::unix::Signal;
use tokio::stream::StreamExt; use tokio::stream::StreamExt;
use tokio::sync::mpsc::channel; use tokio::sync::mpsc::channel;
use tokio::sync::mpsc::{Receiver, Sender}; use tokio::sync::mpsc::{Receiver, Sender};
use tokio::sync::{oneshot, RwLock}; use tokio::sync::oneshot;
use crate::connectors::{Client, ExchangeDetails}; use crate::connectors::{Client, ExchangeDetails};
use crate::currency::SymbolPair; use crate::currency::SymbolPair;
@ -395,9 +393,7 @@ impl OrderManager {
Message::Update { .. } => { Message::Update { .. } => {
self.update().await?; self.update().await?;
} }
Message::ClosePosition { Message::ClosePosition { position_id } => self.close_position(position_id).await?,
position_id: position_id,
} => self.close_position(position_id).await?,
_ => {} _ => {}
}; };
@ -522,7 +518,7 @@ impl OrderManager {
self.client.active_orders(&self.pair), self.client.active_orders(&self.pair),
self.client.active_positions(&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)) Ok((None, None))
} }

View File

@ -2,12 +2,8 @@ use std::fmt;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use chrono::{DateTime, TimeZone}; use crate::connectors::Exchange;
use float_cmp::ApproxEq;
use crate::connectors::{Exchange, ExchangeDetails};
use crate::currency::SymbolPair; use crate::currency::SymbolPair;
use crate::BoxError;
/*************** /***************
* Prices * Prices
@ -190,6 +186,7 @@ pub enum OrderKind {
amount: f64, amount: f64,
}, },
} }
impl OrderKind { impl OrderKind {
pub fn as_str(&self) -> &'static str { pub fn as_str(&self) -> &'static str {
match self { match self {
@ -460,6 +457,7 @@ impl PartialEq for Position {
self.id() == other.id() self.id() == other.id()
} }
} }
impl Eq for Position {} impl Eq for Position {}
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]

View File

@ -1,13 +1,9 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::{Debug, Formatter}; use std::fmt::{Debug, Formatter};
use std::ops::Neg;
use dyn_clone::DynClone; use dyn_clone::DynClone;
use log::{debug, info};
use tokio::sync::{oneshot, RwLock};
use crate::events::{Event, EventKind, EventMetadata, Message}; use crate::events::{Event, EventKind, EventMetadata, Message};
use crate::managers::{OrderManager, PositionManager, TrackedPositionsMap};
use crate::models::{ use crate::models::{
ActiveOrder, OrderBook, OrderBookEntry, OrderForm, OrderKind, Position, PositionProfitState, ActiveOrder, OrderBook, OrderBookEntry, OrderForm, OrderKind, Position, PositionProfitState,
PositionState, TradingPlatform, PositionState, TradingPlatform,
@ -228,7 +224,7 @@ impl PositionStrategy for TrailingStop {
if let Some(profit_state) = position.profit_state() { if let Some(profit_state) = position.profit_state() {
match profit_state { match profit_state {
PositionProfitState::Critical => { PositionProfitState::Critical => {
return (position, None, Some(vec![close_message])) return (position, None, Some(vec![close_message]));
} }
_ => {} _ => {}
} }