Error with take_profit.limit_price

I’m using a bracket order and quite frequently receive the following error:

take_profit.limit_price must be >= base_price + 0.01

How can I know what the base price is? It obviously depends on the market and is not something you can specify in a bracket order.

It seems sometimes my take_profit.limit_price is below the “expected fill price”. But I don’t want to set my limit_price and stop_price to arbitrarily huge values just to ensure they meet the requirements of whatever the base_price might be.

Can I query somehow to get the base_price? Or how do I overcome this error?

    market_order_data = MarketOrderRequest(
                symbol="SPY",
                qty=10,
                side=OrderSide.BUY,
                time_in_force=TimeInForce.DAY,
                order_class=OrderClass.BRACKET,
                take_profit=TakeProfitRequest(limit_price=?),
                stop_loss=StopLossRequest(stop_price=?)

Any help on this would be appreciated. What’s a good strategy to get around this?

I believe this happens when you are setting your limit_price too close to the buy price. Alpaca doesn’t play with sub-penny increments for most positions. Include some logic to either not trade a security when your limit and predicted buy are that close, or use a max function like:

limit_p=max(predicted_limit_price, buy_price+0.01)#might want to check your model if it’s constantly generating so close to null

take_profit=TakeProfitRequest(limit_price=limit_p)