A self-hosted trading journal application for equity futures traders with playbook management, trade recording, and analytics.
- User Authentication: Simple username-based authentication (no passwords)
- Playbook Management: Create and manage trading playbooks with entry/exit criteria
- Trade Recording: Record trade entries and exits with screenshots and criteria tracking
- Dashboard: View summary statistics and recent trade activity
- Reports & Analytics: Analyze trading performance with metrics like win rate, P&L, and mean time in trade
- Screenshot Support: Paste screenshots directly from clipboard
- Self-Hosted: Runs locally with SQLite database
- Backend: Go 1.21+ with chi router
- Frontend: HTMX with Go html/template
- Database: SQLite with WAL mode
- Session Management: gorilla/sessions
- Go 1.21 or higher
- Make (optional, for using Makefile commands)
- Clone the repository:
cd trading-journal- Install dependencies:
go mod download- Run the application:
make run
# or
go run cmd/server/main.go- Open your browser and navigate to:
http://localhost:8080
- Login with any username (account will be created automatically)
- Build and run with Docker Compose:
make docker-build
make docker-run-
Access the application at
http://localhost:8080 -
Stop the containers:
make docker-stopThe application can be configured using environment variables:
PORT: Server port (default: 8080)DB_PATH: Path to SQLite database file (default: ./data/trading-journal.db)SESSION_SECRET: Secret key for session encryption (default: change-this-in-production)
- Navigate to Playbooks in the navigation menu
- Click Create Playbook
- Enter a playbook name
- Add entry criteria (conditions that must be met to enter a trade)
- Add exit criteria (conditions that must be met to exit a trade)
- Click Create Playbook
- Navigate to New Trade in the navigation menu
- Select a playbook
- Enter trade details:
- Product traded (e.g., ES, NQ, CL)
- Capital used
- Entry date and time
- Check which entry criteria were met
- Optional: Paste a screenshot (Cmd+Shift+4 on Mac, Win+Shift+S on Windows, then click Paste)
- Click Record Entry
- Navigate to Open Trades
- Click Close Trade for the trade you want to exit
- Enter exit details:
- Exit date and time
- Profit/Loss (use negative for losses)
- Check which exit criteria were met
- Optional: Paste exit screenshot
- Click Close Trade
- Navigate to Reports in the navigation menu
- Select a time period to filter trades
- View metrics:
- Total trades
- Total P&L
- Win rate
- Average P&L per trade
- Mean time in trade
- Winning/losing trades breakdown
The application uses SQLite, so backing up is simple:
- Stop the application
- Copy the database file:
cp data/trading-journal.db data/trading-journal-backup-$(date +%Y%m%d).dbFor Docker:
docker-compose down
cp data/trading-journal.db data/trading-journal-backup-$(date +%Y%m%d).db
docker-compose up -dtrading-journal/
├── cmd/server/ # Application entry point
│ └── main.go
├── internal/
│ ├── auth/ # Authentication & session management
│ ├── database/ # Database connection & migrations
│ ├── handlers/ # HTTP handlers
│ ├── models/ # Data models
│ ├── services/ # Business logic
│ └── templates/ # HTML templates
├── web/static/ # CSS, JavaScript
├── migrations/ # SQL migration files
├── data/ # SQLite database (created at runtime)
├── Dockerfile
├── docker-compose.yml
└── Makefile
The project includes complete VS Code configuration for a streamlined development experience:
Quick Start:
- Open the project in VS Code
- Install recommended extensions (when prompted)
- Press
Ctrl+Shift+Bto build - Press
F5to start debugging
Available Tasks (access via Ctrl+Shift+B or Terminal → Run Task):
- Run Trading Journal - Quick start with
go run - Build Trading Journal - Compile binary
- Build and Run - Build then execute
- Test Trading Journal - Run all tests
- Docker Build/Run/Stop - Docker workflow
- Clean Build Artifacts - Fresh start
- View Database - Inspect SQLite database
Debug Configurations:
- Launch Trading Journal (standard run)
- Debug Trading Journal (with breakpoints)
- Attach to Running Process
See .vscode/README.md for detailed documentation.
make test
# or
go test -v ./...
# or use VS Code task: "Test Trading Journal"make build
# or
go build -o bin/trading-journal cmd/server/main.go
# or use VS Code: Ctrl+Shift+BThe application follows a three-layer architecture:
- Handlers: HTTP request handling and response rendering
- Services: Business logic and database operations
- Database: Connection management and migrations
- Username-only authentication (no passwords) - suitable for single-user or trusted environments
- Session data stored in encrypted cookies (HttpOnly, SameSite)
- SQL injection prevention via parameterized queries
- XSS protection via Go's html/template auto-escaping
- User data isolation (all queries filtered by user_id)
- Screenshot size limit: 5MB per image
If you see "database is locked" errors:
- Ensure only one instance is running
- WAL mode is enabled by default for better concurrency
Change the port using the PORT environment variable:
PORT=3000 make run- Ensure you've copied a screenshot to clipboard
- On Mac: Cmd+Shift+4 (select area)
- On Windows: Win+Shift+S
- Click the "Paste Screenshot" button or press Ctrl+V
MIT License - Feel free to use this for personal or commercial projects.
Contributions are welcome! Please feel free to submit a Pull Request.
Potential future enhancements:
- Export reports to CSV/PDF
- Trade tags and notes
- Multiple screenshot support per trade
- Chart integration
- Trade journal (daily notes)
- Performance statistics by playbook
- Email notifications for open trades
For issues or questions, please open an issue on GitHub.