Add example of indicator usage to indicators module README
This commit is contained in:
parent
14b0ccec92
commit
d630f45471
35
README.md
35
README.md
@ -13,4 +13,39 @@ pandas
|
||||
|
||||
There is also a dependency on the [OHLC module](https://moshferatu.dev/moshferatu/ohlc) for running tests.
|
||||
|
||||
## Example Usage
|
||||
|
||||
The following is an example of using the provided [RSI indicator](https://moshferatu.dev/moshferatu/indicators/src/branch/main/indicators/rsi.py):
|
||||
|
||||
```python
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from indicators import rsi
|
||||
from ohlc import ohlc
|
||||
|
||||
today = datetime.today()
|
||||
data = ohlc('SPY', start_date = today - timedelta(days = 365), end_date = today)
|
||||
|
||||
rsi_values = rsi(data, period = 14)
|
||||
print(rsi_values)
|
||||
```
|
||||
|
||||
The result will be returned as a ```pandas``` **Series**.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
0 0.000000
|
||||
1 0.000000
|
||||
2 0.000000
|
||||
3 66.017608
|
||||
4 75.789601
|
||||
...
|
||||
246 63.393288
|
||||
247 66.070866
|
||||
248 63.168300
|
||||
249 66.415897
|
||||
250 67.316906
|
||||
```
|
||||
|
||||
---
|
Loading…
Reference in New Issue
Block a user