# Position closing endpoints

**URL:** <https://forum.alpaca.markets/t/position-closing-endpoints/1206>\
**Category:** Alpaca Integration Applications\
**Created:** [April 16, 2020, 5:31pm UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206 "2020-04-16T17:31:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/casey/32/546_2.png) [@Casey](https://forum.alpaca.markets/u/Casey)\
**Post date:** [April 16, 2020, 5:31pm UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/1 "2020-04-16T17:31:58Z")

</div>

Please consider making the cancellation of existing orders a default action included in the DELETE positions endpoints. I would expect that if a trader wants to rapidly exit a position at market, they would not want to have to worry about finding and cancelling existing orders. That seems like a backend job.

Currently an error is returned if there are competing open orders, like so:

```
{
    "available": "0",
    "code": 40310000,
    "existing_qty": "1000",
    "held_for_orders": "1000",
    "message": "insufficient qty available for order (requested: 1000, available: 0)",
    "related_orders": [
        "305c0579-9390-4daf-bb85-fe56491926af"
    ],
    "symbol": "AMD"
}
```

---

<div class="post-metadata">

**Author:** ![hitoshi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/hitoshi/32/69_2.png) [@hitoshi](https://forum.alpaca.markets/u/hitoshi)\
**Post date:** [April 16, 2020, 5:52pm UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/2 "2020-04-16T17:52:11Z")

</div>

That makes sense. It could be additional parameter to do the extra work in backend.

---

<div class="post-metadata">

**Author:** ![Casey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/casey/32/546_2.png) [@Casey](https://forum.alpaca.markets/u/Casey)\
**Post date:** [April 17, 2020, 2:00am UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/3 "2020-04-17T02:00:21Z")

</div>

Yes, that would be a great solution.

---

<div class="post-metadata">

**Author:** ![synchronicity](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/synchronicity/32/824_2.png) [@synchronicity](https://forum.alpaca.markets/u/synchronicity)\
**Post date:** [May 15, 2020, 7:12pm UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/4 "2020-05-15T19:12:10Z")

</div>

Seconding this. Close all positions should just close all positions, full stop. I can only see the usefulness of this endpoint being akin to a killswitch, but it doesn’t really serve that purpose if the positions have associated orders. As I’m building AlpacaforR, I’m going to have the function that calls this endpoint cancel all orders first as a workaround but would like to see the endpoint modified such that it does this automatically.

---

<div class="post-metadata">

**Author:** ![hitoshi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/hitoshi/32/69_2.png) [@hitoshi](https://forum.alpaca.markets/u/hitoshi)\
**Post date:** [May 19, 2020, 7:09pm UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/5 "2020-05-19T19:09:24Z")

</div>

Make sense. It shouldn’t be too hard to add it…

---

<div class="post-metadata">

**Author:** ![Tony](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/tony/32/799_2.png) [@Tony](https://forum.alpaca.markets/u/Tony)\
**Post date:** [May 21, 2020, 12:07am UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/6 "2020-05-21T00:07:16Z")

</div>

May I know if the feature is added ? How to check if there’s any feature updated ?

---

<div class="post-metadata">

**Author:** ![hitoshi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/hitoshi/32/69_2.png) [@hitoshi](https://forum.alpaca.markets/u/hitoshi)\
**Post date:** [May 21, 2020, 12:30am UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/7 "2020-05-21T00:30:29Z")

</div>

It is not added yet. We will let you know.

---

<div class="post-metadata">

**Author:** ![runzeta](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/runzeta/32/785_2.png) [@runzeta](https://forum.alpaca.markets/u/runzeta)\
**Post date:** [May 21, 2020, 5:07pm UTC](https://forum.alpaca.markets/t/position-closing-endpoints/1206/8 "2020-05-21T17:07:35Z")

</div>

looking forward to seeing this implemented!
