Skip to content

FIXED minQty filter #501

@Dvrcksoft

Description

@Dvrcksoft

Example for function marketSell
Before:

public function marketSell(string $symbol, $quantity, array $flags = [])
{
    $c = $this->numberOfDecimals($this->exchangeInfo()['symbols'][$symbol]['filters'][2]['minQty']);
    $quantity = $this->floorDecimal($quantity, $c);

    return $this->order("SELL", $symbol, $quantity, 0, "MARKET", $flags);
}

After:

public function marketSell(string $symbol, $quantity, array $flags = [])
{
// Get exchange information and filters for a specific symbol
$exchangeInfo = $this->exchangeInfo();
$symbolFilters = $exchangeInfo['symbols'][$symbol]['filters'];

    $minQty = null;
    // Look for the LOT_SIZE filter and get the minQty from there
    foreach ($symbolFilters as $filter) {
        if ($filter['filterType'] === 'LOT_SIZE' && isset($filter['minQty'])) {
            $minQty = $filter['minQty'];
            break;
        }
    }

    // If minQty is not found, record an error and return false
    if ($minQty === null) {
        error_log("Not found minQty for LOT_SIZE filter for $symbol pair");
        return false;
    }

    // Determine the number of decimal places for minQty and round the number of decimal places
    $c = $this->numberOfDecimals($minQty);
    $quantity = $this->floorDecimal($quantity, $c);

    // Create Order
    return $this->order("SELL", $symbol, $quantity, 0, "MARKET", $flags);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions