Set quantity for market orders to max buying power

I am randomly getting errors on markt orders stating that buying power is insufficient and cost basis is higher than my buying power. I am calculating the quantity for my market orders based on the fetched buying power / current ask. Due to rest API response times of a couple of hundred MS, price might be higher by the time my order tries to execute and my set quantity for the order would be worth more than by the time it was calculated.

Is there a way, to create and send an order without a numeric quantity but instead use whatever is available?

nevermind, I think I can just go with notional and TIF of day which is fine.