Skip to content

Support for CCXT#59

Open
gbeced wants to merge 31 commits into
developfrom
feature/ccxt
Open

Support for CCXT#59
gbeced wants to merge 31 commits into
developfrom
feature/ccxt

Conversation

@gbeced

@gbeced gbeced commented Jun 22, 2026

Copy link
Copy Markdown
Owner

No description provided.

@gbeced gbeced self-assigned this Jun 22, 2026
@gbeced
gbeced marked this pull request as ready for review July 6, 2026 12:53
@gbeced
gbeced requested a review from Copilot July 6, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new CCXT-based exchange integration (including websocket event sources) and extends Basana’s precision handling to support decimal places, significant digits, and tick-size-based precision, aligning precision behavior across backtesting and external exchanges.

Changes:

  • Introduces basana.external.ccxt with an Exchange wrapper plus websocket-backed bar/trade/order-book/order event sources.
  • Adds PrecisionMode and extends PairInfo + core helper utilities to support rounding/truncation via decimal places, significant digits, or tick size.
  • Updates backtesting/exchange and Binance integration to use the unified PairInfo precision helpers; adds tests/docs/samples for the new CCXT functionality.

Reviewed changes

Copilot reviewed 36 out of 37 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_pair.py Adds unit tests for PairInfo precision/rounding behavior across precision modes.
tests/test_core_helpers.py Adds tests for significant-digits precision and tick-size helpers (round/truncate + decimal-place derivation).
tests/test_ccxt_exchange.py Adds end-to-end tests for the CCXT exchange wrapper and websocket event sources.
tests/test_binance_exchange.py Updates Binance pair-info tests to assert tick-size precision mode and tick sizes.
tests/test_backtesting_exchange_orders.py Adds backtesting tests to ensure tick-size precision limits are enforced in order validation.
tests/fixtures/ccxt.py Adds CCXT fixtures/mocks to support CCXT integration tests.
tests/conftest.py Registers CCXT fixtures for the test suite.
samples/ccxt_websockets.py Adds a usage sample showing CCXT websocket subscriptions for bars/trades/order-book.
README.md Documents CCXT integration and the new optional extra (basana[ccxt]).
pyproject.toml Adds an optional dependency group for CCXT.
docs/quickstart.rst Updates install instructions to include the ccxt extra.
docs/index.rst Updates docs overview to mention CCXT exchange support.
docs/ccxt_trades.rst Adds API reference page for CCXT trades module/classes.
docs/ccxt_orders.rst Adds API reference page for CCXT orders module/classes.
docs/ccxt_order_book.rst Adds API reference page for CCXT order book module/classes.
docs/ccxt_exchange.rst Adds API reference page for CCXT exchange wrapper and DTOs.
docs/api.rst Adds CCXT modules to the API reference TOC.
CHANGELOG.md Notes CCXT integration as a new feature.
basana/external/ccxt/trades.py Implements trade DTO + trade websocket event source.
basana/external/ccxt/requests.py Adds CCXT order-request wrappers for market/limit/stop/stop-limit creation.
basana/external/ccxt/orders.py Implements order DTO + private orders websocket event source.
basana/external/ccxt/order_book.py Implements partial order book DTO + order book websocket event source.
basana/external/ccxt/helpers.py Adds CCXT helper conversions (symbols, decimals, pair-info mapping, etc.).
basana/external/ccxt/exchange.py Adds the CCXT Exchange wrapper (balances, orders, pair info, subscriptions, close).
basana/external/ccxt/bars.py Implements OHLCV websocket bar event source.
basana/external/ccxt/init.py Introduces the CCXT integration package.
basana/external/binance/exchange.py Updates Binance PairInfo construction to use tick sizes + PrecisionMode.TICK_SIZE.
basana/core/pair.py Extends PairInfo with PrecisionMode, tick sizes, and convenience round/truncate methods.
basana/core/helpers.py Adds precision-mode-aware rounding/truncation, significant-digits logic, and tick-size utilities.
basana/core/enums.py Adds PrecisionMode enum.
basana/backtesting/requests.py Uses PairInfo precision helpers in validation + improves precision error messages for tick size.
basana/backtesting/prices.py Uses PairInfo.truncate_quote() for bid/ask spread precision behavior.
basana/backtesting/orders.py Uses PairInfo precision helpers for fills and slippage price rounding.
basana/backtesting/order_mgr.py Uses PairInfo precision helpers for rounding balances/fees.
basana/backtesting/charts.py Uses PairInfo.truncate_quote() for chart fill-price calculations.
basana/init.py Exposes PrecisionMode at the package level.

Comment thread basana/external/ccxt/bars.py Outdated
Comment thread basana/core/helpers.py
Comment thread basana/core/pair.py
Comment thread basana/external/ccxt/exchange.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 37 changed files in this pull request and generated 3 comments.

Comment thread basana/core/helpers.py
Comment on lines +34 to +39
def get_quantizer(precision: int) -> Decimal:
ret = QUANTIZERS_CACHE.get(precision)
if ret is None:
ret = Decimal(f"1e-{precision}")
QUANTIZERS_CACHE[precision] = ret
return ret

@gbeced gbeced Jul 10, 2026

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this context precision is always >= 0. I added an assert. Check 228b257.

Comment thread basana/external/ccxt/exchange.py Outdated
Comment thread basana/external/ccxt/exchange.py Outdated
gbeced and others added 4 commits July 10, 2026 18:07
#59 (comment)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
#59 (comment)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@gbeced
gbeced requested a review from Copilot July 10, 2026 21:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 37 changed files in this pull request and generated 6 comments.

Comment thread pyproject.toml
Comment thread basana/external/ccxt/bars.py Outdated
Comment thread basana/external/ccxt/orders.py Outdated
Comment thread basana/external/ccxt/exchange.py Outdated
Comment thread basana/external/ccxt/exchange.py Outdated
Comment thread basana/external/ccxt/exchange.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 37 changed files in this pull request and generated 6 comments.

Comment thread basana/core/helpers.py
Comment thread tests/test_core_helpers.py
Comment thread basana/external/ccxt/trades.py Outdated
Comment thread basana/external/ccxt/orders.py Outdated
Comment thread basana/external/ccxt/order_book.py Outdated
Comment thread basana/external/ccxt/bars.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants