Check whether symbol can be shorted

Hello, I tried to sell the IAU ticker today but i got the message that this can not be done.
How can I check in general, prior to enducing my trading startegy, whether a symbol can be shorted, to avoid any troubles afterwards?

I believe if you check the asset object there is a property for shortable you can check. I think it’s a Boolean.

1 Like
import alpaca_trade_api as tradeapi
from alpaca_arb import config

# Set your Alpaca API key and secret
API_KEY = config.API_KEY
API_SECRET = config.API_SECRET
BASE_URL = config.ENDPOINT  # Use 'https://api.alpaca.markets' for live trading

# Function to check if an asset is shortable
def check_shortability(api, symbol):
    try:
        # Get asset information
        asset = api.get_asset(symbol)

        # Check if the asset is shortable
        is_shortable = asset.shortable

        return is_shortable
    except Exception as e:
        print(f"Error occurred: {str(e)}")
        return None

# Initialize Alpaca API
api = tradeapi.REST(API_KEY, API_SECRET, BASE_URL)

# Get user input for the symbol
symbol = input("Enter the symbol of the asset you want to check: ")

# Check if the asset is shortable
shortable = check_shortability(api, symbol)