Renamed HiddenTrailingStop to TrailingStop (again!?)
This commit is contained in:
parent
415944bde5
commit
d8d0e07a0b
@ -15,7 +15,7 @@ use crate::connectors::{Client, ExchangeDetails};
|
|||||||
use crate::currency::SymbolPair;
|
use crate::currency::SymbolPair;
|
||||||
use crate::events::{ActionMessage, ActorMessage, Event};
|
use crate::events::{ActionMessage, ActorMessage, Event};
|
||||||
use crate::models::{ActiveOrder, OrderBook, OrderForm, OrderKind, OrderMetadata, Position, PriceTicker};
|
use crate::models::{ActiveOrder, OrderBook, OrderForm, OrderKind, OrderMetadata, Position, PriceTicker};
|
||||||
use crate::strategy::{HiddenTrailingStop, MarketEnforce, PositionStrategy};
|
use crate::strategy::{TrailingStop, MarketEnforce, PositionStrategy};
|
||||||
|
|
||||||
pub type OptionUpdate = (Option<Vec<Event>>, Option<Vec<ActionMessage>>);
|
pub type OptionUpdate = (Option<Vec<Event>>, Option<Vec<ActionMessage>>);
|
||||||
|
|
||||||
@ -236,7 +236,6 @@ impl PositionManager {
|
|||||||
let (fees, opt_active_positions) = tokio::join!(self.client.trading_fees(),self.client.active_positions(&self.pair));
|
let (fees, opt_active_positions) = tokio::join!(self.client.trading_fees(),self.client.active_positions(&self.pair));
|
||||||
let (fees, opt_active_positions) = (fees?, opt_active_positions?);
|
let (fees, opt_active_positions) = (fees?, opt_active_positions?);
|
||||||
|
|
||||||
|
|
||||||
// we assume there is only ONE active position per pair
|
// we assume there is only ONE active position per pair
|
||||||
match opt_active_positions {
|
match opt_active_positions {
|
||||||
// no open positions, no events and no messages returned
|
// no open positions, no events and no messages returned
|
||||||
@ -683,7 +682,7 @@ impl PairManager {
|
|||||||
position_manager: PositionManagerHandle::new(
|
position_manager: PositionManagerHandle::new(
|
||||||
pair,
|
pair,
|
||||||
client,
|
client,
|
||||||
Box::new(HiddenTrailingStop::default()),
|
Box::new(TrailingStop::default()),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ impl Debug for dyn OrderStrategy {
|
|||||||
***************/
|
***************/
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct HiddenTrailingStop {
|
pub struct TrailingStop {
|
||||||
// position id: stop_percentage
|
// position id: stop_percentage
|
||||||
stop_percentages: HashMap<u64, f64>,
|
stop_percentages: HashMap<u64, f64>,
|
||||||
// position_id: bool
|
// position_id: bool
|
||||||
@ -86,7 +86,7 @@ pub struct HiddenTrailingStop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl HiddenTrailingStop {
|
impl TrailingStop {
|
||||||
fn print_status(&self, position: &Position) {
|
fn print_status(&self, position: &Position) {
|
||||||
match self.stop_percentages.get(&position.id()) {
|
match self.stop_percentages.get(&position.id()) {
|
||||||
None => {
|
None => {
|
||||||
@ -143,13 +143,13 @@ impl HiddenTrailingStop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for HiddenTrailingStop {
|
impl Default for TrailingStop {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let leverage = 15.0;
|
let leverage = 15.0;
|
||||||
|
|
||||||
// in percentage
|
// in percentage
|
||||||
let capital_min_profit = 4.0;
|
let capital_min_profit = 8.5;
|
||||||
let capital_max_loss = capital_min_profit * 1.65;
|
let capital_max_loss = capital_min_profit * 1.9;
|
||||||
let capital_good_profit = capital_min_profit * 2.0;
|
let capital_good_profit = capital_min_profit * 2.0;
|
||||||
|
|
||||||
let weighted_min_profit = capital_min_profit / leverage;
|
let weighted_min_profit = capital_min_profit / leverage;
|
||||||
@ -163,7 +163,7 @@ impl Default for HiddenTrailingStop {
|
|||||||
let good_profit_percentage = weighted_good_profit + good_profit_trailing_delta;
|
let good_profit_percentage = weighted_good_profit + good_profit_trailing_delta;
|
||||||
let max_loss_percentage = -weighted_max_loss;
|
let max_loss_percentage = -weighted_max_loss;
|
||||||
|
|
||||||
HiddenTrailingStop {
|
TrailingStop {
|
||||||
stop_percentages: Default::default(),
|
stop_percentages: Default::default(),
|
||||||
stop_loss_flags: Default::default(),
|
stop_loss_flags: Default::default(),
|
||||||
capital_max_loss,
|
capital_max_loss,
|
||||||
@ -179,7 +179,7 @@ impl Default for HiddenTrailingStop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PositionStrategy for HiddenTrailingStop {
|
impl PositionStrategy for TrailingStop {
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
"Hidden Trailing Stop".into()
|
"Hidden Trailing Stop".into()
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ impl OrderStrategy for MarketEnforce {
|
|||||||
|
|
||||||
// long
|
// long
|
||||||
let offer_comparison = {
|
let offer_comparison = {
|
||||||
if order.order_form().amount() > 0.0 {
|
if order.order_form().is_long() {
|
||||||
order_book.highest_bid()
|
order_book.highest_bid()
|
||||||
} else {
|
} else {
|
||||||
order_book.lowest_ask()
|
order_book.lowest_ask()
|
||||||
|
Loading…
Reference in New Issue
Block a user