This commit is contained in:
discountry
2025-10-03 15:28:16 +08:00
parent d5c4b04746
commit fcb83bd16b
925 changed files with 165721 additions and 4 deletions
@@ -0,0 +1,19 @@
"use strict";
// Example code in typescript
// Based on /examples/js/fetch-from-many-exchanges-simultaneously.js
Object.defineProperty(exports, "__esModule", { value: true });
const ccxt = require("ccxt");
const log = require('ololog');
const symbol = 'BTC/USD';
const exchanges = ['coinbasepro', 'gemini', 'kraken'];
const fetchTickers = async (symbol) => {
const result = await Promise.all(exchanges.map(async (id) => {
const CCXT = ccxt; // Hack!
const exchange = new CCXT[id]({ 'enableRateLimit': true });
const ticker = await exchange.fetchTicker(symbol);
const exchangeExtended = exchange.extend({ 'exchange': id }, ticker);
return exchangeExtended;
}));
log(result);
};
fetchTickers(symbol);
@@ -0,0 +1,5 @@
"use strict";
module.exports = {
singleQuote: true,
trailingComma: 'es5',
};
@@ -0,0 +1,17 @@
// Example code in typescript
// Based on /examples/js/fetch-from-many-exchanges-simultaneously.js
import * as ccxt from 'ccxt';
const log = require('ololog');
const symbol = 'BTC/USD';
const exchanges = ['coinbasepro', 'gemini', 'kraken'];
const fetchTickers = async (symbol) => {
const result = await Promise.all(exchanges.map(async (id) => {
const CCXT = ccxt; // Hack!
const exchange = new CCXT[id]({ 'enableRateLimit': true });
const ticker = await exchange.fetchTicker(symbol);
const exchangeExtended = exchange.extend({ 'exchange': id }, ticker);
return exchangeExtended;
}));
log(result);
};
fetchTickers(symbol);