Add usage example to strategies module documentation
This commit is contained in:
parent
4dd366ee16
commit
d70a3ebbd6
23
README.md
23
README.md
@ -4,6 +4,29 @@ This module provides implementations of various trading strategies.
|
||||
|
||||
The [Swing Trading Dashboard](https://moshferatu.dev/moshferatu/swing-trading-dashboard) depends on this module in order to provide an overview of recent trade signals.
|
||||
|
||||
## Example Usage
|
||||
|
||||
The following is an example of obtaining trade signals for the 2-Period RSI strategy:
|
||||
|
||||
```python
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from ohlc import ohlc
|
||||
from strategies import two_period_rsi
|
||||
|
||||
# Obtain the necessary OHLC data first.
|
||||
today = datetime.today()
|
||||
data = ohlc('SPY', start_date = today - timedelta(days = 365), end_date = today)
|
||||
|
||||
# Signals are returned as a pandas Series.
|
||||
signals = two_period_rsi(data)
|
||||
|
||||
# Combining signals with date information from the OHLC data for demonstration purposes only.
|
||||
result = data[['Date']].copy()
|
||||
result['Signal'] = signals
|
||||
print(result)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The strategies module depends on the following Python packages:
|
||||
|
Loading…
Reference in New Issue
Block a user