Instruments¶
The Instruments endpoints allow for retrieval of instrument and fundamental data. These endpoints are Search Instruments and Get Instrument.
Get Instrument¶
pyTD provides access to Get Instruments through the get_instrument
function. Simply enter a symbol:
In [1]: from pyTD.instruments import get_instrument
In [2]: get_instrument("AAPL")
Out[2]:
AAPL
assetType EQUITY
cusip 037833100
description Apple Inc. - Common Stock
exchange NASDAQ
symbol AAPL
or a CUSIP ID:
In [3]: get_instrument("68389X105")
Out[3]:
68389X105
assetType EQUITY
cusip 68389X105
description Oracle Corporation Common Stock
exchange NYSE
symbol ORCL
Search Instruments¶
Search Instruments is implemented through get_instruments
.
projection
¶
There are five types of searches which can be performed:
1. symbol-search
(default): Retrieve instrument data of a specific symbol
or CUSIP
(similar to get_instrument
)
In [4]: from pyTD.instruments import get_instruments
In [5]: get_instruments("AAPL")
Out[5]:
AAPL
assetType EQUITY
cusip 037833100
description Apple Inc. - Common Stock
exchange NASDAQ
symbol AAPL
2. symbol-regex
: Retrieve instrument data for all symbols matching regex.
Example: symbol=XYZ.*
will return all symbols beginning with XYZ
In [6]: get_instruments("AAP.*", projection="symbol-regex")
Out[6]:
...
assetType ...
cusip ...
description ...
exchange ...
symbol ...
[5 rows x 13 columns]
3. desc-search
: Retrieve instrument data for instruments whose description
contains the word supplied. Example: symbol=FakeCompany
will return all
instruments with FakeCompany in the description.
In [7]: get_instruments("computer", projection="desc-search")
Out[7]:
CMDXF CPSI CSCWI CSVI CTG CMSQF CMSQY
assetType EQUITY EQUITY EQUITY EQUITY EQUITY EQUITY EQUITY
cusip 205249105 205306103 205363112 20539A105 205477102 Q2721E105 20557R105
description Computer Modelling Group Ordinary Shares (GM) Computer Programs and Systems, Inc. - Common S... Computer Sciences Corp. Computer Services Inc Ky Common Stock (QX) Computer Task Group, Incorporated - Common Stock Computershare Ltd Aud 0.20 Ordinary Shares (PC) Computershare Ltd Sponsored ADR (PC)
exchange Pink Sheet NASDAQ NYSE Pink Sheet NASDAQ Pink Sheet Pink Sheet
symbol CMDXF CPSI CSCWI CSVI CTG CMSQF CMSQY
4. desc-regex
: Search description with full regex support. Example:
symbol=XYZ.[A-C]
returns all instruments whose descriptions contain a word
beginning with XYZ followed by a character A through C.
In [8]: get_instruments("COM.*", projection="desc-regex")
Out[8]:
...
assetType ...
cusip ...
description ...
exchange ...
symbol ...
[5 rows x 44 columns]
fundamental
: Returns fundamental data for a single instrument specified by exact symbol.
In [9]: get_instruments("AAPL", projection="fundamental").head()
Out[9]:
AAPL
beta 1.09174
bookValuePerShare 2.79895
currentRatio 1.12384
divGrowthRate3Year 0
dividendAmount 2.92