Technical Analysis (TA) is an easy to use library that is built upon Python's Pandas library with more than 80 Indicators. These indicators are comminly used for financial time series datasets with columns or labels similar to: datetime, open, high, low, close, volume, et al. Many commonly used indicators are included, such as: Moving Average Convergence Divergence (MACD), Hull Exponential Moving Average (HMA), Bollinger Bands (BBANDS), On-Balance Volume (OBV), Aroon Oscillator (AROON) and more.
This version contains both the orignal code branch as well as a newly refactored branch with the option to use Pandas DataFrame Extension mode. All the indicators return a named Series or a DataFrame in uppercase underscore parameter format. For example, MACD(fast=12, slow=26, signal=9) will return a DataFrame with columns: ['MACD_12_26_9', 'MACDH_12_26_9', 'MACDS_12_26_9'].
ta.trend_return()
, has a proper index. More consistent with the module.df.ta.adjusted = None
. If the adjusted close column is 'adj_close' for example, then set df.ta.adjusted = 'adj_close'
.A Pandas DataFrame Extension, extends a DataFrame allowing one to add more functionality and features to Pandas to suit your needs. As such, it is now easier to run Technical Analysis on existing Financial Time Series without leaving the current DataFrame. This extension by default returns the Indicator result or, inclusively, it can append the result to the existing DataFrame by including the parameter 'append=True' in the method call. See examples below.
$ pip install pandas_ta
$ pip install -U git+https://github.com/twopirllc/pandas-ta
import pandas as pd
import pandas_ta as ta
# Load data
df = pd.read_csv('symbol.csv', sep=',')
# Calculate Returns and append to the df DataFrame
df.ta.log_return(cumulative=True, append=True)
df.ta.percent_return(cumulative=True, append=True)
# New Columns with results
df.columns
# Take a peek
df.tail()
# vv Continue Post Processing vv
import pandas as pd
import pandas_ta as ta
# Help about this, 'ta', extension
help(pd.DataFrame().ta)
# List of all indicators
pd.DataFrame().ta.indicators()
# Help about the log_return indicator
help(ta.log_return)
# Help about the log_return indicator as a DataFrame Extension
help(pd.DataFrame().ta.log_return)
# Set ta to default to an adjusted column, 'adj_close', overriding default 'close'
df.ta.adjusted = 'adj_close'
df.ta.sma(length=10, append=True)
# To reset back to 'close', set adjusted back to None
df.ta.adjusted = None
Moving Average Convergence Divergence (MACD) |
---|
Simple Moving Averages (SMA) and Bollinger Bands (BBANDS) |
---|
Use parameter: cumulative=True for cumulative results.
Percent Return (Cumulative) with Simple Moving Average (SMA) |
---|
Z Score |
---|
Average Directional Movement Index (ADX) |
---|
![]() |
Average True Range (ATR) |
---|
![]() |
On-Balance Volume (OBV) |
---|
![]() |
Please leave any comments, feedback, or suggestions.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。