PyIndicators is a powerful and user-friendly Python library for technical analysis indicators and metrics. Written entirely in Python, it requires no external dependencies, ensuring seamless integration and ease of use.
Project description
PyIndicators
PyIndicators is a powerful and user-friendly Python library for technical analysis indicators and metrics. Written entirely in Python, it requires no external dependencies, ensuring seamless integration and ease of use.
Installation
PyIndicators can be installed using pip:
pip install pyindicators
Features
- Native Python implementation, no external dependencies needed except for Polars or Pandas
- Dataframe first approach, with support for both pandas dataframes and polars dataframes
- Trend indicators
- Momentum indicators
Indicators
Trend Indicators
Simple Moving Average (SMA)
from investing_algorithm_framework import CSVOHLCVMarketDataSource
from pyindicators import sma
# For this example the investing algorithm framework is used for dataframe creation,
csv_path = "./tests/test_data/OHLCV_BTC-EUR_BINANCE_15m_2023-12-01:00:00_2023-12-25:00:00.csv"
data_source = CSVOHLCVMarketDataSource(csv_file_path=csv_path)
pl_df = data_source.get_data()
pd_df = data_source.get_data(pandas=True)
# Calculate SMA for Polars DataFrame
pl_df = sma(pl_df, source_column="Close", period=200, result_column="SMA_200")
pl_df.show(10)
# Calculate SMA for Pandas DataFrame
pd_df = sma(pd_df, source_column="Close", period=200, result_column="SMA_200")
pd_df.tail(10)
Exponential Moving Average (EMA)
from investing_algorithm_framework import CSVOHLCVMarketDataSource
from pyindicators import ema
# For this example the investing algorithm framework is used for dataframe creation,
csv_path = "./tests/test_data/OHLCV_BTC-EUR_BINANCE_15m_2023-12-01:00:00_2023-12-25:00:00.csv"
data_source = CSVOHLCVMarketDataSource(csv_file_path=csv_path)
pl_df = data_source.get_data()
pd_df = data_source.get_data(pandas=True)
# Calculate EMA for Polars DataFrame
pl_df = ema(pl_df, source_column="Close", period=200, result_column="EMA_200")
pl_df.show(10)
# Calculate EMA for Pandas DataFrame
pd_df = ema(pd_df, source_column="Close", period=200, result_column="EMA_200")
pd_df.tail(10)
Momentum Indicators
Relative Strength Index (RSI)
from investing_algorithm_framework import CSVOHLCVMarketDataSource
from pyindicators import rsi
# For this example the investing algorithm framework is used for dataframe creation,
csv_path = "./tests/test_data/OHLCV_BTC-EUR_BINANCE_15m_2023-12-01:00:00_2023-12-25:00:00.csv"
data_source = CSVOHLCVMarketDataSource(csv_file_path=csv_path)
pl_df = data_source.get_data()
pd_df = data_source.get_data(pandas=True)
# Calculate RSI for Polars DataFrame
pl_df = rsi(pl_df, source_column="Close", period=14, result_column="RSI_14")
pl_df.show(10)
# Calculate RSI for Pandas DataFrame
pd_df = rsi(pd_df, source_column="Close", period=14, result_column="RSI_14")
pd_df.tail(10)
Wilders Relative Strength Index (Wilders RSI)
from investing_algorithm_framework import CSVOHLCVMarketDataSource
from pyindicators import wilders_rsi
# For this example the investing algorithm framework is used for dataframe creation,
csv_path = "./tests/test_data/OHLCV_BTC-EUR_BINANCE_15m_2023-12-01:00:00_2023-12-25:00:00.csv"
data_source = CSVOHLCVMarketDataSource(csv_file_path=csv_path)
pl_df = data_source.get_data()
pd_df = data_source.get_data(pandas=True)
# Calculate Wilders RSI for Polars DataFrame
pl_df = wilders_rsi(pl_df, source_column="Close", period=14, result_column="RSI_14")
pl_df.show(10)
# Calculate Wilders RSI for Pandas DataFrame
pd_df = wilders_rsi(pd_df, source_column="Close", period=14, result_column="RSI_14")
pd_df.tail(10)
Indicator helpers
Is Crossover
from polars import DataFrame as plDataFrame
from pandas import DataFrame as pdDataFrame
from pyindicators import is_crossover
# Polars DataFrame
pl_df = plDataFrame({
"EMA_50": [200, 201, 202, 203, 204, 205, 206, 208, 208, 210],
"EMA_200": [200, 201, 202, 203, 204, 205, 206, 207, 209, 209],
"DateTime": pd.date_range("2021-01-01", periods=10, freq="D")
})
# Pandas DataFrame
pd_df = pdDataFrame({
"EMA_50": [200, 201, 202, 203, 204, 205, 206, 208, 208, 210],
"EMA_200": [200, 201, 202, 203, 204, 205, 206, 207, 209, 209],
"DateTime": pd.date_range("2021-01-01", periods=10, freq="D")
})
if is_crossover(
pl_df, first_column="EMA_50", second_column="EMA_200", data_points=3
):
print("Crossover detected in Polars DataFrame")
if is_crossover(
pd_df, first_column="EMA_50", second_column="EMA_200", data_points=3
):
print("Crossover detected in Pandas DataFrame")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyindicators-0.2.0.tar.gz.
File metadata
- Download URL: pyindicators-0.2.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.3 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f05a95246a3a6f3536fa84bc23b2f7e3261e5dab579ff02a33c9450f0ebb745a
|
|
| MD5 |
ecd50064c7ea059d721d2de311a3b670
|
|
| BLAKE2b-256 |
1dc44a6b84fd75a9a1ac003c2e0149abd47e4a37b18b220093851e20fcb47c09
|
File details
Details for the file pyindicators-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyindicators-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.3 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
236e9e76232e103777416972980f51ae3d1b480060c9fb8f3dcdc15b7347a40c
|
|
| MD5 |
867c071790712652462fae4077d0772d
|
|
| BLAKE2b-256 |
23b0a1730fffc26142aee4fc15dd5d8975a0ded494bc505fea86980d7bdf80a1
|