-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
200 lines (194 loc) · 5.47 KB
/
Copy pathdocker-compose.yml
File metadata and controls
200 lines (194 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
version: '3.9'
services:
# ================================================================
# PostgreSQL + TimescaleDB
# ================================================================
db:
image: timescale/timescaledb:latest-pg15
container_name: nq-bot-db
environment:
POSTGRES_USER: ${PG_USER:-nq_bot}
POSTGRES_PASSWORD: ${PG_PASSWORD:-nq_bot_password}
POSTGRES_DB: ${PG_DATABASE:-nq_trading}
POSTGRES_INITDB_ARGS: "-c shared_preload_libraries=timescaledb -c max_connections=200"
volumes:
- db_data:/var/lib/postgresql/data
- ./database/migrations:/docker-entrypoint-initdb.d:ro
ports:
- "5432:5432"
networks:
- nq_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${PG_USER:-nq_bot} -d ${PG_DATABASE:-nq_trading}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
labels:
- "com.example.description=NQ Trading Bot Database"
restart: unless-stopped
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# ================================================================
# NQ Trading Bot (Paper Mode) - Main Service
# ================================================================
bot:
build:
context: .
dockerfile: Dockerfile
container_name: nq-bot-trading
depends_on:
db:
condition: service_healthy
environment:
- BOT_MODE=${BOT_MODE:-paper}
- TRADOVATE_USERNAME=${TRADOVATE_USERNAME}
- TRADOVATE_PASSWORD=${TRADOVATE_PASSWORD}
- TRADOVATE_APP_ID=${TRADOVATE_APP_ID}
- TRADOVATE_CID=${TRADOVATE_CID}
- TRADOVATE_SECRET=${TRADOVATE_SECRET}
- TRADOVATE_DEVICE_ID=${TRADOVATE_DEVICE_ID:-nq-bot-docker}
- TRADOVATE_ENVIRONMENT=${TRADOVATE_ENVIRONMENT:-demo}
- PG_HOST=db
- PG_PORT=5432
- PG_DATABASE=${PG_DATABASE:-nq_trading}
- PG_USER=${PG_USER:-nq_bot}
- PG_PASSWORD=${PG_PASSWORD:-nq_bot_password}
- DISCORD_TOKEN=${DISCORD_TOKEN:-}
- DISCORD_CHANNEL_IDS=${DISCORD_CHANNEL_IDS:-}
- DASHBOARD_API_TOKEN=${DASHBOARD_API_TOKEN}
- PYTHONUNBUFFERED=1
- LOG_LEVEL=${LOG_LEVEL:-INFO}
env_file:
- .env
volumes:
- bot_logs:/app/logs
- bot_data:/app/data
- ./nq_bot_vscode:/app:cached
networks:
- nq_network
healthcheck:
test: ["CMD", "curl", "-f", "http://dashboard:8080/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
labels:
- "com.example.description=NQ Trading Bot - Paper Trading"
restart: on-failure:3
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
profiles:
- paper
# ================================================================
# Dashboard (FastAPI)
# ================================================================
dashboard:
build:
context: .
dockerfile: Dockerfile
container_name: nq-bot-dashboard
depends_on:
db:
condition: service_healthy
environment:
- BOT_MODE=dashboard
- PG_HOST=db
- PG_PORT=5432
- PG_DATABASE=${PG_DATABASE:-nq_trading}
- PG_USER=${PG_USER:-nq_bot}
- PG_PASSWORD=${PG_PASSWORD:-nq_bot_password}
- DASHBOARD_API_TOKEN=${DASHBOARD_API_TOKEN}
- PYTHONUNBUFFERED=1
- LOG_LEVEL=${LOG_LEVEL:-INFO}
env_file:
- .env
volumes:
- ./nq_bot_vscode:/app:cached
ports:
- "8080:8080"
networks:
- nq_network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/health"]
interval: 15s
timeout: 5s
retries: 3
start_period: 30s
labels:
- "com.example.description=NQ Trading Bot - Dashboard UI"
restart: unless-stopped
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
profiles:
- dashboard
# ================================================================
# Backtest Service (one-off container)
# ================================================================
backtest:
build:
context: .
dockerfile: Dockerfile
container_name: nq-bot-backtest
depends_on:
db:
condition: service_healthy
environment:
- BOT_MODE=backtest
- PG_HOST=db
- PG_PORT=5432
- PG_DATABASE=${PG_DATABASE:-nq_trading}
- PG_USER=${PG_USER:-nq_bot}
- PG_PASSWORD=${PG_PASSWORD:-nq_bot_password}
- PYTHONUNBUFFERED=1
- LOG_LEVEL=${LOG_LEVEL:-INFO}
env_file:
- .env
volumes:
- bot_data:/app/data:ro
- bot_results:/app/results
- ./nq_bot_vscode:/app:cached
networks:
- nq_network
labels:
- "com.example.description=NQ Trading Bot - Backtest (one-off)"
profiles:
- backtest
entrypoint: ["/app/entrypoint.sh"]
command: ["backtest"]
# ================================================================
# Networks
# ================================================================
networks:
nq_network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
# ================================================================
# Volumes (for persistence and data sharing)
# ================================================================
volumes:
db_data:
driver: local
bot_logs:
driver: local
bot_data:
driver: local
bot_results:
driver: local