# Can I create a Min-Max price Buy order?

I would like to create a Buy order (using API) which can be filled only if the current price is between the set minimum and maximum.

For example, if this order has \$10.00 as the Min price and \$11.00 as Max price, this Buy order will get filled only if the Market price is between \$10 and \$11 , and will not get filled if it is below \$10 or above \$11.

Is this possible?

For a Buy order, the Max price is most likely going to be the Limit price, but what is the property for the MINIMUM price?

If it is possible, is it some kind of a special order type, or are there some properties on a regular order that I need to use?

Thank you.

Just out of curiosity, why would you want a minimum price for a buy order? Surely if the price is lower, youâ€™d be buying in cheaper? A limit order will always give the best price available (within the limit).

For example, if this order has \$10.00 as the Min price and \$11.00 as Max price, this Buy order will get filled only if the Market price is between \$10 and \$11 , and will not get filled if it is below \$10 or above \$11.

If you just set a limit buy order at \$11 then, if the price were \$10.50, the the order should fill at \$10.50 (or better). If the price were \$9 then the limit order should fill at \$9 (or better).

If it is important that the order doesnâ€™t trigger/fill below \$10 then you could get the latest price and use an IF statement to determine whether to place the order at all.

``````def place_conditional_limit_order(symbol, lower_price, upper_price, quantity):
#  Get the latest quote for the given symbol.
quote = api.get_latest_quote(symbol)

#  Calculate the latest price by finding the average of the ask and bid price.
price = (quote.ap + quote.bp)/2

#  If the current price is above the lower limit, place a limit order at the upper price...
if (price >= lower_price):
print(f'{symbol} price (\${price}) is above \${lower_price}, so limit buy order placed at \${upper_price}!')
else:
print(f'{symbol} price (\${price}) is below \${lower_price}, so no order placed.')

return

#  symbol: AAPL | lower price: \$165 | upper price: \$170 | quantity: 10
place_conditional_limit_order('AAPL', 165, 170, 10)
``````
``````Output:
AAPL price (\$167.765) is above \$165, so limit buy order placed at \$170!
``````

In the above example (which I tested in my paper account) the order was filled at \$167.77

I hope that helps!

Thank you for trying to answer my question.

I should have specified that I have already figured out the trading process, now I am trying to figure out the specific order type.

My algorithmâ€™s logic requires that a Buy order gets filled between Min and Max. Too cheap is as bad as too expensive.

As for watching the price and placing the order when the price is right: already doing that.

Is there a way to limit the Buy orderâ€™s lowest price programmatically?

Thank you.

Ah right. As far as I know, there is no way to do that. Maybe you could use a FOK or IOC order to reduce the chance of the order filling below the minimum, but it wouldnâ€™t be guaranteed.
Understand Orders | Alpaca Docs

1 Like