alpaca-java icon indicating copy to clipboard operation
alpaca-java copied to clipboard

Closing a position without parameters

Open AlexandreHerbreteau opened this issue 7 months ago • 0 comments

Hello,

a position can be closed through the API without parameters: https://docs.alpaca.markets/reference/deleteopenposition-1

(qty or percentage). In this case, the total position is sold, which results in closing it entirely.

With the alpaca-java, it's not possible to close a full position, we have to pass both qty and percentage: https://javadoc.io/doc/net.jacobpeterson.alpaca/alpaca-java/latest/net/jacobpeterson/alpaca/openapi/trader/api/PositionsApi.html#deleteOpenPosition(java.lang.String,java.math.BigDecimal,java.math.BigDecimal)

Btw, javadoc mentions that those parameters are optional. But how to call deleteOpenPosition without passing those parameters ?

Thanks

AlexandreHerbreteau avatar Jun 17 '25 20:06 AlexandreHerbreteau