Pandas Technical Analysis(Pandas TA) is an easy to use library that leverages the Pandas package with more than 130 Indicators and Utility functions and more than 60 TA Lib Candlestick Patterns. Many commonly used indicators are included, such as:Candle Pattern(cdl_pattern),Simple Moving Average(sma)Moving Average Convergence Divergence(macd),Hull Exponential Moving Average(hma),Bollinger Bands(bbands),On-Balance Volume(obv),Aroon & Aroon Oscillator(aroon),Squeeze(squeeze) andmany more.
Note:TA Libmust be installed to useallthe Candlestick Patterns.pip install TA-Lib
.IfTA Libis not installed, then only the builtin Candlestick Patterns will be available.
- Features
- Installation
- Quick Start
- Help
- Issues and Contributions
- Programming Conventions
- Pandas TA Strategies
- DataFrame Properties
- DataFrame Methods
- Indicators by Category
- Performance Metrics
- Changes
- Sources
- Support
- Has 130+ indicators and utility functions.
- BETAAlso Pandas TA will run TA Lib's version, this includes TA Lib's 63 Chart Patterns.
- Indicators in Python are tightly correlated with thede factoTA Libif they share common indicators.
- If TA Lib is also installed, TA Lib computations are enabled by default but can be disabled disabled per indicator by using the argument
talib=False
.- For instance to disable TA Lib calculation forstdev:
ta.stdev(df[ "close" ], length=30, talib=False)
.
- For instance to disable TA Lib calculation forstdev:
- NEW!Include External Custom Indicators independent of the builtin Pandas TA indicators. For more information, see
import_dir
documentation under/pandas_ta/custom.py
. - Example Jupyter Notebook withvectorbtPortfolio Backtesting with Pandas TA's
ta.tsignals
method. - Have the need for speed? By using the DataFramestrategymethod, you getmultiprocessingfor free!Conditions permitting.
- Easily addprefixesorsuffixesorbothto columns names. Useful for Custom Chained Strategies.
- Example Jupyter Notebooks under theexamplesdirectory, including how to create Custom Strategies using the newStrategyClass
- Potential Data Leaks:dpoandichimoku.See indicator list below for details. Set
lookahead=False
to disable.
Pandas TAchecks if the user has some common trading packages installed including but not limited to:TA Lib,Vector BT,YFinance... Much of which isexperimentaland likely to break until it stabilizes more.
- IfTA Libinstalled, existing indicators willeventuallyget aTA Libversion.
- Easy Downloading ofohlcvdata usingyfinance.See
help(ta.ticker)
andhelp(ta.yf)
and examples below. - Some Common Performance Metrics
Thepip
version is the last stable release. Version:0.3.14b
$ pip install pandas_ta
Best choice! Version:0.3.14b
- Includes all fixes and updates betweenpypiand what is covered in this README.
$ pip install -U git+https://github /twopirllc/pandas-ta
This is theDevelopment Versionwhich could have bugs and other undesireable side effects. Use at own risk!
$ pip install -U git+https://github /twopirllc/pandas-ta.git@development
importpandasaspd
importpandas_taasta
df=pd.DataFrame()# Empty DataFrame
# Load data
df=pd.read_csv("path/to/symbol.csv",sep=",")
# OR if you have yfinance installed
df=df.ta.ticker("aapl")
# VWAP requires the DataFrame index to be a DatetimeIndex.
# Replace "datetime" with the appropriate column from your DataFrame
df.set_index(pd.DatetimeIndex(df["datetime"]),inplace=True)
# 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
Someindicator arguments have been reordered for consistency. Usehelp(ta.indicator_name)
for more information or make a Pull Request to improve documentation.
importpandasaspd
importpandas_taasta
# Create a DataFrame so 'ta' can be used.
df=pd.DataFrame()
# Help about this, 'ta', extension
help(df.ta)
# List of all indicators
df.ta.indicators()
# Help about an indicator such as bbands
help(ta.bbands)
Thanks for usingPandas TA!
-
- Have you readthisdocument?
- Are you running the latest version?
$ pip install -U git+https://github /twopirllc/pandas-ta
- Have you tried theExamples?
- Did they help?
- What is missing?
- Could you help improve them?
- Did you know you can easily buildCustom Strategieswith theStrategyClass?
- Documentation couldalwaysbe improved. Can you help contribute?
-
- First, search theClosedIssuesbeforeyouOpena new Issue; it may have already been solved.
- Please be asdetailedas possiblewithreproducible code, links if any, applicable screenshots, errors, logs, and data samples. Youwillbe asked again if you provide nothing.
- You want a new indicator not currently listed.
- You want an alternate version of an existing indicator.
- The indicator does not match another website, library, broker platform, language, et al.
- Do you have correlation analysis to back your claim?
- Can you contribute?
- Youwillbe asked to fill out an Issue even if you email my personally.
Thank you for your contributions!
Pandas TAhas three primary "styles" of processing Technical Indicators for your use case and/or requirements. They are:Standard,DataFrame Extension,and thePandas TA Strategy.Each with increasing levels of abstraction for ease of use. As you become more familiar withPandas TA,the simplicity and speed of using aPandas TA Strategymay become more apparent. Furthermore, you can create your own indicators through Chaining or Composition. Lastly, each indicator either returns aSeriesor aDataFramein Uppercase Underscore format regardless of style.
You explicitly define the input columns and take care of the output.
sma10 = ta.sma(df[ "Close" ], length=10)
- Returns a Series with name:
SMA_10
- Returns a Series with name:
donchiandf = ta.donchian(df[ "HIGH" ], df[ "low" ], lower_length=10, upper_length=15)
- Returns a DataFrame named
DC_10_15
and column names:DCL_10_15, DCM_10_15, DCU_10_15
- Returns a DataFrame named
ema10_ohlc4 = ta.ema(ta.ohlc4(df[ "Open" ], df[ "High" ], df[ "Low" ], df[ "Close" ]), length=10)
- Chaining indicators is possible but you have to be explicit.
- Since it returns a Series named
EMA_10
.If needed, you may need to uniquely name it.
Callingdf.ta
will automatically lowercaseOHLCVAtoohlcva:open, high, low, close, volume,adj_close.By default,df.ta
will use theohlcvafor the indicator arguments removing the need to specify input columns directly.
sma10 = df.ta.sma(length=10)
- Returns a Series with name:
SMA_10
- Returns a Series with name:
ema10_ohlc4 = df.ta.ema(close=df.ta.ohlc4(), length=10, suffix= "OHLC4" )
- Returns a Series with name:
EMA_10_OHLC4
- Chaining Indicatorsrequirespecifying the input like:
close=df.ta.ohlc4()
.
- Returns a Series with name:
donchiandf = df.ta.donchian(lower_length=10, upper_length=15)
- Returns a DataFrame named
DC_10_15
and column names:DCL_10_15, DCM_10_15, DCU_10_15
- Returns a DataFrame named
Same as the last three examples, but appending the results directly to the DataFramedf
.
df.ta.sma(length=10, append=True)
- Appends to
df
column name:SMA_10
.
- Appends to
df.ta.ema(close=df.ta.ohlc4(append=True), length=10, suffix= "OHLC4", append=True)
- Chaining Indicatorsrequirespecifying the input like:
close=df.ta.ohlc4()
.
- Chaining Indicatorsrequirespecifying the input like:
df.ta.donchian(lower_length=10, upper_length=15, append=True)
- Appends to
df
with column names:DCL_10_15, DCM_10_15, DCU_10_15
.
- Appends to
APandas TAStrategy is a named group of indicators to be run by thestrategymethod. All Strategies usemulitprocessingexceptwhen using thecol_names
parameter (seebelow). There are different types ofStrategieslisted in the following section.
# (1) Create the Strategy
MyStrategy=ta.Strategy(
name="DCSMA10",
ta=[
{"kind":"ohlc4"},
{"kind":"sma","length":10},
{"kind":"donchian","lower_length":10,"upper_length":15},
{"kind":"ema","close":"OHLC4","length":10,"suffix":"OHLC4"},
]
)
# (2) Run the Strategy
df.ta.strategy(MyStrategy,**kwargs)
TheStrategyClass is a simple way to name and group your favorite TA Indicators by using aData Class.Pandas TAcomes with two prebuilt basic Strategies to help you get started:AllStrategyandCommonStrategy.AStrategycan be as simple as theCommonStrategyor as complex as needed using Composition/Chaining.
- When using thestrategymethod,allindicators will be automatically appended to the DataFrame
df
. - You are using a Chained Strategy when you have the output of one indicator as input into one or more indicators in the sameStrategy.
- Note:Use the 'prefix' and/or 'suffix' keywords to distinguish the composed indicator from it's default Series.
See thePandas TA Strategy Examples Notebookfor examples includingIndicator Composition/Chaining.
- name:Some short memorable string.Note:Case-insensitive "All" is reserved.
- ta:A list of dicts containing keyword arguments to identify the indicator and the indicator's arguments
- Note:A Strategy will fail when consumed by Pandas TA if there is no
{ "kind": "indicator name" }
attribute.Rememberto check your spelling.
- description:A more detailed description of what the Strategy tries to capture. Default: None
- created:At datetime string of when it was created. Default: Automatically generated.
# Running the Builtin CommonStrategy as mentioned above
df.ta.strategy(ta.CommonStrategy)
# The Default Strategy is the ta.AllStrategy. The following are equivalent:
df.ta.strategy()
df.ta.strategy("All")
df.ta.strategy(ta.AllStrategy)
# List of indicator categories
df.ta.categories
# Running a Categorical Strategy only requires the Category name
df.ta.strategy("Momentum")# Default values for all Momentum indicators
df.ta.strategy("overlap",length=42)# Override all Overlap 'length' attributes
# Create your own Custom Strategy
CustomStrategy=ta.Strategy(
name="Momo and Volatility",
description="SMA 50,200, BBANDS, RSI, MACD and Volume SMA 20",
ta=[
{"kind":"sma","length":50},
{"kind":"sma","length":200},
{"kind":"bbands","length":20},
{"kind":"rsi"},
{"kind":"macd","fast":8,"slow":21},
{"kind":"sma","close":"volume","length":20,"prefix":"VOLUME"},
]
)
# To run your "Custom Strategy"
df.ta.strategy(CustomStrategy)
ThePandas TAstrategymethod utilizesmultiprocessingfor bulk indicator processing of all Strategy types withONE EXCEPTION!When using thecol_names
parameter to rename resultant column(s), the indicators inta
array will be ran in order.
# VWAP requires the DataFrame index to be a DatetimeIndex.
# * Replace "datetime" with the appropriate column from your DataFrame
df.set_index(pd.DatetimeIndex(df["datetime"]),inplace=True)
# Runs and appends all indicators to the current DataFrame by default
# The resultant DataFrame will be large.
df.ta.strategy()
# Or the string "all"
df.ta.strategy("all")
# Or the ta.AllStrategy
df.ta.strategy(ta.AllStrategy)
# Use verbose if you want to make sure it is running.
df.ta.strategy(verbose=True)
# Use timed if you want to see how long it takes to run.
df.ta.strategy(timed=True)
# Choose the number of cores to use. Default is all available cores.
# For no multiprocessing, set this value to 0.
df.ta.cores=4
# Maybe you do not want certain indicators.
# Just exclude (a list of) them.
df.ta.strategy(exclude=["bop","mom","percent_return","wcp","pvi"],verbose=True)
# Perhaps you want to use different values for indicators.
# This will run ALL indicators that have fast or slow as parameters.
# Check your results and exclude as necessary.
df.ta.strategy(fast=10,slow=50,verbose=True)
# Sanity check. Make sure all the columns are there
df.columns
RememberThese will not be utilizingmultiprocessing
NonMPStrategy=ta.Strategy(
name="EMAs, BBs, and MACD",
description="Non Multiprocessing Strategy by rename Columns",
ta=[
{"kind":"ema","length":8},
{"kind":"ema","length":21},
{"kind":"bbands","length":20,"col_names":("BBL","BBM","BBU")},
{"kind":"macd","fast":8,"slow":21,"col_names":("MACD","MACD_H","MACD_S")}
]
)
# Run it
df.ta.strategy(NonMPStrategy)
# 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
# List of Pandas TA categories.
df.ta.categories
# Set the number of cores to use for strategy multiprocessing
# Defaults to the number of cpus you have.
df.ta.cores=4
# Set the number of cores to 0 for no multiprocessing.
df.ta.cores=0
# Returns the number of cores you set or your default number of cpus.
df.ta.cores
# The 'datetime_ordered' property returns True if the DataFrame
# index is of Pandas datetime64 and df.index[0] < df.index[-1].
# Otherwise it returns False.
df.ta.datetime_ordered
# Sets the Exchange to use when calculating the last_run property. Default: "NYSE"
df.ta.exchange
# Set the Exchange to use.
# Available Exchanges: "ASX", "BMF", "DIFX", "FWB", "HKE", "JSE", "LSE", "NSE", "NYSE", "NZSX", "RTS", "SGX", "SSE", "TSE", "TSX"
df.ta.exchange="LSE"
# Returns the time Pandas TA was last run as a string.
df.ta.last_run
# The 'reverse' is a helper property that returns the DataFrame
# in reverse order.
df.ta.reverse
# Applying a prefix to the name of an indicator.
prehl2=df.ta.hl2(prefix="pre")
print(prehl2.name)# "pre_HL2"
# Applying a suffix to the name of an indicator.
endhl2=df.ta.hl2(suffix="post")
print(endhl2.name)# "HL2_post"
# Applying a prefix and suffix to the name of an indicator.
bothhl2=df.ta.hl2(prefix="pre",suffix="post")
print(bothhl2.name)# "pre_HL2_post"
# Returns the time range of the DataFrame as a float.
# By default, it returns the time in "years"
df.ta.time_range
# Available time_ranges include: "years", "months", "weeks", "days", "hours", "minutes". "seconds"
df.ta.time_range="days"
df.ta.time_range# prints DataFrame time in "days" as float
# Sets the DataFrame index to UTC format.
df.ta.to_utc
importnumpyasnp
# Add constant '1' to the DataFrame
df.ta.constants(True,[1])
# Remove constant '1' to the DataFrame
df.ta.constants(False,[1])
# Adding constants for charting
importnumpyasnp
chart_lines=np.append(np.arange(-4,5,1),np.arange(-100,110,10))
df.ta.constants(True,chart_lines)
# Removing some constants from the DataFrame
df.ta.constants(False,np.array([-60,-40,40,60]))
# Prints the indicators and utility functions
df.ta.indicators()
# Returns a list of indicators and utility functions
ind_list=df.ta.indicators(as_list=True)
# Prints the indicators and utility functions that are not in the excluded list
df.ta.indicators(exclude=["cg","pgo","ui"])
# Returns a list of the indicators and utility functions that are not in the excluded list
smaller_list=df.ta.indicators(exclude=["cg","pgo","ui"],as_list=True)
# Download Chart history using yfinance. (pip install yfinance) https://github /ranaroussi/yfinance
# It uses the same keyword arguments as yfinance (excluding start and end)
df=df.ta.ticker("aapl")# Default ticker is "SPY"
# Period is used instead of start/end
# Valid periods: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
# Default: "max"
df=df.ta.ticker("aapl",period="1y")# Gets this past year
# History by Interval by interval (including intraday if period < 60 days)
# Valid intervals: 1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo
# Default: "1d"
df=df.ta.ticker("aapl",period="1y",interval="1wk")# Gets this past year in weeks
df=df.ta.ticker("aapl",period="1mo",interval="1h")# Gets this past month in hours
# BUT WAIT!! THERE'S MORE!!
help(ta.yf)
Patterns that arenot bold,require TA-Lib to be installed:pip install TA-Lib
- 2crows
- 3blackcrows
- 3inside
- 3linestrike
- 3outside
- 3starsinsouth
- 3whitesoldiers
- abandonedbaby
- advanceblock
- belthold
- breakaway
- closingmarubozu
- concealbabyswall
- counterattack
- darkcloudcover
- doji
- dojistar
- dragonflydoji
- engulfing
- eveningdojistar
- eveningstar
- gapsidesidewhite
- gravestonedoji
- hammer
- hangingman
- harami
- haramicross
- highwave
- hikkake
- hikkakemod
- homingpigeon
- identical3crows
- inneck
- inside
- invertedhammer
- kicking
- kickingbylength
- ladderbottom
- longleggeddoji
- longline
- marubozu
- matchinglow
- mathold
- morningdojistar
- morningstar
- onneck
- piercing
- rickshawman
- risefall3methods
- separatinglines
- shootingstar
- shortline
- spinningtop
- stalledpattern
- sticksandwich
- takuri
- tasukigap
- thrusting
- tristar
- unique3river
- upsidegap2crows
- xsidegap3methods
- Heikin-Ashi:ha
- Z Score:cdl_z
# Get all candle patterns (This is the default behaviour)
df=df.ta.cdl_pattern(name="all")
# Get only one pattern
df=df.ta.cdl_pattern(name="doji")
# Get some patterns
df=df.ta.cdl_pattern(name=["doji","inside"])
- Even Better Sinewave:ebsw
- Awesome Oscillator:ao
- Absolute Price Oscillator:apo
- Bias:bias
- Balance of Power:bop
- BRAR:brar
- Commodity Channel Index:cci
- Chande Forecast Oscillator:cfo
- Center of Gravity:cg
- Chande Momentum Oscillator:cmo
- Coppock Curve:coppock
- Correlation Trend Indicator:cti
- A wrapper for
ta.linreg(series, r=True)
- A wrapper for
- Directional Movement:dm
- Efficiency Ratio:er
- Elder Ray Index:eri
- Fisher Transform:fisher
- Inertia:inertia
- KDJ:kdj
- KST Oscillator:kst
- Moving Average Convergence Divergence:macd
- Momentum:mom
- Pretty Good Oscillator:pgo
- Percentage Price Oscillator:ppo
- Psychological Line:psl
- Percentage Volume Oscillator:pvo
- Quantitative Qualitative Estimation:qqe
- Rate of Change:roc
- Relative Strength Index:rsi
- Relative Strength Xtra:rsx
- Relative Vigor Index:rvgi
- Schaff Trend Cycle:stc
- Slope:slope
- SMI Ergodicsmi
- Squeeze:squeeze
- Default is John Carter's. Enable Lazybear's with
lazybear=True
- Default is John Carter's. Enable Lazybear's with
- Squeeze Pro:squeeze_pro
- Stochastic Oscillator:stoch
- Stochastic RSI:stochrsi
- TD Sequential:td_seq
- Excluded from
df.ta.strategy()
.
- Excluded from
- Trix:trix
- True strength index:tsi
- Ultimate Oscillator:uo
- Williams %R:willr
Moving Average Convergence Divergence(MACD) |
---|
- Arnaud Legoux Moving Average:alma
- Double Exponential Moving Average:dema
- Exponential Moving Average:ema
- Fibonacci's Weighted Moving Average:fwma
- Gann High-Low Activator:hilo
- High-Low Average:hl2
- High-Low-Close Average:hlc3
- Commonly known as 'Typical Price' in Technical Analysis literature
- Hull Exponential Moving Average:hma
- Holt-Winter Moving Average:hwma
- Ichimoku Kinkō Hyō:ichimoku
- Returns two DataFrames. For more information:
help(ta.ichimoku)
. lookahead=False
drops the Chikou Span Column to prevent potential data leak.
- Returns two DataFrames. For more information:
- Jurik Moving Average:jma
- Kaufman's Adaptive Moving Average:kama
- Linear Regression:linreg
- McGinley Dynamic:mcgd
- Midpoint:midpoint
- Midprice:midprice
- Open-High-Low-Close Average:ohlc4
- Pascal's Weighted Moving Average:pwma
- WildeR's Moving Average:rma
- Sine Weighted Moving Average:sinwma
- Simple Moving Average:sma
- Ehler's Super Smoother Filter:ssf
- Supertrend:supertrend
- Symmetric Weighted Moving Average:swma
- T3 Moving Average:t3
- Triple Exponential Moving Average:tema
- Triangular Moving Average:trima
- Variable Index Dynamic Average:vidya
- Volume Weighted Average Price:vwap
- Requiresthe DataFrame index to be a DatetimeIndex
- Volume Weighted Moving Average:vwma
- Weighted Closing Price:wcp
- Weighted Moving Average:wma
- Zero Lag Moving Average:zlma
Simple Moving Averages(SMA) andBollinger Bands(BBANDS) |
---|
Use parameter: cumulative=Truefor cumulative results.
- Draw Down:drawdown
- Log Return:log_return
- Percent Return:percent_return
Percent Return(Cumulative) withSimple Moving Average(SMA) |
---|
- Entropy:entropy
- Kurtosis:kurtosis
- Mean Absolute Deviation:mad
- Median:median
- Quantile:quantile
- Skew:skew
- Standard Deviation:stdev
- Think or Swim Standard Deviation All:tos_stdevall
- Variance:variance
- Z Score:zscore
Z Score |
---|
- Average Directional Movement Index:adx
- Also includesdmpanddmnin the resultant DataFrame.
- Archer Moving Averages Trends:amat
- Aroon & Aroon Oscillator:aroon
- Choppiness Index:chop
- Chande Kroll Stop:cksp
- Decay:decay
- Formally:linear_decay
- Decreasing:decreasing
- Detrended Price Oscillator:dpo
- Set
lookahead=False
to disable centering and remove potential data leak.
- Set
- Increasing:increasing
- Long Run:long_run
- Parabolic Stop and Reverse:psar
- Q Stick:qstick
- Short Run:short_run
- Trend Signals:tsignals
- TTM Trend:ttm_trend
- Vertical Horizontal Filter:vhf
- Vortex:vortex
- Cross Signals:xsignals
Average Directional Movement Index(ADX) |
---|
- Above:above
- Above Value:above_value
- Below:below
- Below Value:below_value
- Cross:cross
- Aberration:aberration
- Acceleration Bands:accbands
- Average True Range:atr
- Bollinger Bands:bbands
- Donchian Channel:donchian
- Holt-Winter Channel:hwc
- Keltner Channel:kc
- Mass Index:massi
- Normalized Average True Range:natr
- Price Distance:pdist
- Relative Volatility Index:rvi
- Elder's Thermometer:thermo
- True Range:true_range
- Ulcer Index:ui
Average True Range(ATR) |
---|
- Accumulation/Distribution Index:ad
- Accumulation/Distribution Oscillator:adosc
- Archer On-Balance Volume:aobv
- Chaikin Money Flow:cmf
- Elder's Force Index:efi
- Ease of Movement:eom
- Klinger Volume Oscillator:kvo
- Money Flow Index:mfi
- Negative Volume Index:nvi
- On-Balance Volume:obv
- Positive Volume Index:pvi
- Price-Volume:pvol
- Price Volume Rank:pvr
- Price Volume Trend:pvt
- Volume Profile:vp
On-Balance Volume(OBV) |
---|
Performance Metricsare anewaddition to the package and consequentially are likely unreliable.Use at your own risk.These metrics return afloatand arenotpart of theDataFrameExtension. They are called the Standard way. For Example:
importpandas_taasta
result=ta.cagr(df.close)
- Compounded Annual Growth Rate:cagr
- Calmar Ratio:calmar_ratio
- Downside Deviation:downside_deviation
- Jensen's Alpha:jensens_ Alpha
- Log Max Drawdown:log_max_drawdown
- Max Drawdown:max_drawdown
- Pure Profit Score:pure_profit_score
- Sharpe Ratio:sharpe_ratio
- Sortino Ratio:sortino_ratio
- Volatility:volatility
Foreasierintegration withvectorbt's Portfoliofrom_signals
method, theta.trend_return
method has been replaced withta.tsignals
method to simplify the generation of trading signals. For a comprehensive example, see the example Jupyter NotebookVectorBT Backtest with Pandas TAin the examples directory.
- See thevectorbtwebsite more options and examples.
importpandasaspd
importpandas_taasta
importvectorbtasvbt
df=pd.DataFrame().ta.ticker("AAPL")# requires 'yfinance' installed
# Create the "Golden Cross"
df["GC"]=df.ta.sma(50,append=True)>df.ta.sma(200,append=True)
# Create boolean Signals(TS_Entries, TS_Exits) for vectorbt
golden=df.ta.tsignals(df.GC,asbool=True,append=True)
# Sanity Check (Ensure data exists)
print(df)
# Create the Signals Portfolio
pf=vbt.Portfolio.from_signals(df.close,entries=golden.TS_Entries,exits=golden.TS_Exits,freq="D",init_cash=100_000,fees=0.0025,slippage=0.0025)
# Print Portfolio Stats and Return Stats
print(pf.stats())
print(pf.returns_stats())
- AStrategyClass to help name and group your favorite indicators.
- If aTA Libis already installed, Pandas TA will run TA Lib's version. (BETA)
- Some indicators have had their
mamode
kwargupdated with moremoving averagechoices with theMoving Average Utilityfunctionta.ma()
.For simplicity, allchoicesare single sourcemoving averages.This is primarily an internal utility used by indicators that have amamode
kwarg.This includes indicators:accbands,amat,aobv,atr,bbands,bias,efi,hilo,kc,natr,qqe,rvi,andthermo;the defaultmamode
parameters have not changed. However,ta.ma()
can be used by the user as well if needed. For more information:help(ta.ma)
- Moving Average Choices:dema, ema, fwma, hma, linreg, midpoint, pwma, rma, sinwma, sma, swma, t3, tema, trima, vidya, wma, zlma.
- Anexperimentaland independentWatchlistClass located in theExamplesDirectory that can be used in conjunction with the newStrategyClass.
- Linear Regression(linear_regression) is a new utility method for Simple Linear Regression usingNumpyorScikit Learn's implementation.
- Added utility/convience function,
to_utc
,to convert the DataFrame index to UTC. See:help(ta.to_utc)
Nowas a Pandas TA DataFrame Property to easily convert the DataFrame index to UTC.
- Trend Return(trend_return) has been removed and replaced withtsignals.When given a trend Series like
close > sma(close, 50)
it returns the Trend, Trade Entries and Trade Exits of that trend to make it compatible withvectorbtby settingasbool=True
to get boolean Trade Entries and Exits. Seehelp(ta.tsignals)
- Arnaud Legoux Moving Average(alma) uses the curve of the Normal (Gauss) distribution to allow regulating the smoothness and high sensitivity of the indicator. See:
help(ta.alma)
trading account, or fund. Seehelp(ta.drawdown)
- Candle Patterns(cdl_pattern) If TA Lib is installed, then all those Candle Patterns are available. See the list and examples above on how to call the patterns. See
help(ta.cdl_pattern)
- Candle Z Score(cdl_z) normalizes OHLC Candles with a rolling Z Score. See
help(ta.cdl_z)
- Correlation Trend Indicator(cti) is an oscillator created by John Ehler in 2020. See
help(ta.cti)
- Cross Signals(xsignals) was created by Kevin Johnson. It is a wrapper of Trade Signals that returns Trends, Trades, Entries and Exits. Cross Signals are commonly used forbbands,rsi,zscorecrossing some value either above or below two values at different times. See
help(ta.xsignals)
- Directional Movement(dm) developed by J. Welles Wilder in 1978 attempts to determine which direction the price of an asset is moving. See
help(ta.dm)
- Even Better Sinewave(ebsw) measures market cycles and uses a low pass filter to remove noise. See:
help(ta.ebsw)
- Jurik Moving Average(jma) attempts to eliminate noise to see the "true" underlying activity.. See:
help(ta.jma)
- Klinger Volume Oscillator(kvo) was developed by Stephen J. Klinger. It is designed to predict price reversals in a market by comparing volume to price.. See
help(ta.kvo)
- Schaff Trend Cycle(stc) is an evolution of the popular MACD incorportating two cascaded stochastic calculations with additional smoothing. See
help(ta.stc)
- Squeeze Pro(squeeze_pro) is an extended version of "TTM Squeeze" from John Carter. See
help(ta.squeeze_pro)
- Tom DeMark's Sequential(td_seq) attempts to identify a price point where an uptrend or a downtrend exhausts itself and reverses. Currently exlcuded from
df.ta.strategy()
for performance reasons. Seehelp(ta.td_seq)
- Think or Swim Standard Deviation All(tos_stdevall) indicator which
returns the standard deviation of data for the entire plot or for the interval
of the last bars defined by the length parameter. See
help(ta.tos_stdevall)
- Vertical Horizontal Filter(vhf) was created by Adam White to identify trending and ranging markets.. See
help(ta.vhf)
- Acceleration Bands(accbands) Argument
mamode
renamed tomode
.Seehelp(ta.accbands)
. - ADX(adx): Added
mamode
with default "RMA"and with the samemamode
options as TradingView. New argumentlensig
so it behaves like TradingView's builtin ADX indicator. Seehelp(ta.adx)
. - Archer Moving Averages Trends(amat): Added
drift
argument and more descriptive column names. - Average True Range(atr): The default
mamode
is now "RMA"and with the samemamode
options as TradingView. Seehelp(ta.atr)
. - Bollinger Bands(bbands): New argument
ddoff
to control the Degrees of Freedom. Also included BB Percent (BBP) as the final column. Default is 0. Seehelp(ta.bbands)
. - Choppiness Index(chop): New argument
ln
to use Natural Logarithm (True) instead of the Standard Logarithm (False). Default is False. Seehelp(ta.chop)
. - Chande Kroll Stop(cksp): Added
tvmode
with defaultTrue
.Whentvmode=False
,ckspimplements “The New Technical Trader” with default values. Seehelp(ta.cksp)
. - Chande Momentum Oscillator(cmo): New argument
talib
will use TA Lib's version and if TA Lib is installed. Default is True. Seehelp(ta.cmo)
. - Decreasing(decreasing): New argument
strict
checks if the series is continuously decreasing over periodlength
with a faster calculation. Default:False
.Thepercent
argument has also been added with default None. Seehelp(ta.decreasing)
. - Increasing(increasing): New argument
strict
checks if the series is continuously increasing over periodlength
with a faster calculation. Default:False
.Thepercent
argument has also been added with default None. Seehelp(ta.increasing)
. - Klinger Volume Oscillator(kvo): Implements TradingView's Klinger Volume Oscillator version. See
help(ta.kvo)
. - Linear Regression(linreg): Checksnumpy's version to determine whether to utilize the
as_strided
method or the newersliding_window_view
method. This should resolve Issues with Google Colab and it's delayed dependency updates as well as TensorFlow's dependencies as discussed in Issues#285and#329. - Moving Average Convergence Divergence(macd): New argument
asmode
enables AS version of MACD. Default is False. Seehelp(ta.macd)
. - Parabolic Stop and Reverse(psar): Bug fix and adjustment to match TradingView's
sar
.New argumentaf0
to initialize the Acceleration Factor. Seehelp(ta.psar)
. - Percentage Price Oscillator(ppo): Included new argument
mamode
as an option. Default issmato match TA Lib. Seehelp(ta.ppo)
. - True Strength Index(tsi): Added
signal
with default13
and Signal MA Modemamode
with defaultemaas arguments. Seehelp(ta.tsi)
. - Volume Profile(vp): Calculation improvements. SeePull Request #320See
help(ta.vp)
. - Volume Weighted Moving Average(vwma): Fixed bug in DataFrame Extension call. See
help(ta.vwma)
. - Volume Weighted Average Price(vwap): Added a new parameter called
anchor
.Default: "D" for "Daily". SeeTimeseries Offset Aliasesfor additional options.Requiresthe DataFrame index to be a DatetimeIndex. Seehelp(ta.vwap)
. - Volume Weighted Moving Average(vwma): Fixed bug in DataFrame Extension call. See
help(ta.vwma)
. - Z Score(zscore): Changed return column name from
Z_length
toZS_length
.Seehelp(ta.zscore)
.
Original TA-LIB|TradingView|Sierra Chart|MQL5|FM Labs|Pro Real Code|User 42
Feeling generous, like the package or want to see it become more a mature package?