question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling ccxt from HTML

See original GitHub issue

Can you please post an example of how to use ccxt in a browser context? I have this simple test html:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title>CCXT Test</title>

<script type="text/javascript" src="scripts/ccxt.js"></script>
</head>

<body>
<script type="text/javascript">
console.log (ccxt.exchanges)
</script>
</body> </html>

Of course the ccxt.exchanges call throws a reference exception. I tried to copy ccxt.js into my local directory but when looking at the source I see a bunch of require imports to /js/base/… which require node.js. I even tried to set up require.js on my server but wasn’t able to make this work.

Definitely open to ideas, thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:39 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
mmehrlecommented, Mar 23, 2021

Quick update - I copied my OS X binary over to CentOS and got it working. In the interim I upgraded my server to python 3.8 and was able to get tox installed there as well. I’m now able to run the build script on both platforms.

When loading my JS test page it shows only the needed exchanges:

(5) ["binance", "bittrex", "coinbase", "kraken", "kucoin"]
0: "binance"
1: "bittrex"
2: "coinbase"
3: "kraken"
4: "kucoin"
length: 5
__proto__: Array(0)

Then it retrieved the OHLCV data just fine. MUCH quicker load time as ccxt.browser.js now is 1.5Mb as opposed to 6.3MB. So definitely worth all the pain to get it working.

Thanks a ton for your help and I hope that my trials and tribulations made your install procedure more anti-fragile 😉

1reaction
mmehrlecommented, Mar 23, 2021

Okay a few pointers for your tutorial:

  1. pip install tox is missing - you already know that.

  2. echo is not reliable on bash across various platforms. Your call did not work for me on both OS X and CentOS. However what makes it work is the -e flag:

echo -e “binance\nkraken\nbittrex\ncoinbase\nkucoin” > exchanges.cfg

Tested it on both and it produces a carriage return.

  1. cp build/ccxt.browser.js path/to/your/html/project needs to be replaced with: cp ./dist/ccxt.browser.js /path/to/your/html/project

It’s not putting it into build but into dist - fortunately I caught that watching the install log.

So got it to work on OS X at least.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exchanges — ccxt 2.4.71 documentation
The ccxt library is a collection of available crypto exchanges or exchange classes. Each class implements the public and private API for a...
Read more >
How to use fetchBalance() parameters with ccxt - Stack Overflow
The params argument on fetchBalances() is for passing exchange specific data to the request. As each exchange offers different endpoints, ...
Read more >
ccxt/README.md - UNPKG
The **CCXT** library is used to connect and trade with cryptocurrency exchanges and payment processing services worldwide. It provides quick access to market ......
Read more >
ccxt-dev/ccxt - Gitter
import ccxt import cfscrape client = ccxt.coinegg({'apiKey': key, 'secret': secret, ... raceback (most recent call last): File ...
Read more >
ccxt Documentation - Read the Docs
14 CCXT – CryptoCurrency eXchange Trading Library ... https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found