debut-js/Core

Proposal for partial close order

BusinessDuck opened this issue · 1 comments

Requirements

For many strategies good practice close 75% of order when take reached and enable trailing stop for 25% left order.

Examples

this.closeOrder(order: ExecutedOrder, partial: number = 0..1);

this.partialClose(order: ExecutedOrder, partial: number = 0..1);

ExecutedOrder should have flag partial and percentage of closing after that

During development, the following approach became obvious. Using the this.reduceOrder(order, reduce) method. Reduce parameter is how many percentage of order you want to close. For example if we need to close 25% of current position just do like this:

const order = this.orders[0];

// Reduce order by 25%
await this.reduceOrder(order, 0.25);