Package: tessa
tessa – simple, hassle-free access to price information of financial assets 📉🤓📈tessa is a Python library to help youeasily search asset identifiers(e.g.,
tickers) andretrieve price informationfor assets from different sources such as
Yahoo or Coingecko. It takes care of the different APIs, caching, rate limiting, and
other hassles.tessa provides aSymbol class that encapsulates nicely the methods relevant for a
symbol. tessa also provides functionality tomanage collections of symbols, store
and load them, and extend their functionality.Finally, tessa makes sure to be nice to the sites being accessed and tries toprevent
users from being blocked by 429 rate limiting errorsby 1) caching results upon
retrieval and 2) keeping track of request timestamps and waiting appropriate amounts of
time if necessary. tessa also automatically waits and retries requests that fail with a
5xx error.→ Check out the full documentation. 📖How to useHere's a longer example that quickly shows all aspects of the library. Refer to
submodulessymbol,search, andpricefor more information.Imports:fromtessaimportSymbol,SymbolCollection,searchCreate a symbol for MSFT and access some functions:s1=Symbol("MSFT")# will use "yahoo" as the default sources1.price_latest()# get latest priceCreate another symbol from a bloomberg ticker as it is used by Yahoo Finance:s2=Symbol("SREN.SW")s2.price_point("2022-06-30")# get price at specific point in timeCreate a symbol from the coingecko source with an id as it is used by coingecko:s3=Symbol("bitcoin",source="coingecko")s3.price_graph()# show price graphSearch for a crypto ticker on coingecko:res=search("name")# search and print search result summaryfiltered=res.filter(source="coingecko")# filter resultsfiltered.p()# print summary of filtered resultsfiltered.buckets[1].symbols# review the 2nd bucket in the filtered resultss4=filtered.buckets[1].symbols[2]# our symbol is the 3rd in that lists4.price_history()# get entire historyBuild a collection of several symbols and use the collection to retrieve symbols:sc=SymbolCollection([s1,s2,s3,s4])sc.add(Symbol("AAPL"))# add another onesc.find_one("SREN").price_graph()Store and load a symbol collection:sc.save_yaml("my_symbols.yaml")sc_new=SymbolCollection()sc_new.load_yaml("my_symbols.yaml")Use a different currency preference:sc.find_one("ens").price_latest()# will return price in USDSymbol.currency_preference="CHF"sc.find_one("ens").price_latest()# will return price in CHFNote thatcurrency_preferencewill only have an effect with sources that support it.
It is supported for Coingecko but not for Yahoo. So you should always verify the
effective currency you receive in the result.Data sourcestessa builds onyfinanceandpycoingeckoand offersa simplified and
unified interface.Why these two sources? Yahoo Finance (via yfinance) is fast and offers an extensive
database that also contains many non-US markets. Coingecko (via pycoingecko) offers
great access to crypto prices. While Yahoo Finance also offers crypto information,
pycoingecko has the advantage that you can have the prices quoted in many more currency
preferences (a function that is also exposed via tessa).More sources can be added in the future. Let me know in theissuesof you have a particular request.Main submodulessymbol: working with symbols and symbol collections.search: searching the different sources.price: accessing price functions directly instead of via theSymbolclass.sources: if you'd like to add additional sources to the library.How to installpip install tessaPrerequisitesSeepyproject.toml. Major prerequisites are theyfinanceandpycoingeckopackages
to access finance information as well as thebeautifulsoup4package to do some
scraping for searching on Yahoo Finance.Repositoryhttps://github.com/ymyke/tessaFuture WorkThis is an initial version. There are a number of ideas on how to extend. Please leave
your suggestions and comments in theIssues
section.On terminologyI'm using symbol instead of ticker because a ticker is mainly used for stock on stock
markets, whereas tessa is inteded to be used for any kind of financial assets, e.g. also
crypto.Other noteworthy librariesstrela: A python package for financial alerts.pypme: A Python package for PME (Public Market
Equivalent) calculation.On investpy as a data sourceTessa used to use theinvestpy packageas the
main source of information until mid 2022 until investing.com introduced Cloudflare,
which broke access by investpy. 😖 It is currently unclear if investpy will be available
again in the future.You can follow the developments in issue
600.The old tessa/investpy code is
still available in theadd-symbols-based-on-investpy
branch.