alpaca-trade-api-js
alpaca-trade-api-js copied to clipboard
Close Position by symbol not accepting qty - no of shares to liquidate
As per the Alpaca docs - Close a position by symbol endpoint - [DELETE]/v2/positions/{symbol}
Accepts a query parameter qty - the number of shares to liquidate
, But this nodejs implementation varient doesn't accepting qty query parameter.
docs url: https://alpaca.markets/docs/api-documentation/api-v2/positions

API usage:
Close a Position
Calls DELETE /positions/{symbol} and liquidates your position in the given symbol.
closePosition(symbol) => Promise
Notice No qty parameter here
Implementation - https://github.com/alpacahq/alpaca-trade-api-js/blob/master/lib/resources/position.js
function closeAll() {
return this.httpRequest('/positions', null, null, 'DELETE')
}
Please Advise us on how to use utilize this. Basically want to achieve Close a position by symbol with N qty.
Thanks.
As I understand from documentation, you just have to provide Query parametr, not Body/Post parameter. So simple:
closePosition(symbol) => Promise
closePosition("AAPL?qty=0.0001")