From c02d29043e1d33dfcb8d2421e9b2caa4a7b9fda3 Mon Sep 17 00:00:00 2001 From: Kevin Johnson Date: Wed, 23 Jun 2021 20:34:26 -0700 Subject: [PATCH] MAINT _time minor refactoring DOC update --- README.md | 12 +++++++----- pandas_ta/utils/_time.py | 17 +++++++++++------ pandas_ta/utils/data/yahoofinance.py | 4 ++-- setup.py | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 803e32f..3483bd8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Pandas TA - A Technical Analysis Library in Python 3 [![Downloads](https://img.shields.io/pypi/dm/pandas_ta?style=flat)](https://pypistats.org/packages/pandas_ta) [![Stars](https://img.shields.io/github/stars/twopirllc/pandas-ta?style=flat)](#stars) [![Forks](https://img.shields.io/github/forks/twopirllc/pandas-ta?style=flat)](#forks) -[![Used By](https://img.shields.io/badge/used_by-140-orange.svg?style=flat)](#usedby) +[![Used By](https://img.shields.io/badge/used_by-142-orange.svg?style=flat)](#usedby) [![Contributors](https://img.shields.io/github/contributors/twopirllc/pandas-ta?style=flat)](#contributors) [![Issues](https://img.shields.io/github/issues-raw/twopirllc/pandas-ta?style=flat)](#issues) [![Closed Issues](https://img.shields.io/github/issues-closed-raw/twopirllc/pandas-ta?style=flat)](#closed-issues) @@ -48,6 +48,7 @@ _Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that lever * [Pandas TA Strategy](#pandas-ta-strategy) * [Pandas TA Strategies](#pandas-ta-strategies) * [Types of Strategies](#types-of-strategies) + * [Multiprocessing](#multiprocessing) * [DataFrame Properties](#dataframe-properties) * [DataFrame Methods](#dataframe-methods) * [Indicators by Category](#indicators-by-category) @@ -81,7 +82,7 @@ _Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that lever * **BETA** Also Pandas TA will run TA Lib's version, this includes TA Lib's 63 Chart Patterns. * Indicators are tightly correlated with the de facto [TA Lib](https://mrjbq7.github.io/ta-lib/) if they share common indicators. * Example Jupyter Notebook with **vectorbt** Portfolio Backtesting with Pandas TA's ```ta.tsignals``` method. -* Have the need for speed? By using the DataFrame _strategy_ method, you get **multiprocessing** for free! +* Have the need for speed? By using the DataFrame _strategy_ method, you get **multiprocessing** for free! __Conditions permitting__. * 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/main/examples) directory, including how to create Custom Strategies using the new [__Strategy__ Class](https://github.com/twopirllc/pandas-ta/tree/main/examples/PandaTA_Strategy_Examples.ipynb) * Potential Data Leaks: **ichimoku** and **dpo**. See indicator list below for details. @@ -103,14 +104,15 @@ _Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that lever Stable ------ -The ```pip``` version is the last most stable release. Version: *0.2.45b* +The ```pip``` version is the last stable release. Version: *0.2.45b* ```sh $ pip install pandas_ta ``` Latest Version -------------- -Best choice! Version: *0.2.94b* +Best choice! Version: *0.2.95b* +* Includes all fixes and updates between **pypi** and what is covered in this README. ```sh $ pip install -U git+https://github.com/twopirllc/pandas-ta ``` @@ -208,7 +210,7 @@ Thanks for using **Pandas TA**! _Thank you for your contributions!_ -[AbyssAlora](https://github.com/AbyssAlora) | [alexonab](https://github.com/alexonab) | [allahyarzadeh](https://github.com/allahyarzadeh) | [CMobley7](https://github.com/CMobley7) | [codesutras](https://github.com/codesutras) | [DrPaprikaa](https://github.com/DrPaprikaa) | [daikts](https://github.com/daikts) | [dorren](https://github.com/dorren) | [edwardwang1](https://github.com/edwardwang1) | [ffhirata](https://github.com/ffhirata) | [FGU1](https://github.com/FGU1) | [floatinghotpot](https://github.com/floatinghotpot) | [GSlinger](https://github.com/gslinger) | [JoeSchr](https://github.com/JoeSchr) | [lluissalord](https://github.com/lluissalord) | [luisbarrancos](https://github.com/luisbarrancos) | [M6stafa](https://github.com/M6stafa) | [maxdignan](https://github.com/maxdignan) | [mchant](https://github.com/mchant) | [moritzgun](https://github.com/moritzgun) | [nicoloridulfo](https://github.com/nicoloridulfo) [NkosenhleDuma](https://github.com/NkosenhleDuma) | [pbrumblay](https://github.com/pbrumblay) | [RajeshDhalange](https://github.com/RajeshDhalange) | [rengel8](https://github.com/rengel8) | [rluong003](https://github.com/rluong003) | [SoftDevDanial](https://github.com/SoftDevDanial) | [tg12](https://github.com/tg12) | [twrobel](https://github.com/twrobel) | [WellMaybeItIs](https://github.com/WellMaybeItIs) | [whubsch](https://github.com/whubsch) | [witokondoria](https://github.com/witokondoria) | [wouldayajustlookatit](https://github.com/wouldayajustlookatit) | [YuvalWein](https://github.com/YuvalWein) +[AbyssAlora](https://github.com/AbyssAlora) | [alexonab](https://github.com/alexonab) | [allahyarzadeh](https://github.com/allahyarzadeh) | [bizso09](https://github.com/bizso09) | [CMobley7](https://github.com/CMobley7) | [codesutras](https://github.com/codesutras) | [DrPaprikaa](https://github.com/DrPaprikaa) | [daikts](https://github.com/daikts) | [dorren](https://github.com/dorren) | [edwardwang1](https://github.com/edwardwang1) | [ffhirata](https://github.com/ffhirata) | [FGU1](https://github.com/FGU1) | [floatinghotpot](https://github.com/floatinghotpot) | [GSlinger](https://github.com/gslinger) | [JoeSchr](https://github.com/JoeSchr) | [lluissalord](https://github.com/lluissalord) | [luisbarrancos](https://github.com/luisbarrancos) | [M6stafa](https://github.com/M6stafa) | [maxdignan](https://github.com/maxdignan) | [mchant](https://github.com/mchant) | [moritzgun](https://github.com/moritzgun) | [nicoloridulfo](https://github.com/nicoloridulfo) [NkosenhleDuma](https://github.com/NkosenhleDuma) | [pbrumblay](https://github.com/pbrumblay) | [RajeshDhalange](https://github.com/RajeshDhalange) | [rengel8](https://github.com/rengel8) | [rluong003](https://github.com/rluong003) | [SoftDevDanial](https://github.com/SoftDevDanial) | [tg12](https://github.com/tg12) | [twrobel](https://github.com/twrobel) | [WellMaybeItIs](https://github.com/WellMaybeItIs) | [whubsch](https://github.com/whubsch) | [witokondoria](https://github.com/witokondoria) | [wouldayajustlookatit](https://github.com/wouldayajustlookatit) | [YuvalWein](https://github.com/YuvalWein)
diff --git a/pandas_ta/utils/_time.py b/pandas_ta/utils/_time.py index f7ddaae..06119bf 100644 --- a/pandas_ta/utils/_time.py +++ b/pandas_ta/utils/_time.py @@ -19,7 +19,9 @@ def df_dates(df: DataFrame, dates: Tuple[str, list] = None) -> DataFrame: def df_month_to_date(df: DataFrame) -> DataFrame: """Yields the Month-to-Date (MTD) DataFrame""" - return df[df.index >= Timestamp.now().strftime("%Y-%m-01")] + in_mtd = df.index >= Timestamp.now().strftime("%Y-%m-01") + if any(in_mtd): return df[in_mtd] + return df def df_quarter_to_date(df: DataFrame) -> DataFrame: @@ -27,13 +29,16 @@ def df_quarter_to_date(df: DataFrame) -> DataFrame: now = Timestamp.now() for m in [1, 4, 7, 10]: if now.month <= m: - return df[df.index >= datetime(now.year, m, 1).strftime("%Y-%m-01")] + in_qtr = df.index >= datetime(now.year, m, 1).strftime("%Y-%m-01") + if any(in_qtr): return df[in_qtr] return df[df.index >= now.strftime("%Y-%m-01")] def df_year_to_date(df: DataFrame) -> DataFrame: """Yields the Year-to-Date (YTD) DataFrame""" - return df[df.index >= Timestamp.now().strftime("%Y-01-01")] + in_ytd = df.index >= Timestamp.now().strftime("%Y-01-01") + if any(in_ytd): return df[in_ytd] + return df def final_time(stime: float) -> str: @@ -105,6 +110,6 @@ def to_utc(df: DataFrame) -> DataFrame: # Aliases -mtd_df = df_month_to_date -qtd_df = df_quarter_to_date -ytd_df = df_year_to_date \ No newline at end of file +mtd = df_month_to_date +qtd = df_quarter_to_date +ytd = df_year_to_date \ No newline at end of file diff --git a/pandas_ta/utils/data/yahoofinance.py b/pandas_ta/utils/data/yahoofinance.py index e923413..10c3767 100644 --- a/pandas_ta/utils/data/yahoofinance.py +++ b/pandas_ta/utils/data/yahoofinance.py @@ -2,7 +2,7 @@ from pandas import DataFrame from pandas_ta import Imports, RATE, version from .._core import _camelCase2Title -from .._time import ytd_df +from .._time import ytd def yf(ticker: str, **kwargs): @@ -280,7 +280,7 @@ def yf(ticker: str, **kwargs): if kind in _all + ["recommendations", "rec"]: recdf = yfd.recommendations if recdf is not None: - recdf = ytd_df(recdf) + recdf = ytd(recdf) # recdf_grade = recdf["To Grade"].value_counts().T # recdf_grade.name = "Grades" if kind not in _all: print(f"\n{ticker_info['symbol']}") diff --git a/setup.py b/setup.py index 35eeac0..69ee692 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( "pandas_ta.volatility", "pandas_ta.volume" ], - version=".".join(("0", "2", "94b")), + version=".".join(("0", "2", "95b")), description=long_description, long_description=long_description, author="Kevin Johnson",