diff --git a/rustybot/src/connectors.rs b/rustybot/src/connectors.rs index 26aacfa..4757f7f 100644 --- a/rustybot/src/connectors.rs +++ b/rustybot/src/connectors.rs @@ -17,7 +17,7 @@ use tokio::time::Duration; use crate::currency::{Symbol, SymbolPair}; use crate::models::{ ActiveOrder, OrderBook, OrderBookEntry, OrderDetails, OrderFee, OrderForm, OrderKind, Position, - PositionState, PriceTicker, Trade, TradingPlatform, WalletKind, + PositionState, PriceTicker, Trade, TradingFees, TradingPlatform, WalletKind, }; use crate::BoxError; @@ -69,9 +69,9 @@ impl Client { // TODO: change fee with account's taker fee positions.iter_mut().flatten().for_each(|x| { if x.is_short() { - x.update_profit_loss(best_ask, 0.2); + x.update_profit_loss(best_ask, 0.075); } else { - x.update_profit_loss(best_bid, 0.2); + x.update_profit_loss(best_bid, 0.075); } }); @@ -153,6 +153,7 @@ pub trait Connector: Send + Sync { &self, pair: &SymbolPair, ) -> Result>, BoxError>; + async fn trading_fees(&self) -> Result, BoxError>; } impl Debug for dyn Connector { @@ -189,7 +190,11 @@ impl BitfinexConnector { if pair.to_string().to_lowercase().contains("test") { format!("{}:{}", pair.base(), pair.quote()) } else { - format!("{}{}", pair.base(), pair.quote()) + if pair.to_string().to_lowercase().contains("f0") { + format!("{}:{}", pair.base(), pair.quote()) + } else { + format!("{}{}", pair.base(), pair.quote()) + } } } @@ -279,9 +284,11 @@ impl Connector for BitfinexConnector { let order_form = match order.kind() { OrderKind::Limit { price, amount } => { bitfinex::orders::OrderForm::new(symbol_name, price, amount, order.into()) + .with_leverage(15) } - OrderKind::Market { amount } => { + OrderKind::Market { amount, .. } => { bitfinex::orders::OrderForm::new(symbol_name, 0.0, amount, order.into()) + .with_leverage(15) } OrderKind::Stop { price, amount } => { bitfinex::orders::OrderForm::new(symbol_name, price, amount, order.into()) @@ -371,6 +378,10 @@ impl Connector for BitfinexConnector { Ok((!mapped_vec.is_empty()).then_some(mapped_vec)) } + + async fn trading_fees(&self) -> Result, BoxError> { + unimplemented!() + } } impl From<&ActiveOrder> for CancelOrderForm { @@ -439,7 +450,7 @@ impl From<&OrderForm> for bitfinex::orders::OrderKind { OrderKind::FillOrKill { .. } => bitfinex::orders::OrderKind::ExchangeFok, OrderKind::ImmediateOrCancel { .. } => bitfinex::orders::OrderKind::ExchangeIoc, }, - TradingPlatform::Margin => match o.kind() { + TradingPlatform::Margin | TradingPlatform::Derivative => match o.kind() { OrderKind::Limit { .. } => bitfinex::orders::OrderKind::Limit, OrderKind::Market { .. } => bitfinex::orders::OrderKind::Market, OrderKind::Stop { .. } => bitfinex::orders::OrderKind::Stop,