From d70a3ebbd6d8e6ae3cb23a8f1db9e932735129d5 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Tue, 7 Jan 2025 12:08:00 -0800 Subject: [PATCH] Add usage example to strategies module documentation --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 7cbd0b0..9710ccf 100644 --- a/README.md +++ b/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: