Take_profit.limit_price must be <= base_price - 0.01


I’m trying to configure a new algo trading strategies but i received this error: “take_profit.limit_price must be <= base_price - 0.01”. I thought that i solved this error selling below the BID price and buying above the ASK price but it give me the error sometimes the same, so, what is the base_price?

@Giuseppe_Mammoliti The base_price is the fill price of the original parent order. However, when an order is submitted (but not yet executed), it isn’t known what that fill price will be. Therefore, the base_price is really the “expected fill price”. If the parent order was a limit order, that price is the limit price (ie it’s assumed it will fill at the limit). If the parent order is a market order, that price is the current ask (for a buy order) or the current bid (for a sell order). Market orders typically fill at the current quote.

For a bracket order (which I assume this is) the take profit order is a limit order. That limit price must be ‘better’ than the base_price (otherwise it wouldn’t be taking a profit). For a long position this means the limit must be greater than the base_price (ie one makes a profit when the price goes up). For a short position this means the limit must be less than the base_price (ie one makes a profit when the price goes down).

Now, since the error was take_profit.limit_price must be <= base_price - 0.01 (notice ‘less than’), the parent order must have been a sell order. The take profit limit price therefore must be less than the base price which is either 1) the parent order limit price if it’s a limit order or 2) the current bid if it’s a market order.

If you are checking the current bid and ensuring your take profit limit is less than that, the issue may be with the quote data you are fetching. The system uses the full market SIP data for the latest quote check. If one only is subscribed to the free Market Data plan that will only be IEX data which is a subset of the full market data. Quotes received from the free plan are not necessarily accurate full market quotes. Could that be the issue?

Thank you for your accurate response @Dan_Whitnable_Alpaca.

Best Regards,