Skip to content

Repository files navigation

Backend — Data + Wallet Foundation

This is Track A+B from the roadmap: real price/news ingestion, wallets, and trade execution, all backed by Redis and exposed over a small HTTP API.

Setup

# 1. Install Redis (if not already) and start it
#    macOS: brew install redis && redis-server
#    Ubuntu: sudo apt install redis-server && redis-server
#    Windows: use WSL or Docker (docker run -p 6379:6379 redis)

sudo service redis-server start

# 2. Install Python deps
pip install -r requirements.txt

# 3. (Optional but recommended) get a free Finnhub API key:
#    https://finnhub.io/register
#    then: export FINNHUB_API_KEY=your_key_here

# 4. Run all three processes (separate terminals):
python price_feed.py
python news_feed.py
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Once running, check it's alive: http://localhost:8000/prices should return live prices within ~15 seconds.

For your teammates

Send them REDIS_CONTRACT.md — it's the exact shape of every Redis key, pub/sub channel, and API endpoint they need to read/write. As long as they match that contract, their piece (dashboard or agents) will plug straight into this backend with zero changes on either side.

Wallet-to-wallet transfers

POST /transfer moves cash only between wallet:user and wallet:agent — no holdings change, and it is not a trade. It's implemented separately from /trade in wallet.py (execute_transfer, distinct from execute_trade), uses a Redis WATCH/MULTI/EXEC transaction so the debit and credit are atomic, and logs to its own capped wallet_transfer_log key rather than trade_log. The dashboard has a small "Transfer cash" control next to the user's wallet panel (User → Agent / Agent → User). See REDIS_CONTRACT.md for the exact request/response shape and GET /transfers for the log.

Moving to 3 laptops later

Only REDIS_HOST in config.py needs to change on each machine to point at whichever laptop is running Redis. No other code changes required.

About

Distributed multi-agent paper-trading system using real-time market data, news sentiment, and autonomous risk-aware trade execution.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages