Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use subscription approach to retrieve market data instead of watch method inside a loop #67

Open
bludnic opened this issue Oct 22, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request exchanges

Comments

@bludnic
Copy link
Owner

bludnic commented Oct 22, 2024

This feature is not yet supported by CCXT.

Instead of:

while (true) {
  try {
    const ticker = await exchange.watchTicker("BTC/USDT");
  } catch (err) {
    // ...
  }
}

Use subscription:

const handleTicker = (ticker) => {
  // ...
}

exchange.onTicker("BTC/USDT", handleTicker)
exchange.offTicker("BTC/USDT", handleTicker)

Same approach for watchOrderbook and watchTrades.

Discussion:
ccxt/ccxt#15188
ccxt/ccxt#9248 (comment)

@bludnic bludnic added enhancement New feature or request exchanges labels Oct 22, 2024
@bludnic bludnic self-assigned this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exchanges
Projects
None yet
Development

No branches or pull requests

1 participant