{"id":44802192,"url":"https://github.com/srcfl/negative-price-calc","last_synced_at":"2026-02-16T13:35:11.770Z","repository":{"id":320386190,"uuid":"1034641653","full_name":"srcfl/negative-price-calc","owner":"srcfl","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-21T17:40:19.000Z","size":2344,"stargazers_count":2,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T01:45:26.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/srcfl.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":"2025-08-08T18:18:53.000Z","updated_at":"2025-10-21T17:40:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"9cc3bc2d-7921-4368-9076-d62328400711","html_url":"https://github.com/srcfl/negative-price-calc","commit_stats":null,"previous_names":["srcfl/negative-price-calc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/srcfl/negative-price-calc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srcfl%2Fnegative-price-calc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srcfl%2Fnegative-price-calc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srcfl%2Fnegative-price-calc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srcfl%2Fnegative-price-calc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srcfl","download_url":"https://codeload.github.com/srcfl/negative-price-calc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srcfl%2Fnegative-price-calc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29509202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: 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-02-16T13:35:10.935Z","updated_at":"2026-02-16T13:35:11.764Z","avatar_url":"https://github.com/srcfl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚡ Negative Price Calculator\n\nA simple web application to analyze electricity prices and solar production data, with focus on negative price detection and cost analysis for solar producers in Sweden.\n\n**[Quick Start →](QUICKSTART.md)** | **[Live Demo](http://localhost:8080)** (after running locally)\n\n\u003cimg src=\"https://img.shields.io/badge/Python-3.12+-blue.svg\" alt=\"Python 3.12+\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/License-MIT-green.svg\" alt=\"MIT License\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\" alt=\"PRs Welcome\"\u003e\n\n---\n\n## 🎯 What is this?\n\nWhen you have solar panels, you often sell excess electricity back to the grid. But sometimes electricity prices go **negative** - meaning you actually pay to export your energy! This tool helps you:\n\n- 📊 **Analyze your production data** - Upload your solar production CSV/Excel file\n- 💸 **Detect negative price periods** - See when your export cost you money\n- 📈 **Visualize the impact** - Interactive charts showing monthly patterns\n- 🤖 **Get AI insights** (optional) - Swedish-language explanations of your analysis\n- 💾 **Export results** - Download detailed Excel reports\n\n## ✨ Key Features\n\n- **🔌 No API keys required** - Uses free [Sourceful Price API](https://docs.sourceful.energy/developer/price-api)\n- **🌍 Webapp interface** - Simple drag-and-drop file upload\n- **🇸🇪 Swedish electricity areas** - Supports SE_1 through SE_4\n- **🤖 Optional AI explanations** - Add OpenAI key for AI-powered insights\n- **📊 Visual analytics** - Charts and metrics at a glance\n- **💾 Excel export** - Detailed analysis export\n- **🚀 Easy deployment** - Docker support included\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- Python 3.12+\n- [uv](https://docs.astral.sh/uv/) package manager\n\n### Install \u0026 Run (3 steps!)\n\n```bash\n# 1. Clone the repository\ngit clone https://github.com/srcfl/negative-price-calc.git\ncd negative-price-calc\n\n# 2. Install dependencies\nuv sync\n\n# 3. Start the webapp\nuv run python app.py\n```\n\nOpen your browser and go to `http://localhost:8080` 🎉\n\n**That's it!** No API keys needed for basic analysis.\n\n### Optional: Enable AI Explanations\n\nWant AI-powered insights? Just add your OpenAI API key:\n\n```bash\n# Copy environment template\ncp .env.example .env\n\n# Edit .env and add: OPENAI_API_KEY=your_key_here\n```\n\nRestart the webapp and AI explanations will appear automatically!\n\n## 🐳 Docker Deployment\n\n```bash\n# Build and run with docker-compose\ndocker-compose up --build\n\n# Open http://localhost:8080\n```\n\n## 🚂 Railway Deployment\n\nDeploy to [Railway](https://railway.app) with one click:\n\n### Backend API\n\n1. Create new project on Railway\n2. Connect your GitHub repo\n3. Set root directory to `/` (project root)\n4. Add environment variables:\n   - `OPENAI_API_KEY` (optional, for AI insights)\n   - `CORS_ORIGINS` (your frontend URL, e.g., `https://your-frontend.railway.app`)\n\n### Frontend\n\n1. Create another service in the same project\n2. Set root directory to `/frontend`\n3. Add environment variable:\n   - `NEXT_PUBLIC_API_URL` (your backend URL, e.g., `https://your-backend.railway.app`)\n\n### Environment Variables for Railway\n\n| Variable | Service | Description |\n|----------|---------|-------------|\n| `OPENAI_API_KEY` | Backend | Optional - enables AI explanations |\n| `CORS_ORIGINS` | Backend | Frontend URL(s), comma-separated |\n| `NEXT_PUBLIC_API_URL` | Frontend | Backend API URL |\n\n## 📖 How to Use\n\n1. **Upload your data**: CSV or Excel file with solar production (hourly or daily)\n2. **Select electricity area**: SE_1, SE_2, SE_3, or SE_4\n3. **Click \"Analysera\"**: Results appear in seconds\n4. **Review insights**: See negative price impact, timing losses, and more\n5. **Export if needed**: Download Excel report for deeper analysis\n\n### Supported File Formats\n\nThe tool intelligently handles various CSV/Excel formats. Your file should have:\n- **Timestamp/Date column**: DateTime or date values\n- **Production column**: Energy produced in kWh\n\nCommon column names are automatically detected (timestamp, date, production, kwh, etc.)\n\n### Example Files\n\nTry it out with sample files in `data/samples/` directory!\n\n## 🏗️ Architecture\n\n### Simple Structure\n\n```\nnegative-price-calc/\n├── app.py                      # Flask webapp (start here!)\n├── cli/                        # Command-line interface\n│   └── main.py                # CLI entrypoint\n├── core/                       # Analysis engine\n│   ├── price_fetcher.py       # Sourceful API integration\n│   ├── production_loader.py   # CSV/Excel parser\n│   └── price_analyzer.py      # Core analysis logic\n├── templates/                  # HTML templates\n│   └── index.html             # Main webapp UI\n└── data/                       # Data storage\n    ├── price_data.db          # SQLite price cache\n    └── samples/               # Example files\n```\n\n### Technology Stack\n\n- **Backend**: Flask + Python 3.12\n- **Price Data**: [Sourceful API](https://docs.sourceful.energy/developer/price-api) (free, no key required)\n- **AI**: OpenAI GPT (optional)\n- **Storage**: SQLite for price caching\n- **Frontend**: Modern HTML/CSS/JS with drag-and-drop\n\n## 🇸🇪 Swedish Electricity Areas\n\n- **SE_1**: Northern Sweden (Luleå) - Typically lowest prices\n- **SE_2**: Central Sweden (Sundsvall)\n- **SE_3**: Central Sweden (Stockholm)\n- **SE_4**: Southern Sweden (Malmö) - Highest price volatility\n\n## 📊 What Analysis is Provided?\n\n### Key Metrics\n\n- **Total Production**: Your solar output (kWh)\n- **Total Revenue**: Income from electricity export\n- **Negative Price Hours**: When export cost money\n- **Timing Loss**: How much below market average you received\n- **Monthly Breakdown**: Visual charts showing patterns\n\n### AI Insights (Optional)\n\nWith OpenAI API key configured:\n- Swedish-language explanation of your results\n- Key recommendations\n- Problem areas highlighted\n\n## 🛠️ Development\n\n### CLI Usage\n\nWant command-line access instead of webapp?\n\n```bash\n# Analyze with CLI\nuv run se-cli analyze your_file.csv --area SE_4 --json\n\n# With AI explanations\nuv run se-cli analyze your_file.csv --area SE_4 --json --ai-explainer\n\n# Inspect file format\nuv run se-cli inspect-production your_file.csv\n```\n\n### Run Tests\n\n```bash\nuv run pytest\n```\n\n### Code Formatting\n\n```bash\nuv run black .\nuv run isort .\n```\n\n## 🤝 Contributing\n\nContributions are welcome! This is an open source project for the solar community.\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📝 Environment Variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `OPENAI_API_KEY` | Optional | Enables AI-powered explanations |\n| `DATABASE_PATH` | Optional | Custom SQLite database path (default: `data/price_data.db`) |\n| `CORS_ORIGINS` | Optional | Allowed frontend origins for CORS (default: `http://localhost:3000`) |\n| `PORT` | Optional | Server port (default: `8080`, Railway sets this automatically) |\n| `NEXT_PUBLIC_API_URL` | Frontend | Backend API URL for Next.js frontend |\n\n**Note**: Electricity price data comes from Sourceful API which requires no API key!\n\n## 🐛 Troubleshooting\n\n### Port 8080 in use?\n```bash\n# Run on different port\nuv run python -c \"from app import app; app.run(host='0.0.0.0', port=5000)\"\n```\n\n### File upload fails?\n- Check file size (max 16MB)\n- Ensure valid CSV or Excel format\n- Try with sample files in `data/samples/`\n\n### Analysis seems wrong?\n- Verify your electricity area is correct\n- Check that your file has proper date/production columns\n- Use `se-cli inspect-production` to validate file format\n\n## 📚 Resources\n\n- **Sourceful Price API**: https://docs.sourceful.energy/developer/price-api\n- **Nordic Energy Markets**: https://www.nordpoolgroup.com/\n- **Swedish Energy Agency**: https://www.energimyndigheten.se/\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## 🙏 Acknowledgments\n\n- Price data powered by [Sourceful Energy API](https://sourceful.energy)\n- Built for the solar producer community in Sweden\n- Inspired by real challenges facing solar panel owners\n\n## 📮 Support\n\n- 🐛 **Bug reports**: [Open an issue](https://github.com/srcfl/negative-price-calc/issues)\n- 💡 **Feature requests**: [Start a discussion](https://github.com/srcfl/negative-price-calc/discussions)\n- 📖 **Questions**: Check [QUICKSTART.md](QUICKSTART.md) or open an issue\n\n---\n\n**Made with ❤️ for the solar energy community** | [GitHub](https://github.com/srcfl/negative-price-calc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrcfl%2Fnegative-price-calc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrcfl%2Fnegative-price-calc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrcfl%2Fnegative-price-calc/lists"}