TypeScript
Public methods

by Benny Neugebauer

async constructQuantity(pair: CurrencyPair, price: string, side: OrderSide): Promise<string> {
  return (side === OrderSide.BUY) ? this.constructBuyQuantity(pair, price) : this.constructSellQuantity(pair);
}

private async constructBuyQuantity(pair: CurrencyPair, price: string): Promise<string> {
  const balance = await this.getBalance(pair.counter);
  return balance.getWorth(new Price(pair, price)).toFixed(8);
}

private async constructSellQuantity(pair: CurrencyPair): Promise<string> {
  const balance = await this.getBalance(pair.base);
  return balance.availableAmountAsString();
}

async constructQuantity(pair: CurrencyPair, price: string, side: OrderSide): Promise<string> {
  if (side === OrderSide.BUY) {
    const balance = await this.getBalance(pair.counter);
    return balance.getWorth(new Price(pair, price)).toFixed(8);
  }

  const balance = await this.getBalance(pair.base);
  return balance.availableAmountAsString();
}