The GetAssets API call is returning multiple assets with the same symbol, class, and exchange - but with different id’s. How are we supposed to determine which asset is correct? Example below (different id’s and one has fractional
set to true
, while the other is false
:
const assets = await alpaca.getAssets({ class: 'us_equity' });
assets.filter((x) => x.symbol === 'MSP');
returns:
[
{
"id": "9cd9de18-5d0e-4c39-bece-45e0e7afdacc",
"class": "us_equity",
"exchange": "NYSE",
"symbol": "MSP",
"name": "Datto Holding Corp.",
"status": "inactive",
"tradable": false,
"marginable": false,
"maintenance_margin_requirement": 100,
"shortable": false,
"easy_to_borrow": false,
"fractionable": false,
"attributes": []
},
{
"id": "9b384de2-3f7b-43db-81d1-a5e394118dcb",
"class": "us_equity",
"exchange": "NYSE",
"symbol": "MSP",
"name": "Datto Holding Corp.",
"status": "inactive",
"tradable": false,
"marginable": false,
"maintenance_margin_requirement": 100,
"shortable": false,
"easy_to_borrow": false,
"fractionable": true,
"attributes": []
}
]
Here is another example - where one asset is active
and the other is inactive
:
[
{
"id": "36e4425b-f80d-4689-be47-3cda0f9773cd",
"class": "us_equity",
"exchange": "NASDAQ",
"symbol": "ARRY",
"name": "Array Technologies, Inc. Common Stock",
"status": "inactive",
"tradable": false,
"marginable": false,
"maintenance_margin_requirement": 100,
"shortable": false,
"easy_to_borrow": false,
"fractionable": false,
"attributes": []
},
{
"id": "fc5dacba-4890-4e7c-bf8e-edbdce826fb8",
"class": "us_equity",
"exchange": "NASDAQ",
"symbol": "ARRY",
"name": "Array Technologies, Inc. Common Stock",
"status": "active",
"tradable": true,
"marginable": true,
"maintenance_margin_requirement": 30,
"shortable": true,
"easy_to_borrow": true,
"fractionable": true,
"attributes": [
"fractional_eh_enabled",
"has_options"
]
}
]
@krsherm There may be multiple instances of a symbol but only one (or none) will have an active status. The only assets one typically is interested in have a status of active
. Every time there is a CUSIP change a new asset is created. Many corporate actions such as stock splits will create a new CUSIP but retain the same symbol.
You can filter for these in your initial call to getAssets
by providing a status parameter. Something like this
getAssets({ class: 'us_equity', status: 'active' }
Of course you could also filter the list after you have fetched all statuses.
1 Like
Appreciate the insight @Dan_Whitnable_Alpaca. I maintain a separate list of all assets, so I need to be able to flip assets from active → inactive. So now i’m just grabbing active assets and then setting anything that is active in my list, but isn’t in the alpaca list, to inactive. FYI, when calling getAssets({ class: 'us_equity', status: 'active', tradable: true })
the tradable: true
filter does not work, so I’m filtering after the fact. Problem solved - thank you again.