Here’s some documentation and a code example on how to submit short orders through Alpaca. Examples are available in C# and Python.
I understand how to short. But confuses me a little is that the documentation says
Any order that would increase your position (e.g. buy orders when your position is >= 0, sell orders when your position is <= 0) reduce buying power by their 104% of their order value (1.04 * qty * price).
Does that mean that if I have 100K on my account I can only buy/short 96K worth of stocks?
Also, say I buy $100 of AAPL stocks. This operation would reduce my buying power by $104? Also, if I sell at the same price, $100 (no profit or loss), I recover buying power back to 100K?
Hi. You are right, this could be worded much better, so we’ve gone ahead and revised as follows:
- Market buy orders that would increase your position (e.g. buy order for a stock where your position in that stock is >= 0) are converted to marketable limit orders with a 2.5% to 4% price collar.
- Market sell orders that would increase your position (e.g. sell order for a stock when your position in that stock is <= 0) are NOT converted but are subject to a pre-trade buying power risk check of 102.5 to 104% of the order value.
The key point is how we handle market orders for opening new positions (as opposed to closing an existing position) to help ensure you do not exceed your available buying power. Please note that these are pre-trade risk checks, so once the order filled, your buying power would decrease by the actual cost of the trade, not the order value. To consume every last bit of available buying power, you would only use limit orders instead of market orders.
Now post the code to check the position price against the purchase price and the sell order to close.