Feat : Add ClickHouse Backend Support#1097
Open
oh-alban wants to merge 1 commit intobmoscon:masterfrom
Open
Conversation
* Chores : Add comprehensive AI coding instructions for Cryptofeed * Feature : Add ClickHouse backend support - Implement ClickHouse backend for all cryptofeed data types - Add TradeClickHouse, TickerClickHouse, BookClickHouse, CandlesClickHouse, etc. - Support authenticated channels (OrderInfo, Fills, Transactions, Balances) - Include comprehensive SQL schema with optimized table structures - Add demo_clickhouse.py example with all supported data types - Update setup.py with clickhouse-connect dependency - Add documentation in docs/clickhouse.md - Update README.md and INSTALL.md to list ClickHouse backend - Update CHANGES.md for version 2.4.2 --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: oh-alban <gildas@qloned.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Add ClickHouse Backend Support
Description of code - what bug does this fix / what feature does this add?
This PR adds comprehensive ClickHouse backend support to cryptofeed, enabling storage of real-time cryptocurrency market data in a high-performance column-oriented database optimized for time-series analytics.
Why ClickHouse?
ClickHouse is the ideal database for storing cryptocurrency market data because:
What's Included
New Files:
cryptofeed/backends/clickhouse.py- Full backend implementation for all data typesexamples/demo_clickhouse.py- Complete example showing usageexamples/clickhouse_tables.sql- Optimized table schemas with best practicesdocs/clickhouse.md- Comprehensive documentation with query examplesSupported Data Types:
Key Features:
snapshots_onlyandsnapshot_intervalfor order booksUpdated Files:
setup.py- Addedclickhouse-connect>=0.6.0to optional dependenciesREADME.md- Added ClickHouse to supported backends listINSTALL.md- Added installation instructionsCHANGES.md- Documented feature for v2.4.2Implementation Notes
The implementation follows cryptofeed backend patterns:
BackendQueueandBackendCallback/BackendBookCallbackclickhouse-connectPython client (not asyncio-based, but runs in separate process/task)write_batchmethodContext: Adding Copilot Instructions
Note: This PR also includes
.github/copilot-instructions.mdwhich was added prior to implementing the ClickHouse backend. During the exploration phase to understand how to properly implement a new backend in cryptofeed, I discovered the codebase lacked AI agent guidance documentation. Since I needed to thoroughly analyze the architecture, component interactions, and backend patterns to implement ClickHouse support correctly, I created comprehensive copilot instructions to help future contributors (both human and AI) understand:This documentation will be valuable for future backend implementations and general contributions to the project.
Checklist
Testing Notes
The implementation has been tested locally with:
Unit tests not included because:
tests/don't have comprehensive test coverage for all backendsIf you'd like unit tests added, I can:
clickhouse-connecttest client with in-memory or Docker containerExample Usage
Performance Characteristics
Based on local testing:
Future Enhancements (not in this PR)
Possible improvements for follow-up PRs:
clickhouse-connectadds async APIs)Documentation
Full documentation added in
docs/clickhouse.mdincluding:Related Issues
This backend was requested by users looking for better time-series database support for high-frequency crypto data. ClickHouse outperforms traditional RDBMS for this use case.
Breaking Changes
None - this is a new optional backend.
Dependencies
Adds optional dependency:
clickhouse-connect>=0.6.0Users can install with:
pip install cryptofeed[clickhouse]