Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POSTGRES_USER=finwar
POSTGRES_PASSWORD=password
POSTGRES_DB=finwar
DATABASE_URL=postgresql://finwar:password@localhost:5432/finwar
RUST_LOG=info
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# FinWar

🤖⚡️🤖 A finbot arena server.

Based on the dataset from : [Huge Stock Market Dataset](https://www.kaggle.com/datasets/borismarjanovic/price-volume-data-for-all-us-stocks-etfs/data)
Expand All @@ -15,6 +16,7 @@ Based on the dataset from : [Huge Stock Market Dataset](https://www.kaggle.com/d
Start both database and Rust server:

```bash
cat .env.example > .env
docker-compose up --build
```

Expand All @@ -29,6 +31,7 @@ docker-compose up -d timescaledb
```

This will start a PostgreSQL + TimescaleDB instance on port 5432 with default credentials:

- **User**: finwar
- **Password**: password
- **Database**: finwar
Expand All @@ -44,4 +47,4 @@ docker-compose down
For detailed instructions on running each server locally:

- **Rust Server**: See [servers/rust-server/README.md](servers/rust-server/README.md)
- **Python Server**: See [servers/python-server/README.md](servers/python-server/README.md)
- **Python Server**: See [servers/python-server/README.md](servers/python-server/README.md)
29 changes: 27 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ services:
POSTGRES_DB: ${POSTGRES_DB:-finwar}
volumes:
- db_data:/var/lib/postgresql/data
- ./init:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD-SHELL", "pg_isready -U finwar"]
interval: 5s
timeout: 5s
retries: 5

migration:
image: rust:1.89-slim-bookworm
working_dir: /app/migration
volumes:
- ./servers/rust-server:/app
command: sh -c "apt-get update && apt-get install -y pkg-config libssl-dev && cargo run"
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-finwar}:${POSTGRES_PASSWORD:-password}@timescaledb:5432/${POSTGRES_DB:-finwar}
depends_on:
timescaledb:
condition: service_healthy

rust-server:
build:
context: ./servers/rust-server
Expand All @@ -30,8 +43,20 @@ services:
DATABASE_URL: postgresql://${POSTGRES_USER:-finwar}:${POSTGRES_PASSWORD:-password}@timescaledb:5432/${POSTGRES_DB:-finwar}
RUST_LOG: info
depends_on:
timescaledb:
condition: service_healthy
migration:
condition: service_completed_successfully

init-bots:
image: curlimages/curl:latest
depends_on:
- rust-server
command: >
sh -c "sleep 5 &&
curl -X POST http://rust-server:4444/api/enroll -H 'Content-Type: application/json' -d '{\"name\":\"TradeMaster\"}' &&
curl -X POST http://rust-server:4444/api/enroll -H 'Content-Type: application/json' -d '{\"name\":\"BullBot\"}' &&
curl -X POST http://rust-server:4444/api/enroll -H 'Content-Type: application/json' -d '{\"name\":\"BearBot\"}' &&
curl -X POST http://rust-server:4444/api/enroll -H 'Content-Type: application/json' -d '{\"name\":\"DiamondHands\"}' &&
curl -X POST http://rust-server:4444/api/enroll -H 'Content-Type: application/json' -d '{\"name\":\"PaperHands\"}'"

volumes:
db_data:
3,827 changes: 3,827 additions & 0 deletions init/stocks_history.init.sql

Large diffs are not rendered by default.

Loading