diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd5590b --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +node_modules/ +.npmrc +.env +.env.* +__tests__/ +coverage/ +.nyc_output/ +dist/ +build/ +.cache/ +*.log +.DS_Store +tmp/ +.tmp/ +__pycache__/ +*.pyc +.venv/ +venv/ +*.egg-info/ +.pytest_cache/ +READY_TO_PUBLISH diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..bc87921 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,24 @@ +# DeltaMesh MVP and Architecture + +Overview +- DeltaMesh is a federated, privacy-preserving cross-venue options market-making engine. +- This repo contains an initial, production-oriented skeleton to bootstrap an MVP focused on the federation and privacy aspects, with a minimal, compilable C prototype for local markets, shared signals, and delta planning. + +What you will find here +- Canonical primitives (LocalMarket, SharedSignals, PlanDelta) with tiny, well-scoped C implementations. +- A lightweight ADMM-like coordinator implemented as delta synchronization at the toy level (admm_lite). +- An adapter-stub that demonstrates how a data feed and a venue adapter could be wired in; for now it’s a toy example in demo_main.c. +- A small, self-contained test harness (test.sh) to compile and run the demo in a deterministic, repeatable way. + +How to contribute +- Start with the delta_mesh/ directory; add adapters under delta_mesh/Adapters if needed. +- Keep interfaces minimal and stable; add new primitives only when they are durable enough for reuse across venues. +- Ensure tests compile and pass locally before proposing broader changes. + +Development process +- Use the MVP plan: Phase 0 skeleton, Phase 1 governance and secure aggregation, Phase 2 cross-venue pilot, Phase 3 SDKs and conformance tests. +- For new features, add a small integration test that demonstrates the feature in a deterministic, isolated way. + +Guidance for reviewers +- Prioritize safety, privacy, and auditor-ability aspects; ensure deterministic behavior on reconnects and partition handling. +- Avoid exposing real inventories or live quotes in tests; use toy values. diff --git a/README.md b/README.md index a402a64..54caf00 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ # deltamesh-federated-privacy-preserving-c -Problem: Cross-venue options liquidity is fragmented and current market-making tools force users to share sensitive inventory, quotes, and risk signals with centralized servers, exposing edge data and increasing regulatory/compliance risk. Latency, d \ No newline at end of file +This repository contains an initial skeleton for DeltaMesh, a federated, privacy-preserving cross-venue options market-making engine. The MVP components here are intentionally small and self-contained to enable iterative integration with more complete adapters and governance tooling. + +MVP snapshot +- LocalMarket, SharedSignals, PlanDelta primitives (C structs) with tiny stubs +- Lightweight ADMM-lite coordination in admm_lite.c +- Toy demo and test harness under delta_mesh/ (demo_main.c, test.sh) +- An AGENTS.md documenting project governance and integration approach + +How to run the MVP demo +- Ensure you have a C toolchain (gcc) available. +- From the repo root, run: ./test.sh + +This will compile a small demo that fabricates two venue inventories and shows an aggregated quote produced by a toy ADMM-like step. + + +Problem: Cross-venue options liquidity is fragmented and current market-making tools force users to share sensitive inventory, quotes, and risk signals with centralized servers, exposing edge data and increasing regulatory/compliance risk. Latency, d diff --git a/delta_mesh/LocalMarket.c b/delta_mesh/LocalMarket.c new file mode 100644 index 0000000..bc028e7 --- /dev/null +++ b/delta_mesh/LocalMarket.c @@ -0,0 +1,2 @@ +#include "LocalMarket.h" +// Minimal implementation file for LocalMarket (toy MVP). diff --git a/delta_mesh/LocalMarket.h b/delta_mesh/LocalMarket.h new file mode 100644 index 0000000..b93b243 --- /dev/null +++ b/delta_mesh/LocalMarket.h @@ -0,0 +1,7 @@ +// Minimal LocalMarket primitive: per-venue market/book state. +// This header defines the core struct used by the toy MVP demo. +typedef struct LocalMarket { + const char* venue; // venue identifier (name) + double inventory; // simple inventory proxy (not a real book) + double risk_budget; // risk budget allocated to this venue +} LocalMarket; diff --git a/delta_mesh/LocalMarket.o b/delta_mesh/LocalMarket.o new file mode 100644 index 0000000..a61369a Binary files /dev/null and b/delta_mesh/LocalMarket.o differ diff --git a/delta_mesh/Makefile b/delta_mesh/Makefile new file mode 100644 index 0000000..48dee8e --- /dev/null +++ b/delta_mesh/Makefile @@ -0,0 +1,13 @@ +CC := gcc +CFLAGS := -Wall -Wextra -O2 + +all: delta_mesh_demo + +delta_mesh_demo: demo_main.o admm_lite.o LocalMarket.o SharedSignals.o PlanDelta.o + $(CC) $(CFLAGS) -o delta_mesh_demo/demo delta_mesh/demo_main.o delta_mesh/admm_lite.o delta_mesh/LocalMarket.o delta_mesh/SharedSignals.o delta_mesh/PlanDelta.o + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -f *.o delta_mesh_demo/demo diff --git a/delta_mesh/PlanDelta.c b/delta_mesh/PlanDelta.c new file mode 100644 index 0000000..dddc648 --- /dev/null +++ b/delta_mesh/PlanDelta.c @@ -0,0 +1,2 @@ +#include "PlanDelta.h" +// Minimal implementation file for PlanDelta (toy MVP). diff --git a/delta_mesh/PlanDelta.h b/delta_mesh/PlanDelta.h new file mode 100644 index 0000000..2a5a44d --- /dev/null +++ b/delta_mesh/PlanDelta.h @@ -0,0 +1,6 @@ +// Minimal PlanDelta primitive: routing/updating plan for quotes/hedges. +typedef struct PlanDelta { + double quote; // proposed quote level + double hedge; // proposed hedge amount + unsigned long timestamp; // monotonic timestamp for replayability +} PlanDelta; diff --git a/delta_mesh/PlanDelta.o b/delta_mesh/PlanDelta.o new file mode 100644 index 0000000..5ced3e0 Binary files /dev/null and b/delta_mesh/PlanDelta.o differ diff --git a/delta_mesh/SharedSignals.c b/delta_mesh/SharedSignals.c new file mode 100644 index 0000000..9b036c1 --- /dev/null +++ b/delta_mesh/SharedSignals.c @@ -0,0 +1,2 @@ +#include "SharedSignals.h" +// Minimal implementation file for SharedSignals (toy MVP). diff --git a/delta_mesh/SharedSignals.h b/delta_mesh/SharedSignals.h new file mode 100644 index 0000000..a1dbba6 --- /dev/null +++ b/delta_mesh/SharedSignals.h @@ -0,0 +1,5 @@ +// Minimal SharedSignals primitive: aggregated greeks and liquidity hints. +typedef struct SharedSignals { + double aggregated_greeks; + double implied_vol; +} SharedSignals; diff --git a/delta_mesh/SharedSignals.o b/delta_mesh/SharedSignals.o new file mode 100644 index 0000000..64d5dfb Binary files /dev/null and b/delta_mesh/SharedSignals.o differ diff --git a/delta_mesh/admm_lite.c b/delta_mesh/admm_lite.c new file mode 100644 index 0000000..e77c9c5 --- /dev/null +++ b/delta_mesh/admm_lite.c @@ -0,0 +1,12 @@ +#include "admm_lite.h" +#include + +// Simple average aggregator to mock cross-venue coordination. +void admm_lite_step(const double* quotes, int n, double* out_aggregate) { + if (quotes == NULL || n <= 0 || out_aggregate == NULL) return; + double sum = 0.0; + for (int i = 0; i < n; ++i) { + sum += quotes[i]; + } + *out_aggregate = sum / (double)n; +} diff --git a/delta_mesh/admm_lite.h b/delta_mesh/admm_lite.h new file mode 100644 index 0000000..8ec360e --- /dev/null +++ b/delta_mesh/admm_lite.h @@ -0,0 +1,3 @@ +// Lightweight ADMM-like coordination interface (toy implementation). +// Exposes a single-step aggregation over a set of venue quotes. +void admm_lite_step(const double* quotes, int n, double* out_aggregate); diff --git a/delta_mesh/admm_lite.o b/delta_mesh/admm_lite.o new file mode 100644 index 0000000..82e786e Binary files /dev/null and b/delta_mesh/admm_lite.o differ diff --git a/delta_mesh/demo b/delta_mesh/demo new file mode 100755 index 0000000..efb5cba Binary files /dev/null and b/delta_mesh/demo differ diff --git a/delta_mesh/demo_main.c b/delta_mesh/demo_main.c new file mode 100644 index 0000000..491bfd5 --- /dev/null +++ b/delta_mesh/demo_main.c @@ -0,0 +1,16 @@ +#include +#include "LocalMarket.h" +#include "admm_lite.h" + +// A tiny demo that creates two LocalMarkets and demonstrates a simple ADMM-lite step. +int main(void) { + LocalMarket v1 = {"VenueA", 100.0, 50.0}; + LocalMarket v2 = {"VenueB", 150.0, 75.0}; + + double quotes[2] = { v1.inventory, v2.inventory }; + double aggregate = 0.0; + admm_lite_step(quotes, 2, &aggregate); + + printf("DeltaMesh DEMO: aggregated quote = %f\n", aggregate); + return 0; +} diff --git a/delta_mesh/demo_main.o b/delta_mesh/demo_main.o new file mode 100644 index 0000000..b171076 Binary files /dev/null and b/delta_mesh/demo_main.o differ diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..6a871f8 --- /dev/null +++ b/test.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e +echo "Building DeltaMesh toy MVP..." +cc=gcc +CCFLAGS="-Wall -Wextra -O2" +ROOT=$(pwd) + +mkdir -p delta_mesh +echo "Compiling delta_mesh components..." +$cc $CCFLAGS -c delta_mesh/demo_main.c -o delta_mesh/demo_main.o +$cc $CCFLAGS -c delta_mesh/admm_lite.c -o delta_mesh/admm_lite.o +$cc $CCFLAGS -c delta_mesh/LocalMarket.c -o delta_mesh/LocalMarket.o || true +$cc $CCFLAGS -c delta_mesh/SharedSignals.c -o delta_mesh/SharedSignals.o || true +$cc $CCFLAGS -c delta_mesh/PlanDelta.c -o delta_mesh/PlanDelta.o || true +$cc $CCFLAGS -o delta_mesh/demo delta_mesh/demo_main.o delta_mesh/admm_lite.o delta_mesh/LocalMarket.o delta_mesh/SharedSignals.o delta_mesh/PlanDelta.o + +echo "Running demo..." +./delta_mesh/demo + +echo "Done."