TypeScript
Prefer conditional expression

by Benny Neugebauer

private isCheapBuy(currentPrice: BigNumber): boolean {
  let isCheap = true;

  if (this.strategy.buyOnlyWhenLower) {
    if (this.history.lastAction === OrderSide.SELL) {
      if (this.history.lastSell.gt(currentPrice)) {
        isCheap = true;
      } else {
        isCheap = false;
      }
    }
  }

  return isCheap;
}

private isCheapBuy(currentPrice: BigNumber): boolean {
  const isConfigured = this.strategy.buyOnlyWhenLower;
  const wasSellOrder = this.history.lastAction === OrderSide.SELL;
  const wasSoldHigher = this.history.lastSell.gt(currentPrice);

  return (isConfigured && wasSellOrder && wasSoldHigher) ? true : false;
}