Skip to main content

CloseReason

Represents the reason why a position/family was closed. This is useful for statistics and logging.

CloseReason.java
package com.bookmap.ordermanagement.model;

/**
* Represents the reason why a position/family was closed.
*
* This is useful for statistics and logging.
*/
public enum CloseReason {

TP_HIT("Take Profit Hit", true),
SL_HIT("Stop Loss Hit", false),
MANUAL("Manual Close", false),
CANCELLED("Order Cancelled", false),
REJECTED("Order Rejected", false),
SESSION_RESET("Session Reset", false),
UNKNOWN("Unknown", false);

private final String description;
private final boolean isWin;

CloseReason(String description, boolean isWin) {
this.description = description;
this.isWin = isWin;
}

/**
* Returns a human-readable description.
*/
public String getDescription() {
return description;
}

/**
* Returns true if this close reason represents a winning trade.
*/
public boolean isWin() {
return isWin;
}

/**
* Returns true if this close reason represents a losing trade.
*/
public boolean isLoss() {
return this == SL_HIT;
}

@Override
public String toString() {
return description;
}
}