mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-10 16:58:08 +00:00
commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
- [Fetch Ohlcv](./examples/js/)
|
||||
|
||||
|
||||
```javascript
|
||||
import ccxt from '../../js/ccxt.js';
|
||||
// AUTO-TRANSPILE //
|
||||
async function example() {
|
||||
const myex = new ccxt.okx({});
|
||||
const fromTimestamp = myex.milliseconds() - 86400 * 1000; // last 24 hrs
|
||||
const ohlcv = await myex.fetchOHLCV('BTC/USDT', '1m', fromTimestamp, 3, { 'whatever': 123 });
|
||||
const length = ohlcv.length;
|
||||
if (length > 0) {
|
||||
const lastPrice = ohlcv[length - 1][4];
|
||||
console.log('Fetched ', length, ' candles for ', myex.id, ': last close ', lastPrice);
|
||||
}
|
||||
else {
|
||||
console.log('No candles have been fetched');
|
||||
}
|
||||
}
|
||||
await example();
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user