{"id":49880033,"url":"https://github.com/pardnio/go-stock-notification","last_synced_at":"2026-05-15T13:40:40.164Z","repository":{"id":353609420,"uuid":"1130086028","full_name":"pardnio/go-stock-notification","owner":"pardnio","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-21T05:27:07.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-24T17:35:29.064Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pardnio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-08T02:29:46.000Z","updated_at":"2026-04-12T09:15:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pardnio/go-stock-notification","commit_stats":null,"previous_names":["pardnio/go-stock-notification"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pardnio/go-stock-notification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fgo-stock-notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fgo-stock-notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fgo-stock-notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fgo-stock-notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pardnio","download_url":"https://codeload.github.com/pardnio/go-stock-notification/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnio%2Fgo-stock-notification/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33068889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-15T13:40:38.592Z","updated_at":"2026-05-15T13:40:40.151Z","avatar_url":"https://github.com/pardnio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!NOTE]\n\u003e This README was generated by [Claude Code](https://gist.github.com/pardnchiu/b09c9bf1166ec7759cbbeeae2e4e93df), get the ZH version from [here](./README.zh.md).\n\n# go-stock-notification\n\n\u003e A stock price notification service powered by PostgreSQL LISTEN/NOTIFY, automatically pushing Discord alerts when prices hit target thresholds.\n\n## Features\n\n- **Database-Driven Notifications**: Leverages PostgreSQL Triggers and pg_notify for real-time price monitoring without polling\n- **Discord Integration**: Sends formatted embedded notification messages via Webhook\n- **RESTful API**: Provides simple HTTP endpoints for setting prices and notification thresholds\n\n## Architecture\n\n```mermaid\nsequenceDiagram\n    participant Client\n    participant Gin as Gin Server\n    participant PG as PostgreSQL\n    participant App as Go Listener\n    participant Discord\n\n    Client-\u003e\u003eGin: PUT /set/:ticker/price/:price\n    Gin-\u003e\u003ePG: UPDATE ticker_price\n    PG-\u003e\u003ePG: Trigger check_price()\n    PG-\u003e\u003ePG: INSERT/UPDATE ticker_notify\n    PG-\u003e\u003eApp: pg_notify('ticker_notify', payload)\n    App-\u003e\u003eDiscord: POST Webhook\n```\n\n## Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/neurowatt-dev/go-stock-notification.git\ncd go-stock-notification\n\n# Copy environment template\ncp .env.example .env\n# Edit .env with your database and Discord Webhook settings\n\n# Start with Docker Compose\ndocker compose up -d\n```\n\n## Usage\n\n### Set Notification Threshold\n\nConfigure the price level at which notifications trigger:\n\n```bash\n# Set AAPL notification price to 150.00\ncurl http://localhost:8080/set/AAPL/notify/150.00\n```\n\n### Update Stock Price\n\nUpdate the latest stock price; crossing the threshold triggers a notification:\n\n```bash\n# Update AAPL price to 151.50\ncurl http://localhost:8080/set/AAPL/price/151.50\n```\n\n### Notification Logic\n\n- **Breakout Up**: Triggers when price rises from below to at or above threshold\n- **Breakdown**: Triggers when price falls from at or above to below threshold\n- **Direction Change**: Notifications only sent on direction change to prevent duplicates\n\n## Configuration Reference\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `DB_USER` | PostgreSQL username | `postgres` |\n| `DB_PASSWORD` | PostgreSQL password | `password` |\n| `DB_NAME` | Database name | `database` |\n| `DB_PORT` | Database port | `5432` |\n\n### Database Schema\n\n| Table | Purpose |\n|-------|---------|\n| `ticker_price` | Stores ticker symbols with current and previous prices |\n| `ticker_compare` | Stores notification threshold prices |\n| `ticker_notify` | Stores notification state and trigger direction |\n\n### API Endpoints\n\n| Method | Path | Description |\n|--------|------|-------------|\n| GET | `/set/:ticker/notify/:price` | Set notification threshold |\n| GET | `/set/:ticker/price/:price` | Update stock price |\n\n## License\n\nThis is a private project.\n\n## Author\n\n\u003cimg src=\"https://avatars.githubusercontent.com/u/25631760\" align=\"left\" width=\"96\" height=\"96\" style=\"margin-right: 0.5rem;\"\u003e\n\n\u003ch4 style=\"padding-top: 0\"\u003e邱敬幃 Pardn Chiu\u003c/h4\u003e\n\n\u003ca href=\"mailto:dev@pardn.io\" target=\"_blank\"\u003e\n\u003cimg src=\"https://pardn.io/image/email.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e \u003ca href=\"https://linkedin.com/in/pardnchiu\" target=\"_blank\"\u003e\n\u003cimg src=\"https://pardn.io/image/linkedin.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e\n\n***\n\n©️ 2026 [邱敬幃 Pardn Chiu](https://linkedin.com/in/pardnchiu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnio%2Fgo-stock-notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpardnio%2Fgo-stock-notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnio%2Fgo-stock-notification/lists"}