diff --git a/php-binance-api.php b/php-binance-api.php old mode 100755 new mode 100644 index cf4324a..ffc2dfd --- a/php-binance-api.php +++ b/php-binance-api.php @@ -409,7 +409,14 @@ public function numberOfDecimals($val = 0.00000001) public function marketQuoteSell(string $symbol, $quantity, array $flags = []) { $flags['isQuoteOrder'] = true; - $c = $this->numberOfDecimals($this->exchangeInfo()['symbols'][$symbol]['filters'][1]['minQty']); + $exchangeInfo = $this->exchangeInfo(); + $filters = $exchangeInfo['symbols'][$symbol]['filters']; + $lotSize = array_filter($filters, function ($filter) { + return $filter['filterType'] === 'LOT_SIZE'; + }); + $lotSize = array_shift($lotSize); + $minQty = $lotSize['minQty']; + $c = $this->numberOfDecimals($minQty); $quantity = $this->floorDecimal($quantity, $c); return $this->order("SELL", $symbol, $quantity, 0, "MARKET", $flags); @@ -445,7 +452,14 @@ public function marketQuoteSellTest(string $symbol, $quantity, array $flags = [] */ public function marketSell(string $symbol, $quantity, array $flags = []) { - $c = $this->numberOfDecimals($this->exchangeInfo()['symbols'][$symbol]['filters'][1]['minQty']); + $exchangeInfo = $this->exchangeInfo(); + $filters = $exchangeInfo['symbols'][$symbol]['filters']; + $lotSize = array_filter($filters, function ($filter) { + return $filter['filterType'] === 'LOT_SIZE'; + }); + $lotSize = array_shift($lotSize); + $minQty = $lotSize['minQty']; + $c = $this->numberOfDecimals($minQty); $quantity = $this->floorDecimal($quantity, $c); return $this->order("SELL", $symbol, $quantity, 0, "MARKET", $flags);