Package: tatspy
tatspyA package to calculate time series of technical analysis indicators for stocksDescriptiontatspy is a package you can use to get information such as:the historical prices of a stock over a given periodthe values of technical analysis indicators (such as MACD, bollinger bands etc.) over a given period.It features not only american stocks, but also stocks from around the globe, featuring countries such as Brazil, Spain, and others.For example...For example, you could use tatspy to get the daily values of the MACD, bollinger bands, parabolic SAR and ATR (among other) for Brazilian's oil giant Petrobras.Package contentsThe tatspy package defines a class calledstock.
It receives two attributes: the stock'stickerand itscountryThis stock has a couple of useful methods:get_stock_historical_prices: returns the historical prices (OHLC) of a stock for a given period, defined by the user.get_technical_indicators: returns a dataframe with time series for a set of technical analysis indicatorslag_indicators: returns a dataframe with specified lags of technical analysis indicators, for Time Series analysisThe outputs of these methods are also saved as class attributes within each instance.Available Technical Analysis IndicatorsAt present, the following technical analysis indicators are made available by tatspy:'simple_moving_average' : simple moving average of stock price'exponential_moving_average': exponential moving average of stock price'RSI': Relative Strength Index'bollinger_bands': Bollinger Bands'bollinger_bands_indicator': Indicates if stock price close to bands, suggesting price reversal'MACD' : Moving Average Convergence-Divergence'stochastic': Stochastic Oscillator'VWAP': Volume Weighted Average Price'ATR': Average True Range'ADX': Average Directional Index'parabolic_SAR': Parabolic SAR'parabolic_SAR_indicator: Indicates if parabolic SAR suggests a price reversal upwards (+1) or downwards (-1)'TRIX': Triple Exponential AverageInstalling tatspyJust pip install it:!pipinstalltatspyQuick startSuppose you're interested in stocks from Brazil's retailer Magalu (ticker = mglu3), year-to-date.First, load thestockclass:fromtatspy.stock_classimportstockNow, create an instance of this class:>>>my_stock=stock('mglu3','brazil')To get historical prices and volume, run...>>>my_stock.get_stock_historical_prices()This command will return a dataframe with OHLC prices and volume, which you can save as a variable.
Alternatively, you can also access this dataframe using...>>>my_stock.historical_pricesTo get technical analysis indicators for the same period, just run...>>>my_stock.get_technical_indicators()This command will return a dataframe with technical indicators, which you can save as a variable.
Alternatively, you can also access this dataframe using...>>>my_stock.technical_indicatorsNow suppose you want to lag these indicators by 5 and 10 days.
You can simply run...>>>my_stock.lag_indicators(lags=[5,10])CitationsI am grateful for the authors of the following packages, which have been very helpful in building tatspy:Alvaro Bartolome del Canto. (2018-2020). investpy - Financial Data Extraction from Investing.com with Python.https://github.com/alvarobartt/investpy.DarÃ­o LÃ³pez Padial (aka Bukosabino). ta.https://github.com/bukosabino/ta.