Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIXED minQty filter #501

Open
Dvrcksoft opened this issue Jan 3, 2024 · 0 comments
Open

FIXED minQty filter #501

Dvrcksoft opened this issue Jan 3, 2024 · 0 comments

Comments

@Dvrcksoft
Copy link

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant