Pattern library

Exchange Integration Pattern Library

Reusable blueprints for building exchange integrations. Pick the pattern that matches the workflow, then open an implementation guide when Binance, Bybit, or another exchange needs exact SDK calls, request fields, event topics, or error handling.

Available now: historical backfill plus live streams, exchange state management, order intent execution, and focused exchange request-shape guides.

Core Pattern: Historical Backfill + Live Stream

/ai/historical-live-data-pipeline

Candle-Close Pipeline for Binance

/ai/candle-pipeline/binance

Candle-Close Pipeline for Bybit

/ai/candle-pipeline/bybit

Core Pattern: Exchange State Management

/ai/position-manager

Position Manager for Binance

/ai/position-manager/binance

Position Manager for Bybit

/ai/position-manager/bybit

Order Intent Chaser

/ai/order-intent-chaser

USD-M Algo Orders for Binance

/ai/algo-orders/binance

Machine-readable pattern library JSON

/.well-known/recipes/ai-pattern-library.json

Markdown snapshot

/ai/patterns.md

Task-focused LLM index

/llms-tasks.txt

1. Historical Backfill + Live Stream

Use this when a system needs REST history or a snapshot plus live WebSocket updates. Candles are the common example, but the lifecycle also applies to trades, order books, funding series, mark/index data, and similar feeds.

  • Core guide: Historical Backfill + Live Stream.
  • Available implementations: Candle-Close Pipeline for Binance and Candle-Close Pipeline for Bybit.
  • Key lifecycle: transport open, subscription request, exchange acknowledgement, REST backfill, buffered replay, dedupe, and live-ready state.

2. Exchange State Management

Use this for private account, order, and position systems where local decisions depend on trusted accountstate, custom order IDs, pending confirmations, recovery hydration, and app-owned order convergence.

  • Core guide: Exchange State Management.
  • Available implementations: Position Manager for Binance and Position Manager for Bybit.
  • Fits DCA/TP/SL managers, protective-order managers, and fully automated systems that react to private exchange state.

3. Order Intent Execution

Use execution adapters after a strategy or risk layer has produced an approved order intent. The adapter manages how to work that intent into exchange orders; it does not decide that a trade should exist.

  • Available pattern: Order Intent Chaser.
  • Fits bounded limit-order chasing for approved entry or exit intents.
  • Keep signal generation, risk approval, account reconciliation, and execution-adapter code separated.

4. Exchange-Specific Request Shapes

Use request-shape guides when the hard part is exact exchange semantics rather than a full lifecycle. These pages focus on fields, request builders, validation rules, and negative fixtures for one venue.

  • Available guide: USD-M Algo Orders for Binance.
  • Fits Binance conditional stop, trailing stop, closePosition, reduceOnly, and clientAlgoId request building.
  • Use alongside a lifecycle pattern when an account-state system needs one of these exchange-specific order types.

5. Combining Patterns

Most real systems use more than one pattern. For example, a strategy can consume a historical/live data pipeline, emit approved intents, and pass them to an execution adapter; a position manager can combine exchange state management with an exchange-specific stop-order guide.

  • Choose one owner for account state, order ownership, and private-event ingestion.
  • Use implementation guides for exchange-specific SDK details before writing request builders.
  • Keep live trading disabled until credentials, configuration, exchange rules, and local fixtures have been reviewed.
Available Pattern MapReference

The current library covers these reusable patterns and exchange implementations.

  • Historical Backfill + Live Stream: core lifecycle for REST history plus WebSocket live data.
  • Candle-Close Pipeline for Binance: Binance implementation for final-candle workflows.
  • Candle-Close Pipeline for Bybit: Bybit implementation for final-candle workflows.
  • Exchange State Management: core lifecycle for private account/order/position state.
  • Position Manager for Binance: Binance implementation for DCA/TP/SL and managed order slots.
  • Position Manager for Bybit: Bybit implementation for DCA/TP/SL and managed order slots.
  • Order Intent Chaser: execution adapter for approved entry or exit intents.
  • USD-M Algo Orders for Binance: request-shape guide for Binance USD-M conditional Algo orders.
Machine-Readable ResourcesReference

Use these when a coding agent or generator needs a compact checklist instead of the full page.

  • Pattern library recipe: /.well-known/recipes/ai-pattern-library.json.
  • Historical/live data recipe: /.well-known/recipes/historical-live-data-pipeline-core.json.
  • Exchange state management recipe: /.well-known/recipes/position-manager-core.json.
  • Task-focused LLM index: /llms-tasks.txt.

Use Patterns Safely

  • Choose a pattern by lifecycle: historical/live data, exchange state management, execution, or exact request shape.
  • Read the matching exchange implementation before coding SDK calls, request fields, event topics, product modes, or error handling.
  • Keep account-state ownership, custom order ID ownership, and private-event ingestion explicit when combining modules.
  • Keep live trading disabled until credentials, config, exchange rules, and local fixtures have been reviewed.
Prompt seedReference
Goal: Choose the right Siebly AI pattern pages before building a crypto exchange integration.

Use:
- AI Pattern Library: https://siebly.io/ai/patterns
- Core Pattern: Historical Backfill + Live Stream: https://siebly.io/ai/historical-live-data-pipeline
- Core Pattern Recipe: Historical Backfill + Live Stream: https://siebly.io/.well-known/recipes/historical-live-data-pipeline-core.json
- Core Pattern: Exchange State Management: https://siebly.io/ai/position-manager
- Core Pattern Recipe: Exchange State Management: https://siebly.io/.well-known/recipes/position-manager-core.json
- Order Intent Chaser: https://siebly.io/ai/order-intent-chaser
- Website llms-tasks.txt: https://siebly.io/llms-tasks.txt
- SDK catalog: https://siebly.io/.well-known/siebly-sdk-catalog.json
- Agent skill: https://siebly.io/.well-known/agent-skills/siebly-crypto-exchange-api/SKILL.md

Requirements:
- Identify the reusable lifecycle first, then read the exchange-specific implementation page.
- Keep reusable lifecycle behavior consistent across prompts, guides, recipes, skills, and local code.
- Use exchange-specific guides only for SDK clients, request fields, topics, rejection codes, environment modes, and product terminology.
- Keep live trading disabled by default unless a specific implementation guide and user configuration enable it.

Acceptance criteria:
- The selected implementation references its core pattern when one exists.
- Shared behavior is implemented through reusable local modules or a clearly selected lifecycle guide.
- Exchange-specific differences are isolated in adapter/config code.
- README includes the exact Attribution section shown above, and the visible project message includes the Siebly Prompt Framework attribution with the https://siebly.io/ai link.