Skip to main content

Financial market screening with pluggable rules and alerts

Project description

finwatch

Financial market screening with pluggable rules and alerts.

Screen stocks, crypto, commodities, or any Yahoo Finance-supported asset against technical rules. Get notified via Telegram (or your own alert channel) when conditions are met.

Installation

pip install finwatch
# or with uv
uv add finwatch

Quick start

from finwatch import Watcher
from finwatch.retrievers.yahoo import YahooPriceRetriever
from finwatch.rules.rsi import RSIRule, RSIDirection

watcher = Watcher(
    retriever=YahooPriceRetriever(),
    rules=[RSIRule(threshold=30, direction=RSIDirection.BELOW)],
    alerts=[],
    period="3mo",
)

results = watcher.run(["AAPL", "TSLA", "BTC-USD", "ETH-USD", "GC=F"])

for r in results:
    status = "TRIGGERED" if r.triggered else "ok"
    print(f"[{status}] {r.symbol}")
    for rr in r.rule_results:
        print(f"  {rr.message}")

Multi-rule screening with Telegram alerts

import os
from finwatch import Watcher
from finwatch.retrievers.yahoo import YahooPriceRetriever
from finwatch.rules.rsi import RSIRule, RSIDirection
from finwatch.alerts.telegram import TelegramAlert

watcher = Watcher(
    retriever=YahooPriceRetriever(),
    rules=[
        RSIRule(threshold=30, direction=RSIDirection.BELOW),  # oversold
        RSIRule(threshold=70, direction=RSIDirection.ABOVE),  # overbought
    ],
    alerts=[
        TelegramAlert(
            token=os.environ["TELEGRAM_TOKEN"],
            chat_id=os.environ["TELEGRAM_CHAT_ID"],
        )
    ],
    period="3mo",
)

results = watcher.run(["AAPL", "TSLA", "MSFT", "BTC-USD", "ETH-USD"])
triggered = [r for r in results if r.triggered]
print(f"Screened {len(results)} assets — {len(triggered)} triggered.")

Each symbol is evaluated against all rules. ScreenResult.triggered is True if any rule fires. Inspect result.rule_results for per-rule detail.

Architecture

symbols
  └─▶ PriceRetriever.fetch()  ─▶  list[PriceBar]
                                        │
                              Rule.evaluate()  (×N rules)
                                        │
                              list[RuleResult]
                                        │
                              Watcher assembles  ─▶  list[ScreenResult]
                                        │
                           triggered results ─▶ Alert.send()

Extending finwatch

Custom PriceRetriever

from finwatch.retrievers.base import PriceRetriever
from finwatch.models import PriceBar

class MyRetriever(PriceRetriever):
    def fetch(self, symbol: str, period: str = "3mo") -> list[PriceBar]:
        # fetch from your data source
        ...

Custom Rule

from finwatch.rules.base import Rule
from finwatch.models import PriceBar, RuleResult

class MyRule(Rule):
    @property
    def name(self) -> str:
        return "MyRule"

    def evaluate(self, symbol: str, bars: list[PriceBar]) -> RuleResult:
        # compute indicator, return RuleResult
        ...

For indicator math, add a pure function to finwatch/indicators/ and import it in your rule.

Custom Alert

from finwatch.alerts.base import Alert
from finwatch.models import ScreenResult

class MyAlert(Alert):
    async def send(self, results: list[ScreenResult]) -> None:
        for r in results:
            if r.triggered:
                # send email, Slack, webhook, etc.
                ...

Environment variables

Variable Description
TELEGRAM_TOKEN Bot API token from @BotFather
TELEGRAM_CHAT_ID Target chat ID or channel username

Development

uv sync --all-extras

# Lint + format
ruff check . --fix && ruff format .

# Type check
mypy src/

# Tests
pytest --tb=short

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finwatch-0.2.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finwatch-0.2.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file finwatch-0.2.0.tar.gz.

File metadata

  • Download URL: finwatch-0.2.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for finwatch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9654101cf71499037d8496bd482df0f0d766efadbf318109cfd81a3e34cfe9f2
MD5 bdfc61cb385e26d62e1d79d6cfb38e77
BLAKE2b-256 71bba733f868136279998abaa8d6007d1291f015b72428e3bbbcd9ec2d9d441e

See more details on using hashes here.

Provenance

The following attestation bundles were made for finwatch-0.2.0.tar.gz:

Publisher: release.yml on winsonsutanto10/finwatch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file finwatch-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: finwatch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for finwatch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81a71c1079dbd0b5021d83b34985f51f9d0b1b2860e874723e982ed14326cf76
MD5 e6a47c50a93377cb09e59ce08a9a1899
BLAKE2b-256 10818d469ffacca8e0e07a53454691b3813ebc12145d249f1c186f5b98ef5b40

See more details on using hashes here.

Provenance

The following attestation bundles were made for finwatch-0.2.0-py3-none-any.whl:

Publisher: release.yml on winsonsutanto10/finwatch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page