isStopLossPriceValidForPosition function

bool isStopLossPriceValidForPosition(
  1. MatexStockPositionSizeCalculatorState state
)

Implementation

bool isStopLossPriceValidForPosition(
  MatexStockPositionSizeCalculatorState state,
) {
  final isValid = state.stopLossPrice != null && state.stopLossPrice! >= 0;

  if (state.isShortPosition) {
    return isValid && state.stopLossPrice! > state.entryPrice!;
  }

  return isValid && state.stopLossPrice! < state.entryPrice!;
}