2024-11-27 20:31:49 +00:00
# Strategies
2024-12-11 16:40:38 +00:00
This module provides implementations of various trading strategies.
2025-01-07 19:59:17 +00:00
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.
2025-01-07 20:08:00 +00:00
## 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)
```
2024-12-11 16:43:45 +00:00
## 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)
2024-12-11 03:21:00 +00:00
## 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
```
2024-11-27 20:31:49 +00:00
---