Skip to content

Commit 3c6597b

Browse files
committed
Add example's
1 parent 480b9cf commit 3c6597b

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

README.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pip install pyindicators
2929
* [Weighted Moving Average (WMA)](#weighted-moving-average-wma)
3030
* [Simple Moving Average (SMA)](#simple-moving-average-sma)
3131
* [Exponential Moving Average (EMA)](#exponential-moving-average-ema)
32-
* [Moving Average Convergence Divergence (MACD)](#moving-average-convergence-divergence-macd)
3332
* [Momentum indicators](#momentum-indicators)
33+
* [Moving Average Convergence Divergence (MACD)](#moving-average-convergence-divergence-macd)
3434
* [Relative Strength Index (RSI)](#relative-strength-index-rsi)
3535
* [Relative Strength Index Wilders method (Wilders RSI)](#wilders-relative-strength-index-wilders-rsi)
3636
* [Williams %R](#williams-r)
@@ -46,15 +46,15 @@ Indicators that help to determine the direction of the market (uptrend, downtren
4646

4747
#### Weighted Moving Average (WMA)
4848

49-
Moving average that gives more weight to recent data points by applying a weighting factor to the data points.
49+
A Weighted Moving Average (WMA) is a type of moving average that assigns greater importance to recent data points compared to older ones. This makes it more responsive to recent price changes compared to a Simple Moving Average (SMA), which treats all data points equally. The WMA does this by using linear weighting, where the most recent prices get the highest weight, and weights decrease linearly for older data points.
5050

5151
```python
5252
def wma(
5353
data: Union[PandasDataFrame, PolarsDataFrame],
5454
source_column: str,
5555
period: int,
5656
result_column: Optional[str] = None
57-
) -> Union[PandasDataFrame, PolarsDataFrame]
57+
) -> Union[PandasDataFrame, PolarsDataFrame]:
5858
```
5959

6060
Example
@@ -84,9 +84,18 @@ pd_df.tail(10)
8484

8585
#### Simple Moving Average (SMA)
8686

87-
Smooth out price data to identify trend direction.
87+
A Simple Moving Average (SMA) is the average of the last N data points, recalculated as new data comes in. Unlike the Weighted Moving Average (WMA), SMA treats all values equally, giving them the same weight.
8888

89-
>sma(data: DataFrame, source_column: str, period: int, result_column: Optional[str]) - DataFrame
89+
```python
90+
def sma(
91+
data: Union[PdDataFrame, PlDataFrame],
92+
source_column: str,
93+
period: int,
94+
result_column: str = None,
95+
) -> Union[PdDataFrame, PlDataFrame]:
96+
```
97+
98+
Example
9099

91100
```python
92101
from investing_algorithm_framework import CSVOHLCVMarketDataSource
@@ -113,6 +122,19 @@ pd_df.tail(10)
113122

114123
#### Exponential Moving Average (EMA)
115124

125+
The Exponential Moving Average (EMA) is a type of moving average that gives more weight to recent prices, making it more responsive to price changes than a Simple Moving Average (SMA). It does this by using an exponential decay where the most recent prices get exponentially more weight.
126+
127+
```python
128+
def ema(
129+
data: Union[PdDataFrame, PlDataFrame],
130+
source_column: str,
131+
period: int,
132+
result_column: str = None,
133+
) -> Union[PdDataFrame, PlDataFrame]:
134+
```
135+
136+
Example
137+
116138
```python
117139
from investing_algorithm_framework import CSVOHLCVMarketDataSource
118140

@@ -136,8 +158,29 @@ pd_df.tail(10)
136158

137159
![EMA](https://github.com/coding-kitties/PyIndicators/blob/main/static/images/indicators/ema.png)
138160

161+
### Momentum Indicators
162+
163+
Indicators that measure the strength and speed of price movements rather than the direction.
164+
139165
#### Moving Average Convergence Divergence (MACD)
140166

167+
The Moving Average Convergence Divergence (MACD) is used to identify trend direction, strength, and potential reversals. It is based on the relationship between two Exponential Moving Averages (EMAs) and includes a histogram to visualize momentum.
168+
169+
```python
170+
def macd(
171+
data: Union[PdDataFrame, PlDataFrame],
172+
source_column: str,
173+
short_period: int = 12,
174+
long_period: int = 26,
175+
signal_period: int = 9,
176+
macd_column: str = "macd",
177+
signal_column: str = "macd_signal",
178+
histogram_column: str = "macd_histogram"
179+
) -> Union[PdDataFrame, PlDataFrame]:
180+
```
181+
182+
Example
183+
141184
```python
142185
from investing_algorithm_framework import CSVOHLCVMarketDataSource
143186

@@ -160,11 +203,7 @@ pl_df.show(10)
160203
pd_df.tail(10)
161204
```
162205

163-
![EMA](https://github.com/coding-kitties/PyIndicators/blob/main/static/images/indicators/macd.png)
164-
165-
### Momentum Indicators
166-
167-
Indicators that measure the strength and speed of price movements rather than the direction.
206+
![MACD](https://github.com/coding-kitties/PyIndicators/blob/main/static/images/indicators/macd.png)
168207

169208
#### Relative Strength Index (RSI)
170209

pyindicators/indicators/exponential_moving_average.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def ema(
1010
source_column: str,
1111
period: int,
1212
result_column: str = None,
13-
):
13+
) -> Union[PdDataFrame, PlDataFrame]:
1414
"""
1515
Function to calculate the Exponential Moving Average (EMA) of a series.
1616

0 commit comments

Comments
 (0)