I have ESGC in my LIVE portfolio. It’s no longer tradable, so how do I liquidate the position? Alpaca support guys, please answer ASAP, this is about REAL money that I entrusted to you.
I see ESGC as tradable (as of 9-25-2020 10:47 EDT). What are you seeing that makes you think otherwise?
Thanks, was able to liquidate it manually, but Alpaca API didn’t return it among a list of tradable assets. tradeapi.REST.get_asset(‘ESGC’) returns an empty response. Any idea why?
Hmm. Are you using Python with alpaca_trade_api
? What is the complete code (with imports)? The following returns the asset for me
import alpaca_trade_api as alpacaapi
ALPACA_API_ENDPOINT = 'https://api.alpaca.markets'
ALPACA_API_KEY_ID = 'xxxxxxxx'
ALPACA_API_SECRET_KEY = 'xxxxxxxxxxx'
api = alpacaapi.REST(ALPACA_API_KEY_ID,
ALPACA_API_SECRET_KEY,
ALPACA_API_ENDPOINT
)
esgc = api.get_asset('ESGC')
print(esgc)
This fetches the asset and prints
Asset({ 'class': 'us_equity',
'easy_to_borrow': True,
'exchange': 'NYSE',
'id': '3592e9dd-8ef5-446a-84c4-f316633830df',
'marginable': True,
'name': 'Eros STX Global Corporation',
'shortable': True,
'status': 'active',
'symbol': 'ESGC',
'tradable': True})
One thing is that the symbols are case sensitive and must be all caps.
Thanks Dan, I was able to get the asset data. Still, two issues remain:
- ESGC was on my portfolio, so I must have purchased it earlier (likely yesterday), but when I get and parse my closed order history, I can’t find it there. I use api.list_orders() to do that, api being defined as you did in your code. It finds hundreds of my other closed orders, but not this one.
- last night I’ve downloaded the entire list of tradable assets - which I do every night. I did that with api.list_assets(). That was a list of 8692 assets, and ESGC was not on the list.
I think the two issues above are related. Any suggestions would be appreciated.
What code do you use to download and query the asset list. One issue is (as of 9-25-2020 2:30 PM EDT) I see 10163 assets returned by api.list_assets()
. Even the active tradable quantity is larger 8886 rather than the 8692 you found. Here is the code I use (same imports and assignment for api as above)
asset_list = api.list_assets()
# Create a dataframe from the list for easy queries
asset_df = pd.DataFrame([asset._raw for asset in asset_list])
# Query the dataframe for a symbol
esgc = asset_df.query('symbol == "ESGC"')
print(esgc)
# Check the length of the asset list
len(asset_list)
10163
# Check for active tradable stocks
active = asset_df.query('(status=="active") and tradable')
len(active)
8886
How are you checking for a particular symbol?