Welcome to cad_tickers’s documentation!

https://codecov.io/gh/FriendlyUser/cad_tickers/branch/master/graph/badge.svg

Canadian Securities Exchange

Functions to download tickers from the cse

cad_tickers.exchanges.cse.get_cse_files(filename='cse.xlsx', filetype='xlsx') → str

Gets excel spreadsheet from api.tsx using requests

Parameters:
filename: Name of the file to be saved exchanges: TSX, TSXV
Returns:
filePath returns path to file

See ://stackoverflow.com/questions/13567507/passing-csrftoken-with-python-requests

TSX Functions

Set of functions to scrap ticker data from the toronto stock exchange

cad_tickers.exchanges.tsx.add_descriptions_to_df(df) → pandas.core.frame.DataFrame

Description: single process solution to fetching descriptions

Input:
df: dataframe containing tickers
Returns:
df: updated dataframe with a descriptions if available
cad_tickers.exchanges.tsx.add_descriptions_to_df_pp(df) → pandas.core.frame.DataFrame

Description: fetch descriptions for tickers in parallel noticable speedup

Input:
df: dataframe containing tickers
Returns:
df: updated dataframe with a descriptions if available
cad_tickers.exchanges.tsx.company_description_by_ticker(ticker) → str

Description: Grabs searchable ticker from quotemedia using tmx ticker

Input:
ticker: string
Returns:
df: updated dataframe with a descriptions if available
cad_tickers.exchanges.tsx.dl_tsx_xlsx(filename=None, **kwargs) → str

Description: Gets excel spreadsheet from the tsx api using programatically

Note

Replicates api calls in TSX discover tool with all parameters. See migreport search Note that not all parameters are documented and/or limited validation

Parameters:
filename: Name of the file to be saved
Kwargs:
exchanges (string): TSX, TSXV marketcap (string): values from 0 to specified value sectors (string): cpc, clean-technology, closed-end-funds, technology
Returns:
data: returns path to file or pandas dataframe

See passing csrftoken

cad_tickers.exchanges.tsx.get_description_for_ticker(ticker)

set of functionality

cad_tickers.exchanges.tsx.get_mig_report(filename='', exchange='TSX', return_df=False) → str

Gets excel spreadsheet from api.tsx using requests

Parameters:
filename: Name of the file to be saved exchanges: TSX, TSXV return_df: Return a pandas dataframe
Returns:
filePath: returns path to file or dataframe

See ://stackoverflow.com/questions/13567507/passing-csrftoken-with-python-requests

cad_tickers.exchanges.tsx.grab_symbol_for_ticker(ticker) → str
Description:
Grabs the first symbol from ticker data all symbols should lead to valid webpages for data scrapping TODO If anyone wants to validate that, be my guest
Parameters:
ticker: string representing the stock ticker
Returns:
symbol: string - searchable string in the quotemedia api or empty string
cad_tickers.exchanges.tsx.lookup_symbol_by_ticker(ticker) → list

Description: Returns search array dictionary for tickers

Note

sometimes the name of the ticker in the xlsx sheet is off slightly and we need to find the “real ticker”. Uses standard api (not graphql) to grab tickers

Example searchpoint is https://app.quotemedia.com/lookup?callback=tmxtickers&q=zmd&limit=5&webmasterId=101020

See Tmx Graphql and the new tmx site

Input:
ticker: tmx ticker
Output:
quote_data: list of ticker metadata

Examples

Grab Descriptions for all tsx tickers

from cad_tickers.exchanges.tsx import dl_tsx_xlsx, add_descriptions_to_df_pp
from datetime import datetime
start_time = datetime.now()
df = dl_tsx_xlsx()
# df = add_descriptions_to_df(df)
df = add_descriptions_to_df_pp(df)
end_time = datetime.now()
df.to_csv('tsx_all_descriptions.csv')
print(end_time - start_time)

Indices and tables