# Strategies 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) ``` Resulting signals: ``` Date Signal 0 2024-01-11 L 1 2024-01-12 N 2 2024-01-16 L 3 2024-01-17 L 4 2024-01-18 N .. ... ... 245 2025-01-02 L 246 2025-01-03 N 247 2025-01-06 N 248 2025-01-07 N 249 2025-01-08 N ``` ## Dependencies The strategies module depends on the following Python packages: ``` numpy pandas ``` It also depends on the following packages hosted here: * [Indicators](https://moshferatu.dev/moshferatu/indicators) * [OHLC](https://moshferatu.dev/moshferatu/ohlc) (only required for running tests) ## Local Workspace Setup After checking out the repository, the dependencies can be installed as follows (ideally in a virtual environment): ```shell pip install . --extra-index-url https://moshferatu.dev/api/packages/moshferatu/pypi/simple ``` If you want the build and test dependencies as well: ```shell pip install .[build,test] --extra-index-url https://moshferatu.dev/api/packages/moshferatu/pypi/simple ``` ---