Making fractional sales

So I see that to make a fractional buy, I run this (from alpaca-py):

        market_order_data = MarketOrderRequest(
                                symbol=ticker,
                                notional=100,
                                side=OrderSide.BUY,
                                time_in_force=TimeInForce.DAY
                            )

Which will create a purchase order for $100 worth of “ticker” but on the other side, how does a sale work when it’s notional?

For instance, if I buy $100 worth of AAPL and then it runs up 10% and I want to sell all of it, do I need to run the below command?

        market_order_data = MarketOrderRequest(
                                symbol='AAPL',
                                notional=110,
                                side=OrderSide.SELL,
                                time_in_force=TimeInForce.DAY
                            )

In which case, do I have to keep track of the dollar value of the security within my algorithm in order to submit the appropriate notional sales amount? Or is there a way to “sell-all” for a security?

Also let’s say that my investment in AAPL goes up to $109.32, do I also need to ensure I’m using the correct sig figs when rounding?

@redcoatwright Do not use notional orders to completely close a position. Either use a sell order with the qty equal to your position qty, or use the ClosePositionRequest method. The ClosePositionRequest method will automatically fetch the current position qty and place a sell order for that amount. That method is also nice in that a ‘percent’ parameter can be added. So one could, for example, close 50% of one’s position (ie sell 50% of one’s shares.

You are a god. Thank you! I didn’t see the ClosePositionRequest method

Hey Dan, me again, so I’m looking in the repo at the ClosePositionRequest class.

I notice it only takes qty or percentage (and not a symbol), how do I specify which symbol to liquidate or do I need to somehow retrieve a position object from the API?

Edit: I found this link: Positions - Alpaca-py
with instructions on closing just a position, it looks a bit different but I’ll give that a shot.