1.4 KiB
1.4 KiB
Database Scripts
Simplified database initialization system for Interactive Brokers data.
Quick Start
# Initialize everything (recommended)
bun run db:init
# Or run Interactive Brokers setup directly:
bun run db:setup-ib # Create schema and populate IB data
What We Built
✅ Simplified from complex multi-table schema to exchanges-only
✅ Single script setup - setup-ib.ts handles both schema and data
✅ Structured logging with @stock-bot/logger
✅ 184 exchanges populated from JSON data
✅ Proper error handling with helpful troubleshooting messages
Scripts
setup-ib.ts - Interactive Brokers Complete Setup
Main script for IB setup - Sets up schema and populates exchange data in one go.
init.ts
Main initialization script that orchestrates setup for all providers.
Database Schema
IB Data (ib_data schema)
exchanges- Trading exchanges with metadataupsert_exchange()- Function to insert/update exchanges
Package.json Commands
{
"db:init": "Run complete database initialization",
"db:setup-ib": "Complete IB setup (schema + data)"
}
Adding New Providers
- Create
{provider}.sqlindatabase/postgres/providers/ - Create
{provider}.tsscript - Add to
init.tsandpackage.json
Requirements
- PostgreSQL running
- Database configured in
.env ib-exchanges.jsonfile inapps/data-service/src/setup/