Skip to content

Commit d1fcca6

Browse files
committed
feat: conan lock files, housekeeping
1 parent 5e1d192 commit d1fcca6

12 files changed

Lines changed: 100 additions & 54 deletions

File tree

.github/workflows/clean_build_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
set -e
4747
rm -rf build
4848
conan profile detect --force
49-
conan install . --build=missing -s build_type=Debug
49+
conan install . --lockfile=conan.lock --build=missing -s build_type=Debug
5050
5151
- name: Build
5252
run: |

.github/workflows/cron.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: Daily
33
on:
44
schedule:
55
- cron: '0 0 * * *' # Runs every day at midnight UTC
6-
7-
# workflow_dispatch: # Allows manual triggering
6+
workflow_dispatch: # Allows manual run from GitHub UI
87

98
jobs:
109
call-reusable:

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
release:
55
types: [published] # Triggers when a release is published
6-
workflow_dispatch: # Allows manual run from GitHub UI
6+
workflow_dispatch: # Allows manual run from GitHub UI
77

88
jobs:
99
build_release:
@@ -25,7 +25,7 @@ jobs:
2525
set -e
2626
rm -rf build
2727
conan profile detect --force
28-
conan install . --build=missing -s build_type=Release
28+
conan install . --lockfile=conan.lock --build=missing -s build_type=Release
2929
3030
- name: Build
3131
run: |

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"command": "bash",
88
"args": [
99
"-c",
10-
"source .venv/bin/activate && conan install . --build=missing -s build_type=Debug && cmake --preset=debug && cmake --build --preset=debug"
10+
"source .venv/bin/activate && conan install --lockfile=conan.lock . --build=missing -s build_type=Debug && cmake --preset=debug && cmake --build --preset=debug"
1111
],
1212
"group": {
1313
"kind": "build",

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,38 @@
55

66
FROM milss/tradercppbuild:v1.6 AS build_container
77

8+
LABEL org.opencontainers.image.title="tradercpp" \
9+
org.opencontainers.image.description="Container for running the trader.cpp app" \
10+
org.opencontainers.image.source="https://github.com/milsanore/trader.cpp" \
11+
maintainer="Milsanore <your@email>"
12+
813
WORKDIR /tradercpp
914

1015
COPY src/ ./src/
1116
COPY tests/ ./tests/
1217
COPY CMakeLists.txt .
1318
COPY CMakePresets.json .
1419
COPY conanfile.txt .
20+
COPY conan.lock .
1521
COPY Makefile .
16-
1722
RUN make init
1823
RUN make build-debug
1924
RUN make test
2025

26+
# ------------------------------------
2127

2228
COPY binance/fixconfig .
2329
COPY binance/spot-fix-md.xml .
2430
COPY binance/stunnel_prod.conf .
25-
# COPY binance/keys/prod-key-prv.pem .
31+
# COPY binance/keys/key.pem .
2632

2733
FROM alpine
2834
WORKDIR /tradercpp
2935

3036
COPY --from=build_container /tradercpp/fixconfig /tradercpp/binance/fixconfig
3137
COPY --from=build_container /tradercpp/spot-fix-md.xml /tradercpp/binance/spot-fix-md.xml
3238
COPY --from=build_container /tradercpp/stunnel_prod.conf /tradercpp/binance/stunnel_prod.conf
33-
# COPY --from=build_container /tradercpp/prod-key-prv.pem /tradercpp/binance/keys/prod-key-prv.pem
39+
# COPY --from=build_container /tradercpp/key.pem /tradercpp/binance/keys/key.pem
3440

3541
COPY --from=build_container /tradercpp/build/Debug/tradercpp /tradercpp/tradercpp
3642
ENTRYPOINT ["/tradercpp/tradercpp"]

Dockerfile_build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
# - coverage (lcov, gcovr)
1515
#############################################
1616

17-
1817
FROM ubuntu:24.04 AS build_container
1918

19+
LABEL org.opencontainers.image.title="tradercppbuild" \
20+
org.opencontainers.image.description="Container for building the trader.cpp app" \
21+
org.opencontainers.image.source="https://github.com/milsanore/trader.cpp" \
22+
maintainer="https://github.com/milsanore"
23+
2024
# Set noninteractive mode to avoid prompts during install
2125
ENV DEBIAN_FRONTEND=noninteractive
2226

Makefile

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: Makefile
1313
@echo " Choose a command to run:"
1414
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
1515

16-
## withenv: 😭 `make` executes every line as a new shell. this is a workaround => `make withenv RECIPE=init`
16+
## withenv: 😭 run `make` with envars from `.env`. like so `make withenv RECIPE=init`
1717
.PHONY: withenv
1818
withenv:
1919
test -e .env || cp .env.example .env
@@ -26,35 +26,26 @@ init:
2626
python3 -m venv .venv
2727
source .venv/bin/activate && \
2828
pip install gcovr conan && \
29-
conan install . --build=missing -s build_type=Debug
29+
conan install . --lockfile=conan.lock --build=missing -s build_type=Debug
3030
cmake --preset=debug
3131

32-
## build-container: 🚢 create the docker container for building the app (hosted on dockerhub and ghcr)
33-
.PHONY: build-container
34-
build-container:
35-
IMAGE_VERSION=
36-
@if [ -z "$(IMAGE_VERSION)" ]; then \
37-
echo "Error: IMAGE_VERSION is not set"; \
38-
echo "(you can set it on the command line like so: \`make build-container IMAGE_VERSION=1.6\`)"; \
39-
exit 1; \
40-
fi
41-
docker build -f Dockerfile_build -t milss/tradercppbuild:latest -t milss/tradercppbuild:v$(IMAGE_VERSION) .
42-
43-
## docker: 🚢 create an app docker image
44-
.PHONY: docker
45-
docker:
46-
docker build .
32+
## lock-conan: 📦 run after installing conan dependencies
33+
.PHONY: lock-conan
34+
lock-conan:
35+
conan lock create . --profile:host=default -s build_type=Debug --lockfile-out=conan.lock
36+
conan lock create . --profile:host=default -s build_type=Release --lockfile=conan.lock --lockfile-out=conan.lock
4737

4838
## build-debug: 🔨 compile (debug)
4939
.PHONY: build-debug
5040
build-debug:
41+
$(call pp,assuming `make init` has been called)
5142
cmake --build --preset=debug
5243

5344
## build-release: 🏎️ compile (prod)
5445
.PHONY: build-release
5546
build-release:
5647
source .venv/bin/activate && \
57-
conan install . --build=missing -s build_type=Release
48+
conan install . --lockfile=conan.lock --build=missing -s build_type=Release
5849
cmake --preset=release
5950
cmake --build --preset=release
6051

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
[![codecov](https://codecov.io/github/milsanore/trader.cpp/graph/badge.svg?token=C787ZTXBQC)](https://codecov.io/github/milsanore/trader.cpp)
44

55
<img src="docs/app.gif" alt="trader.cpp" width="800" />
6-
<br/>
7-
<br/>
86

97
# trader.cpp
108
Small trading UI connected to Binance over their FIX API.<br/>
119
A proof-of-concept, showcasing some modern c++ and some fintech concepts.
1210

1311
## Run Requirements
14-
- a Binance account, with an Ed25519 token that has FIX read permissions enabled
12+
- linux (tested with debian-trixie)
1513
- `stunnel` for TLS encryption (or a local proxy)
14+
- a Binance account, and an Ed25519 token with FIX read permissions enabled
15+
16+
## Run
17+
- start an SSL tunnel
18+
- e.g. run `stunnel stunnel_prod.conf` (from the binance folder)
19+
- configure:
20+
- copy `fixconfig` (from the binance folder)
21+
- copy `spot-fix-md.xml` (from the binance folder) and edit references in fixconfig
22+
- copy your binance private key pem and your public api key
23+
- copy `.env.example` to `.env`, edit values, and source the file
24+
- run:
25+
- download release
26+
- `chmod u+x tradercpp`
27+
- `./tradercpp`
1628

1729
## Build Requirements
1830
- C++20
@@ -78,6 +90,7 @@ NB: this app uses `make` as a recipe book, but it's not essential:
7890
- update balance for in-flight orders (reconcile asynchronously)
7991

8092
## Non-functional
93+
- ✅ package management (Conan 2 + lock file)
8194
- ✅ QuickFIX
8295
- ✅ basic cpp app to start with
8396
- ✅ makefile and build chain
@@ -121,17 +134,21 @@ NB: this app uses `make` as a recipe book, but it's not essential:
121134
- Valgrind
122135
- pipeline
123136
- ✅ custom docker build image with all dependencies (hosted on GHCR for faster pipelines)
137+
- ✅ reusable pipeline components + Release pipeline
138+
- https://github.com/googleapis/release-please
124139
- ✅ cron
125140
- ✅ comprehensive clang-tidy & clang-format checks
126141
- ✅ sonarcloud
127-
- ccache or precomiled headers
142+
- ✅ cached dependencies
143+
- containerised pipeline integration tests / dind
144+
- https://github.com/googleapis/release-please
128145
- local github action runner (`act`)
129-
- containerised integration tests / dind
146+
- ccache or precomiled headers
130147
- testing
148+
- ✅ coverage gutters
131149
- ✅ dependency injection
132150
- integration test with mocked Binance server
133151
- UI snapshot testing
134-
- ✅ coverage gutters
135152
- performance
136153
- ✅ store prices and sizes as integrals (ticks as `uint64_t`) for performance
137154
- release compile flags

conan.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "0.5",
3+
"requires": [
4+
"zlib/1.3.1#b8bc2603263cf7eccbd6e17e66b0ed76%1733936244.862",
5+
"spdlog/1.15.3#3ca0e9e6b83af4d0151e26541d140c86%1748617970.519",
6+
"quickfix/1.15.1#fe4ca02d3a021859ba9673f5d481f31d%1691409263.817",
7+
"openssl/3.5.2#0c5a5e15ae569f45dff57adcf1770cf7%1754407017.477",
8+
"ms-gsl/4.2.0#eb8e3068d01908f5c6fed255fc0d4098%1745345253.347",
9+
"libsodium/1.0.20#d2baa92ed999abe295ff63e2ee25b4f3%1743063880.072",
10+
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1722218217.276",
11+
"gtest/1.17.0#5224b3b3ff3b4ce1133cbdd27d53ee7d%1755784855.585",
12+
"ftxui/6.0.2#1b49d899f377591328fd17df1b3fd98e%1744735500.697",
13+
"fmt/11.2.0#579bb2cdf4a7607621beea4eb4651e0f%1746298708.362",
14+
"efsw/1.4.1#a4dc44b2fa9fa5a55081e365b1301d4c%1731488680.092",
15+
"concurrentqueue/1.0.4#1e48e1c712bcfd892087c9c622a51502%1687274728.048",
16+
"bzip2/1.0.8#00b4a4658791c1f06914e087f0e792f5%1744702067.178",
17+
"boost/1.88.0#6e3079d628a51513bfff72f3ee17668f%1759416413.7",
18+
"abseil/20250814.0#4e0fdd34a888b97aca482e648fc27a3b%1758546438.307"
19+
],
20+
"build_requires": [
21+
"cmake/4.1.1#23ee27eac0192593228fe8ced4680627%1756413041.241",
22+
"cmake/3.31.8#dde3bde00bb843687e55aea5afa0e220%1751628300.59",
23+
"b2/5.3.3#107c15377719889654eb9a162a673975%1750340310.079"
24+
],
25+
"python_requires": [],
26+
"config_requires": []
27+
}

src/README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
# NOTES
2-
- c++ namespace names map to the first level of subdirectories in src/
2+
- namespaces map to the first level of subdirectories in src/
33

44
# SUBFOLDERS
5-
- binance
6-
- FIX connectivity to the Binance exchange
7-
- core
8-
- core trading engine functionality
9-
- e.g. the order book
10-
- ui
11-
- a basic terminal ui written using the c++ `ftxui` library (similar to ncurses)
12-
13-
## UTILS
14-
- os-specific stuff
5+
6+
## binance
7+
- Classes that faciliate connectivity to the Binance crypto exchange using the FIX protocol and the c++ "QuickFIX" library
8+
- Pushes updates to two concurrent queues, that downstream consumers can use:
9+
1. order updates (prices/volumes)
10+
2. trade updates
11+
- NB: Binance uses a custom authentication mechanism
12+
13+
## core
14+
- core trading engine functionality
15+
- e.g. the order book
16+
- some coupling to the binance namespace (symbol, side, and multiplier values).
17+
- TODO(mils): move out.
18+
19+
## ui
20+
- a basic terminal ui written using the c++ `ftxui` library (similar to ncurses)
21+
- work done predominantly on background threads
22+
23+
## utils
24+
- helpers
25+
- non-portable (OS-specific) stuff

0 commit comments

Comments
 (0)