Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
37e8280
Add upload script for crypto risk dashboard project
skymike Oct 31, 2025
b26451e
.
skymike Oct 31, 2025
eca2a10
v2
skymike Oct 31, 2025
0b2e69e
v3
skymike Oct 31, 2025
58b5bf0
Optimize Dockerfile with multi-stage build
skymike Oct 31, 2025
820e1f5
Enhance Docker Compose with health checks and cleanup
skymike Oct 31, 2025
956c238
Add Streamlit and Streamlit Echarts to requirements
skymike Oct 31, 2025
fcb5f30
Remove streamlit from requirements.txt
skymike Oct 31, 2025
e92daa4
Add Streamlit and Streamlit Echarts to requirements
skymike Oct 31, 2025
f0f96a9
Refactor app.py for improved readability and structure
skymike Oct 31, 2025
86536bf
Enhance sentiment fetching with CryptoPanic API
skymike Oct 31, 2025
730afc2
Enhance TimescaleDB schema with indexes and aggregates
skymike Oct 31, 2025
3dc81ab
v4
skymike Oct 31, 2025
44c6393
Add crypto data worker GitHub Actions workflow
skymike Oct 31, 2025
3045ecb
v
skymike Oct 31, 2025
279ff30
Remove Slack failure notification from workflow
skymike Oct 31, 2025
8c4d5e3
Remove Slack notification on failure
skymike Oct 31, 2025
efba0ff
Modify caching and dependency installation in workflow
skymike Oct 31, 2025
5a77d22
Refactor common module imports to services_common
skymike Oct 31, 2025
2dc0d53
Improve services_common import handling and logging
skymike Oct 31, 2025
ad2827d
Update imports to use services.common namespace
skymike Oct 31, 2025
981e4eb
Add debug prints and explicit services imports
skymike Oct 31, 2025
bdf720f
Improve import handling for services.common modules
skymike Oct 31, 2025
79f1d69
Merge branch 'main' of https://github.com/skymike/crypto-risk-dashboard
skymike Oct 31, 2025
80d7394
Remove merge conflict markers from requirements.txt
skymike Oct 31, 2025
70a1ee7
2
skymike Nov 1, 2025
20dbee5
Delete .github/workflows/crypto-worker.yml
skymike Nov 1, 2025
3081d79
Add crypto data worker workflow
skymike Nov 1, 2025
eba28b9
Refactor UI and sentiment adapter, fix merge artifacts
skymike Nov 1, 2025
f953f34
Clean up schema_timescale.sql by removing merge conflict markers
skymike Nov 2, 2025
bc29ec3
Update railway.json to switch builder to DOCKERFILE and specify docke…
skymike Nov 2, 2025
0115bd6
Merge branch 'main' of https://github.com/skymike/crypto-risk-dashboard
skymike Nov 2, 2025
d8681cb
Add UI enhancements and live market snapshot feature
skymike Nov 2, 2025
7f598d7
Add manual ingest endpoint and enhance database operations
skymike Nov 2, 2025
586c1cb
Update deployment guide and configuration for default trading pairs
skymike Nov 2, 2025
504a673
Enhance UI with new global market overview and Telegram alert options
skymike Nov 2, 2025
53fae88
Refactor configuration loading and enhance asset fetching logic
skymike Nov 2, 2025
9411b82
Update worker schedule to 15 minutes and introduce signal profile opt…
skymike Nov 2, 2025
843ea73
Update crypto-worker.yml
skymike Nov 2, 2025
6f24764
Enhance UI with live time display and improved market snapshot features
skymike Nov 3, 2025
036bd69
Merge branch 'main' of https://github.com/skymike/crypto-risk-dashboard
skymike Nov 3, 2025
0645ed8
Refactor scoring notes display in Hot Signals section
skymike Nov 3, 2025
73a5689
chore: snapshot current state before merging Open-Trader fork
skymike Nov 9, 2025
0e5d3e7
Merge Open-Trader fork (dev) into project, favoring Open-Trader
skymike Nov 9, 2025
fd7db60
Add Python 3.12 compiled cache files
skymike Nov 9, 2025
13e6ee4
Add Linux deployment instructions to README
skymike Nov 11, 2025
acaf6d8
full redesign and move to npm
skymike Nov 11, 2025
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
41 changes: 41 additions & 0 deletions .github/workflows/crypto-worker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Crypto Data Worker

on:
schedule:
- cron: '*/15 * * * *' # Every 15 minutes
workflow_dispatch:

jobs:
worker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Cache Python packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('services/worker/requirements.txt', 'services/api/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install -r services/worker/requirements.txt
pip install -r services/api/requirements.txt

- name: Run Data Worker
env:
# DATABASE_URL should be set from Railway PostgreSQL service
# Go to Railway dashboard → PostgreSQL → Variables → Copy DATABASE_URL
# Add it to GitHub Secrets as DATABASE_URL
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SYMBOLS: binance:BTC/USDT,binance:ETH/USDT,binance:SOL/USDT,binance:BNB/USDT,binance:XRP/USDT,binance:DOGE/USDT,binance:ADA/USDT,binance:AVAX/USDT,binance:TRX/USDT,binance:DOT/USDT,binance:LINK/USDT,binance:MATIC/USDT,binance:UNI/USDT,binance:APT/USDT,binance:ARB/USDT,binance:ATOM/USDT,binance:OP/USDT,binance:SEI/USDT,binance:NEAR/USDT,binance:INJ/USDT,bybit:BTC/USDT,bybit:ETH/USDT,bybit:SOL/USDT,bybit:XRP/USDT,bybit:DOGE/USDT,bybit:ADA/USDT,bybit:LINK/USDT,bybit:MATIC/USDT,bybit:NEAR/USDT,bybit:APT/USDT
SCHEDULE_MINUTES: 15
run: python services/worker/run_worker.py
37 changes: 37 additions & 0 deletions .github/workflows/node-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: OpenTraderX Build (pnpm, frozen lockfile)

on:
push:
branches:
- integrate-open-trader
- main
pull_request:
branches:
- '**'

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node 22
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.12.1

- name: Install (frozen lockfile)
run: pnpm install --frozen-lockfile

- name: Build
run: |
if [ -f package.json ]; then pnpm build; else echo "No package.json in repo root; skipping build"; fi
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
185 changes: 185 additions & 0 deletions RAILWAY_DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Railway Deployment Guide

This guide provides detailed instructions for deploying the Crypto Risk Dashboard to Railway.

## Prerequisites

- GitHub account with this repository
- Railway account (sign up at [railway.app](https://railway.app))
- Railway CLI (optional, for local testing)

## Architecture

- **Railway Services**: API, UI, and PostgreSQL database
- **GitHub Actions**: Worker service (runs every 15 minutes)

## Deployment Steps

### 1. Create Railway Project

1. Go to [railway.app](https://railway.app) and sign in with GitHub
2. Click "New Project"
3. Select "Empty Project" or "Deploy from GitHub repo"
4. Connect your GitHub repository

### 2. Create PostgreSQL Database

1. In your Railway project, click "+ New"
2. Select "Database" → "Add PostgreSQL"
3. Railway will automatically provision a PostgreSQL instance
4. Note the service name (e.g., "Postgres")

### 3. Deploy API Service

1. Click "+ New" → "GitHub Repo"
2. Select your repository
3. In the service settings:
- **Root Directory**: Set to `services/api`
- **Build Command**: Leave empty (uses Dockerfile)
- Railway will detect the Dockerfile automatically

4. **Add Environment Variables**:
- Go to "Variables" tab
- Click "New Variable"
- `DATABASE_URL`: Click "Reference Variable" → Select your PostgreSQL service → Select `DATABASE_URL`
- `SYMBOLS`: Default includes top 30 perp pairs (e.g., `binance:BTC/USDT,...,bybit:APT/USDT`). Override if you want a smaller slice.

5. **Generate Public URL**:
- Go to "Settings" → "Networking"
- Click "Generate Domain"
- Note your API URL (e.g., `https://crypto-risk-api-production.up.railway.app`)

### 4. Deploy UI Service

1. Click "+ New" → "GitHub Repo"
2. Select the same repository
3. In the service settings:
- **Root Directory**: Set to `services/ui`
- **Build Command**: Leave empty (uses Dockerfile)

4. **Add Environment Variables**:
- `API_CANDIDATES`: Your API URL from step 3 (e.g., `https://crypto-risk-api-production.up.railway.app,http://api:8000,http://localhost:8000`)
- `DATABASE_URL`: Reference from PostgreSQL service (same as API service)

5. **Generate Public URL**:
- Generate a domain for UI service
- Note your UI URL

### 5. Configure GitHub Actions Worker

The worker runs via GitHub Actions to keep costs low (GitHub Actions free tier).

1. **Get Database Connection String**:
- In Railway → Your PostgreSQL service → "Variables" tab
- Copy the `DATABASE_URL` value
- It should look like: `postgresql://user:password@host:port/dbname`

2. **Add GitHub Secret**:
- Go to your GitHub repository
- Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name: `DATABASE_URL`
- Value: Paste your Railway PostgreSQL `DATABASE_URL`
- Click "Add secret"

3. **Verify Workflow**:
- Go to Actions tab in GitHub
- The "Crypto Data Worker" workflow should run automatically every 15 minutes
- You can manually trigger it using "workflow_dispatch"

### 6. Verify Deployment

1. **Check API Health**:
- Visit your API URL: `https://your-api-url.railway.app/health`
- Should return: `{"ok": true}`

2. **Check UI**:
- Visit your UI URL
- Dashboard should load and show pair selection

3. **Check Worker**:
- Go to GitHub Actions
- Check recent runs are successful
- Wait a few minutes for initial data ingestion

## Environment Variables Reference

### API Service
- `DATABASE_URL`: PostgreSQL connection string (referenced from database service)
- `SYMBOLS`: Comma-separated trading pairs (default top 30, e.g., `binance:BTC/USDT,...,bybit:APT/USDT`)
- `PORT`: Automatically set by Railway (don't set manually)

### UI Service
- `API_CANDIDATES`: Comma-separated API URLs to try (include your Railway API URL)
- `DATABASE_URL`: PostgreSQL connection string (referenced from database service)
- `PORT`: Automatically set by Railway (don't set manually)

### Worker (GitHub Actions)
- `DATABASE_URL`: PostgreSQL connection string (from GitHub Secrets)
- `SYMBOLS`: Trading pairs (set in workflow file; defaults to top 30)
- `SCHEDULE_MINUTES`: Worker schedule interval (set in workflow file)
- `TELEGRAM_BOT_TOKEN`: *(optional)* Telegram bot token for alerting top signals
- `TELEGRAM_CHAT_ID`: *(optional)* Destination chat/channel ID for Telegram notifications
- `SIGNAL_PROFILE`: *(optional)* Default worker profile (`conservative`, `balanced`, or `aggressive`) controlling signal strictness

## Troubleshooting

### API not connecting to database
- Verify `DATABASE_URL` is correctly referenced from PostgreSQL service
- Check PostgreSQL service is running in Railway dashboard
- Ensure database has been initialized (first worker run will do this)

### UI can't find API
- Verify `API_CANDIDATES` includes your Railway API URL
- Check API service is running and health endpoint works
- Ensure API URL is publicly accessible (not internal Railway hostname)

### Worker not running
- Check GitHub Actions workflow is enabled
- Verify `DATABASE_URL` secret is set correctly
- Check workflow logs for errors
- Ensure repository has Actions enabled

### Service not building
- Check Dockerfile exists in service directory
- Verify Root Directory is set correctly (`services/api` or `services/ui`)
- Check build logs in Railway dashboard

## Railway CLI (Optional)

You can also deploy using Railway CLI:

```bash
# Install Railway CLI
npm i -g @railway/cli

# Login
railway login

# Link project
railway link

# Deploy
railway up
```

## Cost Considerations

- **Railway Free Tier**: $5 credit per month
- Perfect for testing and small deployments
- May need to upgrade for production traffic
- **GitHub Actions**: Free tier includes 2,000 minutes/month
- Worker runs every 15 minutes = ~2,880 runs/month
- Each run takes ~1-2 minutes = ~2,880–5,760 minutes/month
- May need to optimize or reduce frequency for free tier

## Updating Services

Railway auto-deploys on git push to your main branch. To update:

1. Make changes to your code
2. Commit and push to main branch
3. Railway will automatically rebuild and deploy

You can also manually trigger deployments from Railway dashboard.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ opentrader trade grid

Licensed under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) License. See the [LICENSE](LICENSE) file for more information.

# Linux Deployment

For a ready-to-use systemd unit and Nginx TLS proxy example (listening on port 9966), see `deploy/linux/README.md`.

# Disclaimer

This software is for educational purposes only. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS. Do not risk money that you are afraid to lose. There might be bugs in the code - this software DOES NOT come with ANY warranty.
7 changes: 7 additions & 0 deletions _codex_tmp/.npmrc.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lockfile=true
prefer-frozen-lockfile=true
shared-workspace-lockfile=true
strict-peer-dependencies=true
auto-install-peers=false
engine-strict=true

73 changes: 73 additions & 0 deletions _codex_tmp/deploy.bak/linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
OpenTraderX Linux Deployment (systemd + Nginx)

This guide sets up OpenTraderX as a Linux service and exposes it securely via Nginx with TLS. The app listens on port 9966 and is reachable on your home network.

Prerequisites
- Linux host with sudo
- Node.js 22.x on the host (required by OpenTrader). Recommended: nvm
- Nginx installed (for TLS/domain)

1) Install Node 22 and OpenTrader CLI
- Install nvm and Node 22:
- curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- source ~/.nvm/nvm.sh
- nvm install 22 && nvm use 22
- Install OpenTrader CLI globally (OpenTraderX uses the opentrader CLI):
- npm install -g opentrader

2) Create a dedicated user and working dir
- sudo useradd -r -m -d /opt/opentrader opentrader || true
- sudo mkdir -p /opt/opentrader
- sudo chown -R opentrader:opentrader /opt/opentrader

3) Initialize configs and admin password
- Copy samples from this repo and edit:
- sudo cp deploy/linux/config.sample.json5 /opt/opentrader/config.json5
- sudo cp deploy/linux/exchanges.sample.json5 /opt/opentrader/exchanges.json5
- sudo nano /opt/opentrader/config.json5
- sudo nano /opt/opentrader/exchanges.json5
- Set the admin password (runs as the opentrader user):
- sudo -u opentrader opentrader set-password <your_strong_password>

4) Install the systemd unit
- Copy the unit file:
- sudo cp deploy/linux/opentraderx.service /etc/systemd/system/opentraderx.service
- Reload and start:
- sudo systemctl daemon-reload
- sudo systemctl enable --now opentraderx
- Check status/logs:
- systemctl status opentraderx
- journalctl -u opentraderx -f

By default, the service listens on 0.0.0.0:9966 so it’s available on your LAN.

5) Nginx reverse proxy with TLS (optional, for domain)
- Replace example.com with your domain in deploy/linux/nginx/opentraderx.conf and copy it:
- sudo cp deploy/linux/nginx/opentraderx.conf /etc/nginx/sites-available/opentraderx.conf
- sudo ln -s /etc/nginx/sites-available/opentraderx.conf /etc/nginx/sites-enabled/opentraderx.conf
- Test and reload Nginx:
- sudo nginx -t && sudo systemctl reload nginx
- Obtain Let’s Encrypt certificates (certbot example):
- sudo apt-get update && sudo apt-get install -y certbot python3-certbot-nginx
- sudo certbot --nginx -d example.com -d www.example.com

Optional UI branding via Nginx
- The provided Nginx config includes a sub_filter that changes page title text from "OpenTrader" to "OpenTraderX" for HTML responses only.
- If you prefer to disable this, remove the sub_filter lines under the location / block.

6) Firewall
- For LAN access without Nginx, open 9966/tcp:
- sudo ufw allow 9966/tcp
- If using Nginx + TLS, allow 80,443:
- sudo ufw allow 80/tcp
- sudo ufw allow 443/tcp

Service management
- Start: sudo systemctl start opentraderx
- Stop: sudo systemctl stop opentraderx
- Restart: sudo systemctl restart opentraderx

Notes
- Configure exchanges in /opt/opentrader/exchanges.json5 (created from exchanges.sample.json5)
- Configure strategy in /opt/opentrader/config.json5 (created from config.sample.json5)
- To change port/host, edit ExecStart in the unit to pass --host and --port or run `opentrader up --host 0.0.0.0 --port 9966` manually.
22 changes: 22 additions & 0 deletions _codex_tmp/deploy.bak/linux/config.sample.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Example strategy configuration for OpenTraderX
// Copy to /opt/opentrader/config.json5 and adjust values
{
// Select one of: "grid", "dca", "rsi"
template: "grid",

// Strategy-specific settings
settings: {
// GRID strategy
highPrice: 70000, // upper price of the grid
lowPrice: 60000, // lower price of the grid
gridLevels: 20, // number of grid levels
quantityPerGrid: 0.0001 // quantity in base currency per grid
},

// Trading pair
pair: "BTC/USDT",

// Exchange account label defined in exchanges.json5
exchange: "DEFAULT"
}

Loading