I run some scripts at market open for my Alpaca Pro account that basically picks UP TO 4 stocks, buys them individually via a separate algorithm, then I have another algorithm that scans my current Alpaca positions currently every second (easy to modify) and ‘chases’ each position with a stop limit order.
Currently, the only calls being made to Alpaca every second are:
- Initial query to get ALL open orders (to process locally)
- Current price of each stock that it’s currently holding
- Updating an existing order IF certain criteria are met (I.E. price increases by X percent or a new candle posts, etc)
I really don’t think I should be hitting API rate limits, but I’m seeing a small pattern of some INITIAL stop limit orders being ‘rejected’ or ‘cancelled’ for up to a couple iterations/seconds without any errors in the request.post response (to “v2/orders”). I put some logic in my script to handle this and usually they stick after a couple iterations. Annoying, but no biggie. However, today, I had one particular stop limit UPDATE that simply was “rejected” every iteration for about 2 minutes where I gave up and manually intervened (huge confidence killer).
The frustrating thing is the response from my requests.patch (using https://api.alpaca.markets/v2/orders/ + order[‘id’]) returned perfectly fine with no errors and included the correct stop price and looked exactly like I would expect it to. However, the dashboard showed “rejected” and the next iteration of my script still pulled the “old” order info which then triggered it to send another UPDATE using request.patch and just repeated until I killed it.
What’s up with that and how can I prevent it from happening?
****Below is my logs with some stuff in the middle removed.
The “08:38:08 - Updated limit order for ACLX” is simply the output from:
response = requests.patch(url, json=payload, headers=headers).text
response = json.loads(response)
”***Open Orders:” is the returned list of all open orders from Alpaca:
API_Endpoint + “v2/orders?status=open”
response = requests.get(url, headers=headers).text
response = json.loads(response)
”Found order for: ACLX” is simply locally parsing through the Open Orders and comparing against the known held positions to match an open order to the list of held stocks for processing.
08:38:08 - Updated limit order for ACLX
{
“id”: “556a6811-f095-4638-afb0-6d18f5981109”,
“client_order_id”: “7fde7f54-5ecf-44de-8f72-b954b62dbee7”,
“created_at”: “2026-02-23T14:38:08.681335842Z”,
“updated_at”: “2026-02-23T14:38:08.681949152Z”,
“submitted_at”: “2026-02-23T14:38:08.681335842Z”,
“filled_at”: null,
“expired_at”: null,
“canceled_at”: null,
“failed_at”: null,
“replaced_at”: null,
“replaced_by”: null,
“replaces”: “18891e01-8d25-40a9-8965-8dfff65ae1a1”,
“asset_id”: “c984af2f-f1e3-4c45-9c68-dde36c158782”,
“symbol”: “ACLX”,
“asset_class”: “us_equity”,
“notional”: null,
“qty”: “10”,
“filled_qty”: “0”,
“filled_avg_price”: null,
“order_class”: “”,
“order_type”: “stop_limit”,
“type”: “stop_limit”,
“side”: “sell”,
“position_intent”: “sell_to_close”,
“time_in_force”: “day”,
“limit_price”: “56.98”,
“stop_price”: “113.97”,
“status”: “new”,
“extended_hours”: false,
“legs”: null,
“trail_percent”: null,
“trail_price”: null,
“hwm”: null,
“subtag”: null,
“source”: null,
“expires_at”: “2026-02-23T21:00:00Z”
}
08:38:09 - Processing
Alpaca price = $114.0001
Number of shares held = 10
***Open Orders:
[
{
“id”: “18891e01-8d25-40a9-8965-8dfff65ae1a1”,
“client_order_id”: “a1e96e8f-cdc1-4131-a9e8-2a1f31fd5587”,
“created_at”: “2026-02-23T14:36:00.456166Z”,
“updated_at”: “2026-02-23T14:38:08.695497Z”,
“submitted_at”: “2026-02-23T14:36:00.46287Z”,
“filled_at”: null,
“expired_at”: null,
“canceled_at”: null,
“failed_at”: null,
“replaced_at”: null,
“replaced_by”: null,
“replaces”: “fb79c003-4af3-470e-bf8e-2469fc8b0ab5”,
“asset_id”: “c984af2f-f1e3-4c45-9c68-dde36c158782”,
“symbol”: “ACLX”,
“asset_class”: “us_equity”,
“notional”: null,
“qty”: “10”,
“filled_qty”: “0”,
“filled_avg_price”: null,
“order_class”: “”,
“order_type”: “stop_limit”,
“type”: “stop_limit”,
“side”: “sell”,
“position_intent”: “sell_to_close”,
“time_in_force”: “day”,
“limit_price”: “56.95”,
“stop_price”: “113.89”,
“status”: “new”,
“extended_hours”: false,
“legs”: null,
“trail_percent”: null,
“trail_price”: null,
“hwm”: null,
“subtag”: null,
“source”: “access_key”,
“expires_at”: “2026-02-23T21:00:00Z”
}
]
Found order for: ACLX
{
“id”: “18891e01-8d25-40a9-8965-8dfff65ae1a1”,
“client_order_id”: “a1e96e8f-cdc1-4131-a9e8-2a1f31fd5587”,
“created_at”: “2026-02-23T14:36:00.456166Z”,
“updated_at”: “2026-02-23T14:38:08.695497Z”,
“submitted_at”: “2026-02-23T14:36:00.46287Z”,
“filled_at”: null,
“expired_at”: null,
“canceled_at”: null,
“failed_at”: null,
“replaced_at”: null,
“replaced_by”: null,
“replaces”: “fb79c003-4af3-470e-bf8e-2469fc8b0ab5”,
“asset_id”: “c984af2f-f1e3-4c45-9c68-dde36c158782”,
“symbol”: “ACLX”,
“asset_class”: “us_equity”,
“notional”: null,
“qty”: “10”,
“filled_qty”: “0”,
“filled_avg_price”: null,
“order_class”: “”,
“order_type”: “stop_limit”,
“type”: “stop_limit”,
“side”: “sell”,
“position_intent”: “sell_to_close”,
“time_in_force”: “day”,
“limit_price”: “56.95”,
“stop_price”: “113.89”,
“status”: “new”,
“extended_hours”: false,
“legs”: null,
“trail_percent”: null,
“trail_price”: null,
“hwm”: null,
“subtag”: null,
“source”: “access_key”,
“expires_at”: “2026-02-23T21:00:00Z”
}
Here’s my dashboard screenshot. You can see the wall of “canceled” ACLX’s along with a couple updates that stuck. Similarly, you can see a few of the INITIAL SL orders for VNDA were ‘canceled, but eventually stuck and updated accordingly. As mentioned, I’m seeing no ‘errors’ in my logs from the API calls. I’d love to hear anyone’s thoughts/hypothesis on what’s up with this!
