work on postgress / will prob remove and work on ib exchanges and symbols
This commit is contained in:
parent
cce5126cb7
commit
a20a11c1aa
16 changed files with 1441 additions and 95 deletions
56
database/postgres/scripts/README.md
Normal file
56
database/postgres/scripts/README.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Database Scripts
|
||||
|
||||
**Simplified database initialization system for Interactive Brokers data.**
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# 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 metadata
|
||||
- `upsert_exchange()` - Function to insert/update exchanges
|
||||
|
||||
## Package.json Commands
|
||||
|
||||
```json
|
||||
{
|
||||
"db:init": "Run complete database initialization",
|
||||
"db:setup-ib": "Complete IB setup (schema + data)"
|
||||
}
|
||||
```
|
||||
|
||||
## Adding New Providers
|
||||
|
||||
1. Create `{provider}.sql` in `database/postgres/providers/`
|
||||
2. Create `{provider}.ts` script
|
||||
3. Add to `init.ts` and `package.json`
|
||||
|
||||
## Requirements
|
||||
|
||||
- PostgreSQL running
|
||||
- Database configured in `.env`
|
||||
- `ib-exchanges.json` file in `apps/data-service/src/setup/`
|
||||
Loading…
Add table
Add a link
Reference in a new issue