Initial
This commit is contained in:
222
README.md
Normal file
222
README.md
Normal file
@ -0,0 +1,222 @@
|
||||
# Stock Tax Analyzer - Deployment Guide
|
||||
|
||||
A complete stock portfolio analyzer with tax-eligible holdings calculation, real-time prices, and stock split adjustments.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
stock-tax-analyzer/
|
||||
├── main.go # Go backend server
|
||||
├── go.mod # Go module file
|
||||
├── index.html # React frontend app
|
||||
├── Dockerfile # Multi-stage Docker build
|
||||
├── docker-compose.yml # Docker Compose configuration
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- 📊 Analyze Revolut trading statements
|
||||
- 💰 Real-time stock prices in EUR
|
||||
- 🏆 Tax-eligible holdings (stocks held >2 years)
|
||||
- 📈 Stock split adjustments (NVDA, TSLA, AAPL, GOOGL, AMZN)
|
||||
- 💵 Portfolio valuation with gain/loss calculations
|
||||
- 🔒 Runs entirely on your server - no data leaves your infrastructure
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Option 1: Using Docker Compose (Recommended)
|
||||
|
||||
1. Create a directory and copy all files:
|
||||
```bash
|
||||
mkdir stock-tax-analyzer
|
||||
cd stock-tax-analyzer
|
||||
# Copy: main.go, go.mod, index.html, Dockerfile, docker-compose.yml
|
||||
```
|
||||
|
||||
2. Build and run:
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
3. Access the application:
|
||||
```
|
||||
http://localhost:8080
|
||||
```
|
||||
|
||||
### Option 2: Using Docker
|
||||
|
||||
1. Build the image:
|
||||
```bash
|
||||
docker build -t stock-analyzer .
|
||||
```
|
||||
|
||||
2. Run the container:
|
||||
```bash
|
||||
docker run -d -p 8080:8080 --name stock-analyzer stock-analyzer
|
||||
```
|
||||
|
||||
3. Access the application:
|
||||
```
|
||||
http://localhost:8080
|
||||
```
|
||||
|
||||
### Option 3: Manual Build (without Docker)
|
||||
|
||||
1. Install Go 1.21 or higher
|
||||
|
||||
2. Build the Go backend:
|
||||
```bash
|
||||
go build -o stock-analyzer main.go
|
||||
```
|
||||
|
||||
3. Create static directory:
|
||||
```bash
|
||||
mkdir -p static
|
||||
cp index.html static/
|
||||
```
|
||||
|
||||
4. Run the server:
|
||||
```bash
|
||||
./stock-analyzer
|
||||
```
|
||||
|
||||
5. Access the application:
|
||||
```
|
||||
http://localhost:8080
|
||||
```
|
||||
|
||||
## How to Use
|
||||
|
||||
1. Open the application in your browser
|
||||
2. Click "Click to upload CSV file"
|
||||
3. Select your Revolut trading statement CSV file
|
||||
4. Wait for the analysis to complete
|
||||
5. Review your portfolio:
|
||||
- **Total Holdings**: All your stocks
|
||||
- **Tax-Eligible Holdings**: Stocks bought more than 2 years ago
|
||||
|
||||
## API Endpoint
|
||||
|
||||
### POST /api/stock-prices
|
||||
|
||||
Fetches current stock prices from Yahoo Finance.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"tickers": ["AAPL", "MSFT", "GOOGL"]
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"prices": {
|
||||
"AAPL": {
|
||||
"ticker": "AAPL",
|
||||
"usd": 150.25,
|
||||
"eur": 138.23,
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
"exchangeRate": 0.92
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `PORT`: Server port (default: 8080)
|
||||
- `TZ`: Timezone (default: Europe/Zagreb)
|
||||
|
||||
### Supported Stock Splits
|
||||
|
||||
The application includes historical stock split data for:
|
||||
- **NVDA**: 6 splits (including 10:1 in 2024)
|
||||
- **TSLA**: 2 splits (3:1 and 5:1)
|
||||
- **AAPL**: 5 splits (including 4:1 in 2020)
|
||||
- **GOOGL**: 1 split (20:1 in 2022)
|
||||
- **AMZN**: 4 splits (including 20:1 in 2022)
|
||||
|
||||
## Architecture
|
||||
|
||||
### Multi-stage Docker Build
|
||||
|
||||
1. **Stage 1 (static-builder)**: Prepares static HTML files
|
||||
2. **Stage 2 (go-builder)**: Compiles Go backend
|
||||
3. **Stage 3 (final)**: Clean Alpine image with binary and static files
|
||||
|
||||
Benefits:
|
||||
- Small final image size (~15MB)
|
||||
- No build tools in production image
|
||||
- Secure and efficient
|
||||
|
||||
### Backend (Go)
|
||||
|
||||
- HTTP server on port 8080
|
||||
- Fetches stock prices from Yahoo Finance
|
||||
- Handles CORS and rate limiting
|
||||
- Serves static frontend files
|
||||
|
||||
### Frontend (React)
|
||||
|
||||
- Pure client-side React app
|
||||
- No build step required
|
||||
- Processes CSV files in browser
|
||||
- Calls backend API for stock prices
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Stock prices showing as N/A
|
||||
|
||||
- Check if Yahoo Finance is accessible from your server
|
||||
- Verify network connectivity
|
||||
- Check Docker logs: `docker-compose logs -f`
|
||||
|
||||
### Port already in use
|
||||
|
||||
Change the port in docker-compose.yml:
|
||||
```yaml
|
||||
ports:
|
||||
- "9090:8080" # Use port 9090 instead
|
||||
```
|
||||
|
||||
### File upload not working
|
||||
|
||||
- Ensure the CSV file is a valid Revolut trading statement
|
||||
- Check browser console for errors
|
||||
- Verify file size is reasonable (<10MB)
|
||||
|
||||
## Security Notes
|
||||
|
||||
- Application runs entirely on your server
|
||||
- CSV files are processed in the browser (never sent to server)
|
||||
- Only stock tickers are sent to backend for price fetching
|
||||
- No data is stored or logged
|
||||
|
||||
## Development
|
||||
|
||||
### Running locally for development
|
||||
|
||||
```bash
|
||||
# Terminal 1: Run Go backend
|
||||
go run main.go
|
||||
|
||||
# Terminal 2: Serve static files (or just open index.html)
|
||||
python3 -m http.server 8000
|
||||
```
|
||||
|
||||
Then open http://localhost:8080 (backend serves both API and static files)
|
||||
|
||||
## License
|
||||
|
||||
MIT License - Feel free to modify and use as needed.
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions, check the application logs:
|
||||
```bash
|
||||
docker-compose logs -f stock-analyzer
|
||||
```
|
||||
Reference in New Issue
Block a user