@jmparsons/ccxt
Version:
A JavaScript / Python / PHP cryptocurrency trading library with support for 100+ exchanges
47 lines (37 loc) • 1.36 kB
HTML
<html>
<head>
<title>CCXT Basic example for the browser</title>
<script type="text/javascript" src="https://unpkg.com/ccxt"></script>
<style type="text/css">
#contentA { background-color: #ccccff; }
#contentB { background-color: #ffcccc; }
</style>
<script>class MyExchange extends ccxt.gdax {
async fetchTicker (symbol, params = {}) {
alert ("I'm about to call the parent method from the overrided class, woohooo!")
// just call the parent method and that's it
return super.fetchTicker (symbol, params);
}
}
document.addEventListener ("DOMContentLoaded", function () {
const exchange = new MyExchange ()
const symbol = 'ETH/BTC'
const showFetchedTicker = function (ticker, elementId) {
const text = [
exchange.id,
symbol,
JSON.stringify (ticker, undefined, '\n\t')
]
document.getElementById (elementId).innerHTML = text.join (' ')
}
exchange.fetchTicker (symbol).then (ticker => showFetchedTicker (ticker, 'content'))
})
</script>
</head>
<body>
<h1>Hello, CCXT!</h1>
<pre id="content"></pre>
</body>
</html>