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.
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 SMA for Polars DataFrame
pl_df = ema(pl_df, source_column="Close", period=200, result_column="EMA_200")
pl_df.show(10)
# Calculate SMA 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 polars import DataFrame as plDataFrame
from pandas import DataFrame as pdDataFrame
from pyindicators import rsi
# Polars DataFrame
pl_df = plDataFrame({"close": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
# Pandas DataFrame
pd_df = pdDataFrame({"close": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
# Calculate RSI for Polars DataFrame
pl_df = rsi(pl_df, "close", 14)
pl_df.show(10)
# Calculate RSI for Pandas DataFrame
pd_df = rsi(pd_df, "close", 14)
print(pd_df)
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.1.0.tar.gz.
File metadata
- Download URL: pyindicators-0.1.0.tar.gz
- Upload date:
- Size: 4.8 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 |
b19d22efa585012c7d1ebf802c4ca63881633664c548d6d833138c2d2d628cfe
|
|
| MD5 |
26e1de57bc3c70c44288ffbc457f3e71
|
|
| BLAKE2b-256 |
7df95911aabd16f0cf7eefcd1487a3c1ee26e8a73e1d8c21b565dae1efc8a651
|
File details
Details for the file pyindicators-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyindicators-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 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 |
7fe13018c335d43e9c9714056f9c91937394028ac5445a9876f3c57991cfbc0d
|
|
| MD5 |
7df5fd88d1e367172ec4f10ffe99e7c7
|
|
| BLAKE2b-256 |
761041622b2ed0ac32a32cde6f855b68aaaf72e07bee3442437bb6055e12df1c
|