File size: 5,348 Bytes
9e5fa5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4043cb
 
 
 
 
 
 
 
 
 
 
 
c04bdc8
e4043cb
 
 
 
9e5fa5b
 
 
 
 
 
 
 
 
 
 
 
 
 
e1128ec
abeb532
c04bdc8
8f253b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf84a36
 
8f253b3
 
 
de2b29d
8f253b3
 
 
b32ac07
 
8f253b3
 
9e5fa5b
 
 
8f253b3
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214

services:
  # Build-only base image
  fix-base:
    build:
      context: .
      dockerfile: Dockerfile.base
    image: fix-base
    # No need to run a container for base
    deploy:
      replicas: 0

  zookeeper:
    image: confluentinc/cp-zookeeper:7.5.0
    container_name: zookeeper
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    ports:
      - "2181:2181"

  kafka:
    image: confluentinc/cp-kafka:7.5.0
    container_name: kafka
    depends_on:
      - zookeeper
    ports:
      - "9092:9092"   # for containers & optionally host
      - "29092:29092" # for host access
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_HOST://0.0.0.0:29092
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

  matcher:
    build: ./matcher
    container_name: matcher
    depends_on:
      - kafka
    ports:
      - "6000:6000"
    volumes:
      - ./shared:/app/shared
      - matcher_data:/app/data  # SQLite database persistence

  frontend:
    build: ./frontend
    container_name: frontend
    depends_on:
      - matcher
      - kafka
    ports:
      - "5000:5000"
    volumes:
      - ./shared:/app/shared
    environment:
      - MATCHER_URL=http://matcher:6000

  consumer:
    build: ./consumer
    container_name: consumer
    depends_on:
      - kafka
    volumes:
      - ./shared:/app/shared

  md_feeder:
    build:
      context: ./md_feeder
      dockerfile: Dockerfile
    volumes:
      - ./shared:/app/shared

  oeg:
    build: ./oeg
    container_name: oeg
    environment:
      - FRONTEND_URL=http://frontend:5000
    command: ["python","oeg_simulator.py"]
    depends_on:
      - frontend
    networks:
      - default

  fix_oeg:
    build: ./fix_oeg
    container_name: fix_oeg
    depends_on:
      - kafka
    ports:
      - "5001:5001"
    volumes:
      - ./shared:/app/shared
    networks:
      - default

  snapshot_viewer:
    build: ./snapshot_viewer
    #dockerfile: snapshot_viewer/Dockerfile
    volumes:
      - ./logs:/app/logs   # logs will appear in ./logs folder on your host
      - ./shared:/app/shared
    depends_on:
      - kafka
      - md_feeder
    networks:
      - default
          
  fix-ui-client-1:
    build:
      context: ./fix-ui-client
    container_name: fix-ui-client-1
    ports:
      - "5002:5002"
    volumes:
      - ./fix-ui-client/client1.cfg:/app/client.cfg
      - ./fix-ui-client/log:/app/log
      - ./fix-ui-client/store:/app/store
      - ./shared:/app/shared
    environment:
      FIX_CFG: client.cfg
    depends_on:
      - fix_oeg

  fix-ui-client-2:
    build:
      context: ./fix-ui-client
    container_name: fix-ui-client-2
    ports:
      - "5003:5002"
    volumes:
      - ./fix-ui-client/client2.cfg:/app/client.cfg
      - ./fix-ui-client/log:/app/log
      - ./fix-ui-client/store:/app/store
      - ./shared:/app/shared
    environment:
      FIX_CFG: client.cfg
    depends_on:
      - fix_oeg

  ai_analyst:
    build: ./ai_analyst
    container_name: ai_analyst
    depends_on:
      - kafka
    volumes:
      - ./shared:/app/shared
    environment:
      - KAFKA_BOOTSTRAP=kafka:9092
      - OLLAMA_HOST=http://host.docker.internal:11434
      - OLLAMA_MODEL=llama3.1:8b
      - HF_TOKEN=${HF_TOKEN:-}
      - HF_MODEL=${HF_MODEL:-Qwen/Qwen2.5-7B-Instruct}
      - ANALYSIS_INTERVAL=1800
    extra_hosts:
      - "host.docker.internal:host-gateway"

  dashboard:
    build:
      context: ./dashboard
    container_name: dashboard
    ports:
      - "5005:5000"
    volumes:
      - ./dashboard:/app
      - ./shared:/app/shared
    depends_on:
      - kafka
      - matcher
    environment:
      - MATCHER_URL=http://matcher:6000
      - FRONTEND_URL=http://localhost:5000
      - HF_TOKEN=${HF_TOKEN:-}
      - HF_MODEL=${HF_MODEL:-Qwen/Qwen2.5-7B-Instruct}
      - CH_SERVICE_URL=http://clearing_house:5004

  clearing_house:
    build:
      context: .
      dockerfile: clearing_house/Dockerfile
    container_name: clearing_house
    ports:
      - "5004:5004"
    volumes:
      - ./shared:/app/shared
      - ch_data:/app/data                # clearing_house.db persistence
    depends_on:
      - kafka
      - matcher
    environment:
      - KAFKA_BOOTSTRAP=kafka:9092
      - MATCHER_URL=http://matcher:6000
      - SECURITIES_FILE=/app/shared/data/securities.txt
      - OHLCV_DIR=/app/shared/data/ohlcv
      - CH_DB_PATH=/app/data/clearing_house.db
      - CH_PORT=5004
      - HF_TOKEN=${HF_TOKEN:-}
      - HF_MODEL=${HF_MODEL:-RayMelius/stockex-ch-trader}
      - GROQ_API_KEY=${GROQ_API_KEY:-}
      - GROQ_MODEL=${GROQ_MODEL:-llama-3.1-8b-instant}
      - OLLAMA_HOST=${OLLAMA_HOST:-}
      - CH_RL_MODEL_REPO_NN1=${CH_RL_MODEL_REPO_NN1:-Adilbai/stock-trading-rl-agent}
      - CH_RL_MODEL_REPO_NN2=${CH_RL_MODEL_REPO_NN2:-RayMelius/stockex-nn-agent}
    extra_hosts:
      - "host.docker.internal:host-gateway"

volumes:
  matcher_data:  # Persists SQLite database across container restarts
  ch_data:       # Persists Clearing House SQLite DB and securities file