How e-geist/ddtp works
Project type and purpose
• This is a proof-of-concept Distributed Trading Platform (DDTP) implemented in Python.
• It consists of independently deployable components (market data provider, order execution engine, trading strategy) that communicate via Kafka.
• It integrates with the Kraken Derivatives API for both market data ingestion and order execution.
File structure
• Top-level “src/ddtp” contains five logical subpackages:
· api/kraken_derivatives – adapters for Kraken REST and WebSocket endpoints
· marketdata – local market-data logic and adapters
· order_execution – core order management and engine integration
· serialization – Kafka producer/consumer setup and message schema config
· strategy – trading logic that consumes market data and emits orders
• Entry-point modules at src/ddtp/ (marketdata_provider, order_execution_engine, buy_on_small_spread_strategy) correspond to three long-running services.
• docker/docker-compose.yml sets up a Kafka broker for inter‐service messaging.
• .env_template and config modules drive API credentials, Kafka URLs, and topic names.
README for additional insights
• Kafka is the backbone for component communication (market data → strategy → order execution).
• uv is used as the build/run system, Docker Compose for local Kafka.
• No persistent storage beyond Kafka—this is an in-memory streaming architecture.
1. Kraken Derivatives Exchange (external)
2. Market Data Provider Service
– Subcomponents: Kraken WebSocket client, MarketData Adapter, Kafka Producer
3. Trading Strategy Service
– Subcomponents: Kafka Consumer (“marketdata” topic), Strategy Logic, Kafka Producer (“orders” topic)
4. Order Execution Engine Service
– Subcomponents: Kafka Consumer (“orders” topic), Order Manager, Execution Engine Adapter, Kraken REST client
5. Kafka Cluster (broker)
– Topics: marketdata, orders
– Kraken → Market Data Provider (WebSocket)
– Market Data Provider → Kafka (produce marketdata)
– Kafka → Strategy Service (consume marketdata)
– Strategy Service → Kafka (produce orders)
– Kafka → Order Execution Service (consume orders)
– Order Execution Service → Kraken (REST)
c. Architectural patterns & design principles:
– Microservices with asynchronous messaging bus (Kafka)
– Adapter pattern for external API integration (in api/kraken_derivatives and order_execution/execution_engine_adapter.py)
– Single Responsibility: each service does one main job (ingest, decide, execute)
– Config-driven deployment via environment variables (.env + config.py)
d. Technologies & frameworks to annotate:
– Python 3.13
– uv build/run tool
– kafka-python (or confluent-kafka) under serialization/producer.py, consumer.py
– Docker Compose for Kafka test container
– WebSocket and REST libraries (in api/kraken_derivatives)