btb.libstocks package

Submodules

btb.libstocks.stocks module

synopis:

An aggregation of stock data with a simple API.

class btb.libstocks.stocks.Stocks(index=None)[source]

Bases: object

Provides stock data for a selected stock from the top 1000 measured by market capitial.

Parameters:

index (int) – Index for selected stock into the list of stocks sorted by market capitalization. If not specified a random index will be selected, defaults to None.

property country: str

Returns the contry of the selected stock. For this data set all stocks are U.S. stocks.

Returns:

Country.

property description: str

Returns a short description of the selected stock.

Returns:

Stock description.

property divdend: str

Returns the dividend yield of the selected stock. A dividend is a distribution of a portion of a company’s earnings, decided by the board of directors, paid to a class of its shareholders.

Returns:

Dividend yield.

find_ticker_by_instrument_id(instrument_id) str[source]

Uses a Robinhood instrument ID to find the associated stock ticker within the data set.

Parameters:

instrument_id (str) – Instrument ID used to find associated stock ticker.

Returns:

Stock ticker.

property market_cap: str

Returns the market capitalization of the selected stock. Market capitalization is the total dollar value of all outstanding shares of a company at the current market price.

Returns:

Market capitalization.

property sector: str

The sector of the selected stock. The market sector is a part of the economy, usually broader than an industry. Two industries may form part of one market sector. The eleven sectors are:

  1. Communication services

  2. Consumer discretionary

  3. Consumer staples

  4. Energy

  5. Financials

  6. Healthcare

  7. Industrials

  8. Information technology

  9. Materials

  10. Real estate

  11. Utilities

Returns:

Sector.

size() int[source]

Returns the number of elements in the data set.

Returns:

The number of elements in the data set.

property symbol: str

The symbol (ticker) of the selected stock. A stock symbol is a unique series of letters assigned to a security for trading purposes.

e.g. AAPL for the computer company Apple.

Returns:

Symbol.

Module contents