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 @@
build/
+116
View File
@@ -0,0 +1,116 @@
{
"name": "fetch-tickers",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/node": {
"version": "10.14.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.18.tgz",
"integrity": "sha512-ryO3Q3++yZC/+b8j8BdKd/dn9JlzlHBPdm80656xwYUdmPkpTGTjkAdt6BByiNupGPE8w0FhBgvYy/fX9hRNGQ==",
"dev": true
},
"ansicolor": {
"version": "1.1.92",
"resolved": "https://registry.npmjs.org/ansicolor/-/ansicolor-1.1.92.tgz",
"integrity": "sha512-2jRpULfLpLvFeYYxIu1z6i0LQ4Khj/UxecsrdJ+837P0AVOW3smdKHpHmeKVYHZPG67o3jQFdMjNvPwktwPmZg=="
},
"as-table": {
"version": "1.0.55",
"resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz",
"integrity": "sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==",
"requires": {
"printable-characters": "^1.0.42"
}
},
"ccxt": {
"version": "1.18.1147",
"resolved": "https://registry.npmjs.org/ccxt/-/ccxt-1.18.1147.tgz",
"integrity": "sha512-3iflgpmBKgbskca3hwUDW/ewepKQ9rFEvxMV9s8NkWJFloO0ZAQzf3SfyxdRDGcJHcNNxSmbRFX/zRp3ucH0jw=="
},
"data-uri-to-buffer": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.1.tgz",
"integrity": "sha512-OkVVLrerfAKZlW2ZZ3Ve2y65jgiWqBKsTfUIAFbn8nVbPcCZg6l6gikKlEYv0kXcmzqGm6mFq/Jf2vriuEkv8A==",
"requires": {
"@types/node": "^8.0.7"
},
"dependencies": {
"@types/node": {
"version": "8.10.54",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.54.tgz",
"integrity": "sha512-kaYyLYf6ICn6/isAyD4K1MyWWd5Q3JgH6bnMN089LUx88+s4W8GvK9Q6JMBVu5vsFFp7pMdSxdKmlBXwH/VFRg=="
}
}
},
"get-source": {
"version": "1.0.40",
"resolved": "https://registry.npmjs.org/get-source/-/get-source-1.0.40.tgz",
"integrity": "sha512-grbzSLO9gCVpb+ngrUf2ch4nzcfAs9pYqlnu0v2+Ho0rOpwnJqhZsHWLXaqdNHMtmnY+OwGgS4SPdzMRXEwVtQ==",
"requires": {
"data-uri-to-buffer": "^2.0.0",
"source-map": "^0.6.1"
}
},
"ololog": {
"version": "1.1.146",
"resolved": "https://registry.npmjs.org/ololog/-/ololog-1.1.146.tgz",
"integrity": "sha512-C68zLVMFgIZC1Rdz7LTmtIEuAsth/2yllA/kb3OUfdWI9+U5x4F7EXO3xgfp9Rhn/tiETffo6DnWGPQaVHjKiw==",
"requires": {
"ansicolor": "^1.1.84",
"pipez": "^1.1.12",
"printable-characters": "^1.0.42",
"stacktracey": "^1.2.117",
"string.bullet": "^1.0.12",
"string.ify": "^1.0.57"
}
},
"pipez": {
"version": "1.1.12",
"resolved": "https://registry.npmjs.org/pipez/-/pipez-1.1.12.tgz",
"integrity": "sha1-s1nOVAHpNfEp+koJT83omvuENtg="
},
"printable-characters": {
"version": "1.0.42",
"resolved": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz",
"integrity": "sha1-Pxjpd6m9jrN/zE/1ZZ176Qhos9g="
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
},
"stacktracey": {
"version": "1.2.117",
"resolved": "https://registry.npmjs.org/stacktracey/-/stacktracey-1.2.117.tgz",
"integrity": "sha512-sj9olGCco8jxMw3fcmhL5er1yuVL2qSMhNfycwx+iIWz6uVpG+bQ2YNpVSlWscGmSskt61gSmUBjZ0Mb5jYBLw==",
"requires": {
"as-table": "^1.0.36",
"get-source": "^1.0.34"
}
},
"string.bullet": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/string.bullet/-/string.bullet-1.0.12.tgz",
"integrity": "sha1-tB/EF4UKV+QEK/PPNHtu7iV+4lM=",
"requires": {
"printable-characters": "^1.0.26"
}
},
"string.ify": {
"version": "1.0.61",
"resolved": "https://registry.npmjs.org/string.ify/-/string.ify-1.0.61.tgz",
"integrity": "sha512-ROVOYWN8B62bP1LUJIDK6/NooBrN8xIvpV8Ugssbw7Oa4YKJmiOeoEomhDLLRVpYHo0vOBCpEM8RFpxUk9KDIQ==",
"requires": {
"printable-characters": "^1.0.42",
"string.bullet": "^1.0.12"
}
},
"typescript": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==",
"dev": true
}
}
}
@@ -0,0 +1,34 @@
{
"name": "fetch-tickers",
"version": "0.1.0",
"description": "ccxt example code in typescript.",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"files": [
"build/src"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/ccxt/ccxt.git"
},
"keywords": [],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc -p .",
"start": "node ./build/index"
},
"dependencies": {
"ansicolor": "^1.1.92",
"as-table": "^1.0.55",
"ccxt": "^2.0.0",
"ololog": "^1.1.146"
},
"devDependencies": {
"typescript": "~3.5.0",
"@types/node": "^10.0.3"
},
"engines": {
"node": ">=7.6.0"
}
}
@@ -0,0 +1,4 @@
module.exports = {
singleQuote: true,
trailingComma: 'es5',
};
@@ -0,0 +1,21 @@
// 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: string) => {
const result = await Promise.all(exchanges.map(async (id: string): Promise<ccxt.Exchange> => {
const CCXT = ccxt as any; // Hack!
const exchange = new CCXT[id]({ 'enableRateLimit': true }) as ccxt.Exchange;
const ticker = await exchange.fetchTicker(symbol);
const exchangeExtended = exchange.extend({ 'exchange': id }, ticker) as ccxt.Exchange;
return exchangeExtended;
}));
log(result);
};
fetchTickers(symbol);
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"rootDir": "src",
"outDir": "build",
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"es2016"
],
"module": "commonjs",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"pretty": true,
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
],
"exclude": [
"node_modules"
]
}