You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+180-1Lines changed: 180 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,8 @@ pip install pyindicators
37
37
*[Indicator helpers](#indicator-helpers)
38
38
*[Crossover](#crossover)
39
39
*[Is Crossover](#is-crossover)
40
+
*[Crossunder](#crossunder)
41
+
*[Is Crossunder](#is-crossunder)
40
42
41
43
## Indicators
42
44
@@ -207,6 +209,19 @@ pd_df.tail(10)
207
209
208
210
#### Relative Strength Index (RSI)
209
211
212
+
The Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements. It moves between 0 and 100 and is used to identify overbought or oversold conditions in a market.
213
+
214
+
```python
215
+
defrsi(
216
+
data: Union[pd.DataFrame, pl.DataFrame],
217
+
source_column: str,
218
+
period: int=14,
219
+
result_column: str=None,
220
+
) -> Union[pd.DataFrame, pl.DataFrame]:
221
+
```
222
+
223
+
Example
224
+
210
225
```python
211
226
from investing_algorithm_framework import CSVOHLCVMarketDataSource
212
227
@@ -232,6 +247,19 @@ pd_df.tail(10)
232
247
233
248
#### Wilders Relative Strength Index (Wilders RSI)
234
249
250
+
The Wilders Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements. It moves between 0 and 100 and is used to identify overbought or oversold conditions in a market. The Wilders RSI uses a different calculation method than the standard RSI.
251
+
252
+
```python
253
+
defwilders_rsi(
254
+
data: Union[pd.DataFrame, pl.DataFrame],
255
+
source_column: str,
256
+
period: int=14,
257
+
result_column: str=None,
258
+
) -> Union[pd.DataFrame, pl.DataFrame]:
259
+
```
260
+
261
+
Example
262
+
235
263
```python
236
264
from investing_algorithm_framework import CSVOHLCVMarketDataSource
237
265
@@ -259,7 +287,6 @@ pd_df.tail(10)
259
287
260
288
Williams %R (Williams Percent Range) is a momentum indicator used in technical analysis to measure overbought and oversold conditions in a market. It moves between 0 and -100 and helps traders identify potential reversal points.
261
289
262
-
263
290
```python
264
291
defwillr(
265
292
data: Union[pd.DataFrame, pl.DataFrame],
@@ -300,6 +327,21 @@ pd_df.tail(10)
300
327
301
328
#### Crossover
302
329
330
+
The crossover function is used to calculate the crossover between two columns in a DataFrame. It returns a new DataFrame with an additional column that contains the crossover values. A crossover occurs when the first column crosses above or below the second column. This can happen in two ways, a strict crossover or a non-strict crossover. In a strict crossover, the first column must cross above or below the second column. In a non-strict crossover, the first column must cross above or below the second column, but the values can be equal.
331
+
332
+
```python
333
+
defcrossover(
334
+
data: Union[PdDataFrame, PlDataFrame],
335
+
first_column: str,
336
+
second_column: str,
337
+
result_column="crossover",
338
+
data_points: int=None,
339
+
strict: bool=True,
340
+
) -> Union[PdDataFrame, PlDataFrame]:
341
+
```
342
+
343
+
Example
344
+
303
345
```python
304
346
from polars import DataFrame as plDataFrame
305
347
from pandas import DataFrame as pdDataFrame
@@ -341,6 +383,21 @@ pd_df.tail(10)
341
383
342
384
#### Is Crossover
343
385
386
+
The is_crossover function is used to determine if a crossover occurred in the last N data points. It returns a boolean value indicating if a crossover occurred in the last N data points. The function can be used to check for crossovers in a DataFrame that was previously calculated using the crossover function.
387
+
388
+
```python
389
+
defis_crossover(
390
+
data: Union[PdDataFrame, PlDataFrame],
391
+
first_column: str=None,
392
+
second_column: str=None,
393
+
crossover_column: str=None,
394
+
number_of_data_points: int=None,
395
+
strict=True,
396
+
) -> bool:
397
+
```
398
+
399
+
Example
400
+
344
401
```python
345
402
from polars import DataFrame as plDataFrame
346
403
from pandas import DataFrame as pdDataFrame
@@ -395,3 +452,125 @@ if is_crossover(
395
452
if is_crossover(pd_df, crossover_column="Crossover_EMA", data_points=3):
396
453
print("Crossover detected in Pandas DataFrame in the last 3 data points")
397
454
```
455
+
456
+
#### Crossunder
457
+
458
+
The crossunder function is used to calculate the crossunder between two columns in a DataFrame. It returns a new DataFrame with an additional column that contains the crossunder values. A crossunder occurs when the first column crosses below the second column. This can happen in two ways, a strict crossunder or a non-strict crossunder. In a strict crossunder, the first column must cross below the second column. In a non-strict crossunder, the first column must cross below the second column, but the values can be equal.
459
+
460
+
```python
461
+
defcrossunder(
462
+
data: Union[PdDataFrame, PlDataFrame],
463
+
first_column: str,
464
+
second_column: str,
465
+
result_column="crossunder",
466
+
data_points: int=None,
467
+
strict: bool=True,
468
+
) -> Union[PdDataFrame, PlDataFrame]:
469
+
```
470
+
471
+
Example
472
+
473
+
```python
474
+
from polars import DataFrame as plDataFrame
475
+
from pandas import DataFrame as pdDataFrame
476
+
477
+
from investing_algorithm_framework import CSVOHLCVMarketDataSource
478
+
from pyindicators import crossunder, ema
479
+
480
+
# For this example the investing algorithm framework is used for dataframe creation,
The is_crossunder function is used to determine if a crossunder occurred in the last N data points. It returns a boolean value indicating if a crossunder occurred in the last N data points. The function can be used to check for crossunders in a DataFrame that was previously calculated using the crossunder function.
515
+
516
+
```python
517
+
defis_crossunder(
518
+
data: Union[PdDataFrame, PlDataFrame],
519
+
first_column: str=None,
520
+
second_column: str=None,
521
+
crossunder_column: str=None,
522
+
number_of_data_points: int=None,
523
+
strict: bool=True,
524
+
) -> bool:
525
+
```
526
+
527
+
Example
528
+
529
+
```python
530
+
from polars import DataFrame as plDataFrame
531
+
from pandas import DataFrame as pdDataFrame
532
+
533
+
from investing_algorithm_framework import CSVOHLCVMarketDataSource
534
+
from pyindicators import crossunder, ema, is_crossunder
535
+
536
+
# For this example the investing algorithm framework is used for dataframe creation,
0 commit comments