ENH logo MAINT gitignore + update example notebooks

This commit is contained in:
Kevin Johnson
2021-01-24 12:25:42 -08:00
parent a60821a41f
commit 53404e57cc
7 changed files with 213 additions and 211 deletions
+13 -29
View File
@@ -116,9 +116,22 @@ env/**
pandas_ta/_wrapper.py
# twopirllc stuff
notes.md
setup.cfg
doc.py
pandas_pips
reqs.txt
requirements.txt
driver.py
qd.py
# Local package installs
ta-lib/
AlphaVantageAPI/
# Data & NB Exclusions
*.ipynb
*.csv
data/datas.csv
data/f500.csv
data/GLD_D_tv.csv
@@ -129,33 +142,4 @@ data/SPY_D_TV2.csv
data/SPY_D_TV3.csv
data/TV_5min.csv
data/tulip.csv
examples/cache.sqlite
examples/taplot.py
examples/alpaca_trader.py
examples/ChartTA.ipynb
examples/charting.ipynb
examples/ib_trader.ipynb
examples/example2.ipynb
examples/*.csv
setup.cfg
note.md
driver.py
doc.py
bt.ipynb
scratch.ipynb
ta_extension.ipynb
scratch.ipynb
kerasmodeller.ipynb
Charts.ipynb
pandas_pips
reqs.txt
requirements.txt
qd.py
tds.py
simple.ipynb
ta.json
# Issue Data
*.csv
+27 -2
View File
@@ -1,4 +1,8 @@
<p align="center">
<a href="https://github.com/twopirllc/pandas_ta">
<img src="images/logo.png" alt="Pandas TA">
</a>
</p>
Pandas TA - A Technical Analysis Library in Python 3
=================
@@ -60,6 +64,7 @@ _Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that lever
* 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.
* 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
<br/>
@@ -98,6 +103,10 @@ import pandas_ta as ta
# Load data
df = pd.read_csv("path/to/symbol.csv", sep=",")
# 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)
@@ -175,6 +184,8 @@ _Thank you for your contributions!_
**Pandas TA** has three primary "styles" of processing Technical Indicators for your use case and/or requirements. They are: _Standard_, _DataFrame Extension_, and the _Pandas TA Strategy_. Each with increasing levels of abstraction for ease of use. As you become more familiar with **Pandas TA**, the simplicity and speed of using a _Pandas TA Strategy_ may become more apparent. Furthermore, you can create your own indicators through Chaining or Composition. Lastly, each indicator either returns a _Series_ or a _DataFrame_ in Uppercase Underscore format regardless of style.
<br/>
_Standard_
====================
You explicitly define the input columns and take care of the output.
@@ -187,6 +198,8 @@ You explicitly define the input columns and take care of the output.
* 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.
<br/>
_Pandas TA DataFrame Extension_
====================
@@ -207,6 +220,8 @@ Same as the last three examples, but appending the results directly to the DataF
* ```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```.
<br/>
_Pandas TA Strategy_
====================
@@ -299,12 +314,18 @@ CustomStrategy = ta.Strategy(
df.ta.strategy(CustomStrategy)
```
<br/>
**Multiprocessing**
=======================
The **Pandas TA** _strategy_ method utilizes **multiprocessing** for bulk indicator processing of all Strategy types with **ONE EXCEPTION!** When using the ```col_names``` parameter to rename resultant column(s), the indicators in ```ta``` array will be ran in order.
```python
# 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()
@@ -487,6 +508,7 @@ print(bothhl2.name) # "pre_HL2_post"
* _Hull Exponential Moving Average_: **hma**
* _Ichimoku Kinkō Hyō_: **ichimoku**
* Use: help(ta.ichimoku). Returns two DataFrames.
* Drop the Chikou Span Column, the final column of the first resultant DataFrame, remove potential data leak.
* _Kaufman's Adaptive Moving Average_: **kama**
* _Linear Regression_: **linreg**
* _McGinley Dynamic_: **mcgd**
@@ -505,6 +527,7 @@ print(bothhl2.name) # "pre_HL2_post"
* _Triangular Moving Average_: **trima**
* _Variable Index Dynamic Average_: **vidya**
* _Volume Weighted Average Price_: **vwap**
* **Requires** the DataFrame index to be a DatetimeIndex
* _Volume Weighted Moving Average_: **vwma**
* _Weighted Closing Price_: **wcp**
* _Weighted Moving Average_: **wma**
@@ -556,6 +579,7 @@ Use parameter: cumulative=**True** for cumulative results.
* Formally: **linear_decay**
* _Decreasing_: **decreasing**
* _Detrended Price Oscillator_: **dpo**
* Set ```centered=False``` to remove potential data leak.
* _Increasing_: **increasing**
* _Long Run_: **long_run**
* _Parabolic Stop and Reverse_: **psar**
@@ -655,6 +679,7 @@ result = ta.cagr(df.close)
## **Breaking Indicators**
* _Bollinger Bands_ (**bbands**): New column 'bandwidth' appended to the returning DataFrame. See: ```help(ta.bbands)```
* _Volume Weighted Average Price_ (**vwap**): **Requires** the DataFrame index to be a DatetimeIndex.
## **New Indicators**
@@ -676,7 +701,7 @@ article in the June, 1994 issue of Technical Analysis of Stocks & Commodities Ma
* _Decreasing_ (**decreasing**): New argument ```strict``` checks if the series is continuously decreasing over period ```length```. Default: ```False```. See ```help(ta.decreasing)```.
* _Increasing_ (**increasing**): New argument ```strict``` checks if the series is continuously increasing over period ```length```. Default: ```False```. See ```help(ta.increasing)```.
* _Trend Return_ (**trend_return**): Returns a DataFrame now instead of Series with pertinenet trade info for a _trend_. An example can be found in the [AI Example Notebook](https://github.com/twopirllc/pandas-ta/tree/master/examples/AIExample.ipynb). The notebook is still a work in progress and open to colloboration.
* _Volume Weighted Average Price_ (**vwap**) Added a new parameter called ```anchor```. Default: "D" for "Daily". See [Timeseries Offset Aliases](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timeseries-offset-aliases) for additional options.
* _Volume Weighted Average Price_ (**vwap**) Added a new parameter called ```anchor```. Default: "D" for "Daily". See [Timeseries Offset Aliases](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timeseries-offset-aliases) for additional options. **Requires** the DataFrame index to be a DatetimeIndex
<br />
File diff suppressed because one or more lines are too long
+50 -57
View File
@@ -86,7 +86,7 @@
"text": [
"name = All\n",
"description = All the indicators with their default settings. Pandas TA default.\n",
"created = 12/23/2020, 12:39:31\n",
"created = 01/23/2021, 12:36:24\n",
"ta = None\n"
]
}
@@ -117,7 +117,7 @@
"text": [
"name = Common Price and Volume SMAs\n",
"description = Common Price SMAs: 10, 20, 50, 200 and Volume SMA: 20.\n",
"created = 12/23/2020, 12:39:31\n",
"created = 01/23/2021, 12:36:24\n",
"ta = [{'kind': 'sma', 'length': 10}, {'kind': 'sma', 'length': 20}, {'kind': 'sma', 'length': 50}, {'kind': 'sma', 'length': 200}, {'kind': 'sma', 'close': 'volume', 'length': 20, 'prefix': 'VOL'}]\n"
]
}
@@ -159,7 +159,7 @@
{
"data": {
"text/plain": [
"Strategy(name='A', ta=[{'kind': 'sma', 'length': 50}, {'kind': 'sma', 'length': 200}], description=None, created='12/23/2020, 12:39:31')"
"Strategy(name='A', ta=[{'kind': 'sma', 'length': 50}, {'kind': 'sma', 'length': 200}], description='TA Description', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 4,
@@ -187,7 +187,7 @@
{
"data": {
"text/plain": [
"Strategy(name='B', ta=[{'kind': 'ema', 'length': 8}, {'kind': 'ema', 'length': 21}, {'kind': 'log_return', 'cumulative': True}, {'kind': 'rsi'}, {'kind': 'supertrend'}], description=None, created='12/23/2020, 12:39:31')"
"Strategy(name='B', ta=[{'kind': 'ema', 'length': 8}, {'kind': 'ema', 'length': 21}, {'kind': 'log_return', 'cumulative': True}, {'kind': 'rsi'}, {'kind': 'supertrend'}], description='TA Description', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 5,
@@ -215,7 +215,7 @@
{
"data": {
"text/plain": [
"Strategy(name='Runtime Failure', ta=[{'kind': 'percet_return'}], description=None, created='12/23/2020, 12:39:31')"
"Strategy(name='Runtime Failure', ta=[{'kind': 'percet_return'}], description='TA Description', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 6,
@@ -441,13 +441,13 @@
"[i] Loaded['D']: SPY_D.csv\n",
"[+] Strategy: Common Price and Volume SMAs\n",
"[i] Indicator arguments: {'timed': False, 'append': True}\n",
"[i] Multiprocessing: 4 of 4 cores.\n",
"[i] Multiprocessing: 8 of 8 cores.\n",
"[i] Total indicators: 5\n",
"[i] Columns added: 5\n",
"[i] Loaded['D']: IWM_D.csv\n",
"[+] Strategy: Common Price and Volume SMAs\n",
"[i] Indicator arguments: {'timed': False, 'append': True}\n",
"[i] Multiprocessing: 4 of 4 cores.\n",
"[i] Multiprocessing: 8 of 8 cores.\n",
"[i] Total indicators: 5\n",
"[i] Columns added: 5\n"
]
@@ -814,7 +814,7 @@
{
"data": {
"text/plain": [
"Strategy(name='A', ta=[{'kind': 'sma', 'length': 50}, {'kind': 'sma', 'length': 200}], description=None, created='12/23/2020, 12:39:31')"
"Strategy(name='A', ta=[{'kind': 'sma', 'length': 50}, {'kind': 'sma', 'length': 200}], description='TA Description', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 14,
@@ -1039,7 +1039,7 @@
{
"data": {
"text/plain": [
"Strategy(name='B', ta=[{'kind': 'ema', 'length': 8}, {'kind': 'ema', 'length': 21}, {'kind': 'log_return', 'cumulative': True}, {'kind': 'rsi'}, {'kind': 'supertrend'}], description=None, created='12/23/2020, 12:39:31')"
"Strategy(name='B', ta=[{'kind': 'ema', 'length': 8}, {'kind': 'ema', 'length': 21}, {'kind': 'log_return', 'cumulative': True}, {'kind': 'rsi'}, {'kind': 'supertrend'}], description='TA Description', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 16,
@@ -1144,10 +1144,10 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>-0.007172</td>\n",
" <td>0.000000</td>\n",
" <td>131.968750</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>131.96875</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
@@ -1160,10 +1160,10 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>-0.000461</td>\n",
" <td>50.185503</td>\n",
" <td>131.968750</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>131.96875</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
@@ -1176,10 +1176,10 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>0.007120</td>\n",
" <td>69.153995</td>\n",
" <td>131.968750</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>131.96875</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
@@ -1192,10 +1192,10 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>0.016915</td>\n",
" <td>79.896816</td>\n",
" <td>131.968750</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>131.96875</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
@@ -1317,10 +1317,10 @@
" EMA_21 CUMLOGRET_1 RSI_14 SUPERT_7_3.0 SUPERTd_7_3.0 \\\n",
"date \n",
"1999-11-01 NaN NaN NaN 0.000000 1 \n",
"1999-11-02 NaN -0.007172 0.000000 131.968750 1 \n",
"1999-11-03 NaN -0.000461 50.185503 131.968750 1 \n",
"1999-11-04 NaN 0.007120 69.153995 131.968750 1 \n",
"1999-11-05 NaN 0.016915 79.896816 131.968750 1 \n",
"1999-11-02 NaN -0.007172 NaN NaN 1 \n",
"1999-11-03 NaN -0.000461 NaN NaN 1 \n",
"1999-11-04 NaN 0.007120 NaN NaN 1 \n",
"1999-11-05 NaN 0.016915 NaN NaN 1 \n",
"... ... ... ... ... ... \n",
"2020-09-28 334.010756 0.902277 49.833349 344.119874 -1 \n",
"2020-09-29 333.861596 0.896816 48.051629 344.119874 -1 \n",
@@ -1331,10 +1331,10 @@
" SUPERTl_7_3.0 SUPERTs_7_3.0 \n",
"date \n",
"1999-11-01 NaN NaN \n",
"1999-11-02 131.96875 NaN \n",
"1999-11-03 131.96875 NaN \n",
"1999-11-04 131.96875 NaN \n",
"1999-11-05 131.96875 NaN \n",
"1999-11-02 NaN NaN \n",
"1999-11-03 NaN NaN \n",
"1999-11-04 NaN NaN \n",
"1999-11-05 NaN NaN \n",
"... ... ... \n",
"2020-09-28 NaN 344.119874 \n",
"2020-09-29 NaN 344.119874 \n",
@@ -1369,7 +1369,7 @@
{
"data": {
"text/plain": [
"Strategy(name='Runtime Failure', ta=[{'kind': 'percet_return'}], description=None, created='12/23/2020, 12:39:31')"
"Strategy(name='Runtime Failure', ta=[{'kind': 'percet_return'}], description='TA Description', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 18,
@@ -1435,7 +1435,7 @@
{
"data": {
"text/plain": [
"Strategy(name='Volume MAs and Price MA chain', ta=[{'kind': 'ema', 'close': 'volume', 'length': 10, 'prefix': 'VOLUME'}, {'kind': 'sma', 'close': 'volume', 'length': 20, 'prefix': 'VOLUME'}, {'kind': 'ema', 'length': 5}, {'kind': 'linreg', 'close': 'EMA_5', 'length': 8, 'prefix': 'EMA_5'}], description=None, created='12/23/2020, 12:39:31')"
"Strategy(name='Volume MAs and Price MA chain', ta=[{'kind': 'ema', 'close': 'volume', 'length': 10, 'prefix': 'VOLUME'}, {'kind': 'sma', 'close': 'volume', 'length': 20, 'prefix': 'VOLUME'}, {'kind': 'ema', 'length': 5}, {'kind': 'linreg', 'close': 'EMA_5', 'length': 8, 'prefix': 'EMA_5'}], description='TA Description', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 20,
@@ -1736,7 +1736,7 @@
{
"data": {
"text/plain": [
"Strategy(name='MACD BBands', ta=[{'kind': 'macd'}, {'kind': 'bbands', 'close': 'MACD_12_26_9', 'length': 20, 'prefix': 'MACD'}], description='BBANDS_20 applied to MACD', created='12/23/2020, 12:39:31')"
"Strategy(name='MACD BBands', ta=[{'kind': 'macd'}, {'kind': 'bbands', 'close': 'MACD_12_26_9', 'length': 20, 'prefix': 'MACD'}], description='BBANDS_20 applied to MACD', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 23,
@@ -2095,7 +2095,7 @@
{
"data": {
"text/plain": [
"Strategy(name='Momo, Bands and SMAs and Cumulative Log Returns', ta=[{'kind': 'sma', 'length': 50}, {'kind': 'sma', 'length': 200}, {'kind': 'bbands', 'length': 20}, {'kind': 'macd'}, {'kind': 'rsi'}, {'kind': 'log_return', 'cumulative': True}, {'kind': 'sma', 'close': 'CUMLOGRET_1', 'length': 5, 'suffix': 'CUMLOGRET'}], description='MACD and RSI Momo with BBANDS and SMAs 50 & 200 and Cumulative Log Returns', created='12/23/2020, 12:39:31')"
"Strategy(name='Momo, Bands and SMAs and Cumulative Log Returns', ta=[{'kind': 'sma', 'length': 50}, {'kind': 'sma', 'length': 200}, {'kind': 'bbands', 'length': 20}, {'kind': 'macd'}, {'kind': 'rsi'}, {'kind': 'log_return', 'cumulative': True}, {'kind': 'sma', 'close': 'CUMLOGRET_1', 'length': 5, 'suffix': 'CUMLOGRET'}], description='MACD and RSI Momo with BBANDS and SMAs 50 & 200 and Cumulative Log Returns', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 26,
@@ -2261,7 +2261,7 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>0.000000</td>\n",
" <td>NaN</td>\n",
" <td>-0.007172</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
@@ -2284,7 +2284,7 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>50.185503</td>\n",
" <td>NaN</td>\n",
" <td>-0.000461</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
@@ -2307,7 +2307,7 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>69.153995</td>\n",
" <td>NaN</td>\n",
" <td>0.007120</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
@@ -2330,7 +2330,7 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>79.896816</td>\n",
" <td>NaN</td>\n",
" <td>0.016915</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
@@ -2358,21 +2358,21 @@
"1999-11-04 NaN NaN NaN NaN NaN \n",
"1999-11-05 NaN NaN NaN NaN NaN \n",
"\n",
" MACD_12_26_9 MACDh_12_26_9 MACDs_12_26_9 RSI_14 \\\n",
" MACD_12_26_9 MACDh_12_26_9 MACDs_12_26_9 RSI_14 CUMLOGRET_1 \\\n",
"date \n",
"1999-11-01 NaN NaN NaN NaN \n",
"1999-11-02 NaN NaN NaN 0.000000 \n",
"1999-11-03 NaN NaN NaN 50.185503 \n",
"1999-11-04 NaN NaN NaN 69.153995 \n",
"1999-11-05 NaN NaN NaN 79.896816 \n",
"1999-11-01 NaN NaN NaN NaN NaN \n",
"1999-11-02 NaN NaN NaN NaN -0.007172 \n",
"1999-11-03 NaN NaN NaN NaN -0.000461 \n",
"1999-11-04 NaN NaN NaN NaN 0.007120 \n",
"1999-11-05 NaN NaN NaN NaN 0.016915 \n",
"\n",
" CUMLOGRET_1 SMA_5_CUMLOGRET 0 30 70 \n",
" SMA_5_CUMLOGRET 0 30 70 \n",
"date \n",
"1999-11-01 NaN NaN 0 30 70 \n",
"1999-11-02 -0.007172 NaN 0 30 70 \n",
"1999-11-03 -0.000461 NaN 0 30 70 \n",
"1999-11-04 0.007120 NaN 0 30 70 \n",
"1999-11-05 0.016915 NaN 0 30 70 "
"1999-11-01 NaN 0 30 70 \n",
"1999-11-02 NaN 0 30 70 \n",
"1999-11-03 NaN 0 30 70 \n",
"1999-11-04 NaN 0 30 70 \n",
"1999-11-05 NaN 0 30 70 "
]
},
"execution_count": 28,
@@ -2419,7 +2419,7 @@
{
"data": {
"text/plain": [
"Strategy(name='EMA, MACD History, Outter BBands, Log Returns', ta=[{'kind': 'ema', 'params': (10,)}, {'kind': 'macd', 'params': (9, 19, 10), 'col_numbers': (1,)}, {'kind': 'bbands', 'col_numbers': (0, 2), 'col_names': ('LB', 'UB')}, {'kind': 'log_return', 'params': (5, False)}], description='EMA, MACD History, BBands(LB, UB), and Log Returns Strategy', created='12/23/2020, 12:39:31')"
"Strategy(name='EMA, MACD History, Outter BBands, Log Returns', ta=[{'kind': 'ema', 'params': (10,)}, {'kind': 'macd', 'params': (9, 19, 10), 'col_numbers': (1,)}, {'kind': 'bbands', 'col_numbers': (0, 2), 'col_names': ('LB', 'UB')}, {'kind': 'log_return', 'params': (5, False)}], description='EMA, MACD History, BBands(LB, UB), and Log Returns Strategy', created='01/23/2021, 12:36:24')"
]
},
"execution_count": 29,
@@ -2622,13 +2622,6 @@
"spy = watch.load(\"SPY\")\n",
"spy.tail()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
+104 -104
View File
File diff suppressed because one or more lines are too long
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

+1 -1
View File
@@ -17,7 +17,7 @@ setup(
"pandas_ta.volatility",
"pandas_ta.volume"
],
version=".".join(("0", "2", "40b")),
version=".".join(("0", "2", "41b")),
description=long_description,
long_description=long_description,
author="Kevin Johnson",