Skip to main content

tatspy

A package to calculate time series of technical analysis indicators for stocks

Description

tatspy is a package you can use to get information such as:

  • the historical prices of a stock over a given period
  • the 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 contents

The tatspy package defines a class called stock. It receives two attributes: the stock's ticker and its country This 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 indicators
  • lag_indicators: returns a dataframe with specified lags of technical analysis indicators, for Time Series analysis

The outputs of these methods are also saved as class attributes within each instance.

Available Technical Analysis Indicators

At present, the following technical analysis indicators are made available by tatspy:

  1. 'simple_moving_average' : simple moving average of stock price
  2. 'exponential_moving_average': exponential moving average of stock price
  3. 'RSI': Relative Strength Index
  4. 'bollinger_bands': Bollinger Bands
  5. 'bollinger_bands_indicator': Indicates if stock price close to bands, suggesting price reversal
  6. 'MACD' : Moving Average Convergence-Divergence
  7. 'stochastic': Stochastic Oscillator
  8. 'VWAP': Volume Weighted Average Price
  9. 'ATR': Average True Range
  10. 'ADX': Average Directional Index
  11. 'parabolic_SAR': Parabolic SAR
  12. 'parabolic_SAR_indicator: Indicates if parabolic SAR suggests a price reversal upwards (+1) or downwards (-1)
  13. 'TRIX': Triple Exponential Average

Installing tatspy

Just pip install it:

!pip install tatspy

Quick start

Suppose you're interested in stocks from Brazil's retailer Magalu (ticker = mglu3), year-to-date.

First, load the stock class:

from tatspy.stock_class import stock

Now, 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_prices

To 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_indicators

Now suppose you want to lag these indicators by 5 and 10 days. You can simply run...

>>> my_stock.lag_indicators(lags=[5,10])

Citations

I am grateful for the authors of the following packages, which have been very helpful in building tatspy:

Metadata

Release files for tatspy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for tatspy 0.1.0
File Interpreter ABI Platform
tatspy-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / tatspy-0.1.0-py3-none-any.whl

Download URL tatspy-0.1.0-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71c6a2df5f63f1077159e6567de1f4139414ad119dc0607570b36a7863713a05
BLAKE2b-256 checksum
How to use checksums
639ec39a6eb1f2cf2047a51101adfaed9bb64dc4dcf5c91d31654f0a0be7d3b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page