Skip to content

Commit

Permalink
ENH cdl and cdl_pattern with talib compat added DOC cdl_pattern info …
Browse files Browse the repository at this point in the history
…+ notebooks BUG yf extra output removed
  • Loading branch information
twopirllc committed Apr 10, 2021
1 parent 6f94d58 commit d65bb5a
Show file tree
Hide file tree
Showing 15 changed files with 505 additions and 205 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,5 @@ data/SPY_D_TV2.csv
data/SPY_D_TV3.csv
data/TV_5min.csv
data/tulip.csv
examples/*.csv
examples/*.csv
examples/Chande_Kroll_Stop.ipynb
162 changes: 93 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ Pandas TA - A Technical Analysis Library in Python 3
![Example Chart](/images/TA_Chart.png)


_Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that leverages the Pandas library with more than 130 Indicators and Utility functions. Many commonly used indicators are included, such as: _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**) and **_many more_**.
_Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that leverages the Pandas library with more than 130 Indicators and Utility functions and more than 60 TA Lib Candlestick Patterns. Many commonly used indicators are included, such as: _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**) and **_many more_**.


**Note:** _TA Lib_ must be installed to use **all** the Candlestick Patterns. ```pip install TA-Lib```. If _TA Lib_ is not installed, then only the builtin Candlestick Patterns will be available.

<br/>

Expand All @@ -36,7 +39,7 @@ _Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that lever
* [DataFrame Properties](#dataframe-properties)
* [DataFrame Methods](#dataframe-methods)
* [Indicators by Category](#indicators-by-category)
* [Candles](#candles-3)
* [Candles](#candles-63)
* [Cycles](#cycles-1)
* [Momentum](#momentum-37)
* [Overlap](#overlap-31)
Expand All @@ -63,13 +66,22 @@ _Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that lever
# **Features**

* Has 130+ indicators and utility functions.
* With **TA Lib** installed there are an additional 63 Chart Patterns available.
* Indicators are tightly correlated with the de facto [TA Lib](https://mrjbq7.github.io/ta-lib/) if they share common indicators.
* Have the need for speed? By using the DataFrame _strategy_ method, you get **multiprocessing** for free!
* Easily add _prefixes_ or _suffixes_ or both to columns names. Useful for Custom Chained Strategies.
* Easily add _prefixes_ or _suffixes_ or _both_ to columns names. Useful for Custom Chained Strategies.
* Example Jupyter Notebooks under the [examples](https://github.com/twopirllc/pandas-ta/tree/master/examples) directory, including how to create Custom Strategies using the new [__Strategy__ Class](https://github.com/twopirllc/pandas-ta/tree/master/examples/PandaTA_Strategy_Examples.ipynb)
* Potential Data Leaks: **ichimoku** and **dpo**. See indicator list below for details.
* **UNDER DEVELOPMENT:** Performance Metrics
* **UNDER DEVELOPMENT:** Easy Downloading of _ohlcv_ data using [yfinance](https://github.com/ranaroussi/yfinance). See ```help(ta.ticker)``` and ```help(ta.yf)```

<br/>

**Under Development**
===================
**Pandas TA** checks if the user has some common trading packages installed including but not limited to: [**TA Lib**](https://mrjbq7.github.io/ta-lib/), [**Vector BT**](https://github.com/polakowo/vectorbt), [**YFinance**](https://github.com/ranaroussi/yfinance) ... Much of which is experimental and likely to break until it stabilizes more.
* If **TA Lib** installed, existing indicators will _eventually_ get a **TA Lib** version.
* Easy Downloading of _ohlcv_ data using [yfinance](https://github.com/ranaroussi/yfinance). See ```help(ta.ticker)``` and ```help(ta.yf)``` and examples below.
* Hopefully soon a Pandas TA _YAML_ configuration file contained in ```~/pandas_ta/``` can be implemented. To see the proposed specification and leave comments and suggestions on it's implementation, see Issue [#258](https://github.com/twopirllc/pandas-ta/issues/258).
* Some Common Performance Metrics

<br/>

Expand All @@ -85,7 +97,7 @@ $ pip install pandas_ta

Latest Version
--------------
Best choice! Version: *0.2.67b*
Best choice! Version: *0.2.68b*
```sh
$ pip install -U git+https://github.com/twopirllc/pandas-ta
```
Expand Down Expand Up @@ -556,79 +568,90 @@ help(ta.yf)
# **Indicators** (_by Category_)
### **Candles** (63)

* _Patterns_: cdl_pattern (Patterns that aren't bold, need 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
_Candle Patterns_: ```ta.cdl_pattern``` or ```ta.cdl```


Patterns that are **not 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**
```python
# Get all candle patterns (This is the default behaviour)
df = df.ta.cdl_pattern(name="all")
# Or
df.ta.cdl("all", append=True) # = df.ta.cdl_pattern("all", append=True)


# Get only one pattern
df = df.ta.cdl_pattern(name="doji")
# Or
df.ta.cdl("doji", append=True)

# Get some patterns
df = df.ta.cdl_pattern(name=["doji", "inside"])
# Or
df.ta.cdl(["doji", "inside"], append=True)
```
<br/>

Expand Down Expand Up @@ -878,6 +901,7 @@ result = ta.cagr(df.close)
## **New Indicators**
* _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. See: ```help(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)```
* _Even Better Sinewave_ (**ebsw**) measures market cycles and uses a low pass filter to remove noise. See: ```help(ta.ebsw)```
* _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. See: ```help(ta.td_seq)```
<br/>
Expand Down
18 changes: 9 additions & 9 deletions examples/AIExample.ipynb

Large diffs are not rendered by default.

402 changes: 326 additions & 76 deletions examples/Chande_Kroll_Stop.ipynb

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions examples/PandasTA_Strategy_Examples.ipynb

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@
"output_type": "stream",
"text": [
"Pandas TA - Technical Analysis Indicators - v0.2.64b0\n",
"Total Indicators: 134\n",
"Total Indicators: 196\n",
"Abbreviations:\n",
" aberration, above, above_value, accbands, ad, adosc, adx, alma, amat, ao, aobv, apo, aroon, atr, bbands, below, below_value, bias, bop, brar, cci, cdl_doji, cdl_inside, cfo, cg, chop, cksp, cmf, cmo, coppock, cross, cross_value, decay, decreasing, dema, donchian, dpo, ebsw, efi, ema, entropy, eom, er, eri, fisher, fwma, ha, hilo, hl2, hlc3, hma, hwc, hwma, ichimoku, increasing, inertia, kama, kc, kdj, kst, kurtosis, linreg, log_return, long_run, macd, mad, massi, mcgd, median, mfi, midpoint, midprice, mom, natr, nvi, obv, ohlc4, pdist, percent_return, pgo, ppo, psar, psl, pvi, pvo, pvol, pvr, pvt, pwma, qqe, qstick, quantile, rma, roc, rsi, rsx, rvgi, rvi, short_run, sinwma, skew, slope, sma, smi, squeeze, ssf, stdev, stoch, stochrsi, supertrend, swma, t3, td_seq, tema, thermo, trend_return, trima, trix, true_range, tsi, ttm_trend, ui, uo, variance, vidya, vortex, vp, vwap, vwma, wcp, willr, wma, zlma, zscore\n"
" aberration, above, above_value, accbands, ad, adosc, adx, alma, amat, ao, aobv, apo, aroon, atr, bbands, below, below_value, bias, bop, brar, cci, cdl, cdl_pattern, cfo, cg, chop, cksp, cmf, cmo, coppock, cross, cross_value, decay, decreasing, dema, donchian, dpo, ebsw, efi, ema, entropy, eom, er, eri, fisher, fwma, ha, hilo, hl2, hlc3, hma, hwc, hwma, ichimoku, increasing, inertia, kama, kc, kdj, kst, kurtosis, linreg, log_return, long_run, macd, mad, massi, mcgd, median, mfi, midpoint, midprice, mom, natr, nvi, obv, ohlc4, pdist, percent_return, pgo, ppo, psar, psl, pvi, pvo, pvol, pvr, pvt, pwma, qqe, qstick, quantile, rma, roc, rsi, rsx, rvgi, rvi, short_run, sinwma, skew, slope, sma, smi, squeeze, ssf, stdev, stoch, stochrsi, supertrend, swma, t3, td_seq, tema, thermo, trend_return, trima, trix, true_range, tsi, ttm_trend, ui, uo, variance, vidya, vortex, vp, vwap, vwma, wcp, willr, wma, zlma, zscore\n",
"\n",
"Candle Patterns:\n",
" 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\n"
]
}
],
Expand Down Expand Up @@ -926,7 +929,7 @@
"[i] Multiprocessing 5 indicators with 7 chunks and 8/8 cpus.\n",
"[i] Total indicators: 5\n",
"[i] Columns added: 5\n",
"[i] Last Run: Saturday April 10, 2021, NYSE: 5:38:28, Local: 9:38:28 PDT, Day 100/365 (27.0%)\n"
"[i] Last Run: Saturday April 10, 2021, NYSE: 12:37:31, Local: 16:37:31 PDT, Day 100/365 (27.0%)\n"
]
},
{
Expand Down Expand Up @@ -954,7 +957,7 @@
{
"data": {
"text/plain": [
"<__main__.Chart at 0x12ffc83d0>"
"<__main__.Chart at 0x132188e20>"
]
},
"execution_count": 11,
Expand Down Expand Up @@ -1064,7 +1067,7 @@
{
"data": {
"text/plain": [
"<matplotlib.lines.Line2D at 0x130be2700>"
"<matplotlib.lines.Line2D at 0x132e4c550>"
]
},
"execution_count": 13,
Expand Down Expand Up @@ -1103,7 +1106,7 @@
{
"data": {
"text/plain": [
"<matplotlib.lines.Line2D at 0x1308b2cd0>"
"<matplotlib.lines.Line2D at 0x132ebf850>"
]
},
"execution_count": 14,
Expand Down Expand Up @@ -1136,7 +1139,7 @@
{
"data": {
"text/plain": [
"<matplotlib.lines.Line2D at 0x130cb4580>"
"<matplotlib.lines.Line2D at 0x132e85dc0>"
]
},
"execution_count": 15,
Expand Down Expand Up @@ -1216,7 +1219,7 @@
{
"data": {
"text/plain": [
"<__main__.Chart at 0x130ceb6d0>"
"<__main__.Chart at 0x132f42820>"
]
},
"execution_count": 17,
Expand Down Expand Up @@ -1268,7 +1271,7 @@
{
"data": {
"text/plain": [
"<__main__.Chart at 0x130d2f190>"
"<__main__.Chart at 0x132fd0d60>"
]
},
"execution_count": 18,
Expand Down Expand Up @@ -1322,7 +1325,7 @@
{
"data": {
"text/plain": [
"<__main__.Chart at 0x13147fd30>"
"<__main__.Chart at 0x132936820>"
]
},
"execution_count": 19,
Expand Down Expand Up @@ -1380,7 +1383,7 @@
{
"data": {
"text/plain": [
"<__main__.Chart at 0x130136f70>"
"<__main__.Chart at 0x13247e610>"
]
},
"execution_count": 20,
Expand Down
2 changes: 1 addition & 1 deletion pandas_ta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Category = {
# Candles
"candles": [
"cdl_pattern", "ha"
"cdl", "cdl_pattern", "ha"
],
# Cycles
"cycles": ["ebsw"],
Expand Down
2 changes: 1 addition & 1 deletion pandas_ta/candles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .ha import ha
from .cdl_doji import cdl_doji
from .cdl_inside import cdl_inside
from .cdl_pattern import cdl_pattern, ALL_PATTERNS as CDL_PATTERN_NAMES
from .cdl_pattern import cdl_pattern, cdl, ALL_PATTERNS as CDL_PATTERN_NAMES
Loading

0 comments on commit d65bb5a

Please sign in to comment.