Go to file
2025-01-10 08:48:46 -08:00
strategies Update docstring in TPS strategy 2025-01-10 08:42:53 -08:00
test Add test for TPS strategy 2025-01-10 08:42:05 -08:00
.gitignore Add .vscode/ directory to strategies module .gitignore 2025-01-08 10:45:36 -08:00
pyproject.toml Add dependency on twine to pyproject.toml for strategies package 2025-01-07 09:03:16 -08:00
README.md Add example signal output to strategies module documentation 2025-01-10 08:48:46 -08:00

Strategies

This module provides implementations of various trading strategies.

The 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:

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:

Local Workspace Setup

After checking out the repository, the dependencies can be installed as follows (ideally in a virtual environment):

pip install . --extra-index-url https://moshferatu.dev/api/packages/moshferatu/pypi/simple

If you want the build and test dependencies as well:

pip install .[build,test] --extra-index-url https://moshferatu.dev/api/packages/moshferatu/pypi/simple