# Help with Python coding, sell all at the close

**URL:** <https://forum.alpaca.markets/t/help-with-python-coding-sell-all-at-the-close/10632>\
**Category:** Alpaca Integration Applications\
**Created:** [September 19, 2022, 1:35pm UTC](https://forum.alpaca.markets/t/help-with-python-coding-sell-all-at-the-close/10632 "2022-09-19T13:35:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![V-Spec](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/v-spec/32/4662_2.png) [@V-Spec](https://forum.alpaca.markets/u/V-Spec)\
**Post date:** [September 19, 2022, 1:35pm UTC](https://forum.alpaca.markets/t/help-with-python-coding-sell-all-at-the-close/10632/1 "2022-09-19T13:35:19Z")

</div>

Trying to make a script that will sell all open positions at the close, im a bit stuck

portfolio = api.list\_positions()  
for position in portfolio:

print(“{} shares of {}”.format(position.qty, position.symbol))

order = api.submit\_order(position.symbol,position.qty,‘sell’,‘market’,‘cls’)

Not sure how to feed multiple open positions in to those submit\_orders.

Im not the best at coding, any help would be nice.

Rich

---

<div class="post-metadata">

**Author:** ![V-Spec](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/v-spec/32/4662_2.png) [@V-Spec](https://forum.alpaca.markets/u/V-Spec)\
**Post date:** [September 25, 2022, 11:48pm UTC](https://forum.alpaca.markets/t/help-with-python-coding-sell-all-at-the-close/10632/2 "2022-09-25T23:48:38Z")

</div>

ive figured this out now - moderators please close
