forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic-rate-limiting.html
49 lines (36 loc) · 1.23 KB
/
basic-rate-limiting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE HTML>
<html>
<head>
<title>CCXT Basic example for the browser</title>
<script type="text/javascript" src="https://unpkg.com/ccxt"></script>
<script>
document.addEventListener ("DOMContentLoaded", async function () {
alert ('ccxt version ' + ccxt.version + ' supporting '+ ccxt.exchanges.length.toString () + ' exchanges');
const enableRateLimit = true
const exchange = new ccxt.poloniex ({ enableRateLimit })
const symbol = 'ETH/BTC'
while (true) {
let text = []
try {
const ticker = await exchange.fetchTicker (symbol)
text = [
exchange.id,
symbol,
JSON.stringify (exchange.omit (ticker, 'info'), undefined, '\t')
]
} catch (e) {
text = [
e.constructor.name,
e.message,
]
}
document.getElementById ('content').innerHTML = text.join (' ')
}
})
</script>
</head>
<body>
<h1>Hello, CCXT!</h1>
<pre id="content"></pre>
</body>
</html>