ccxt 4.2.86 → 4.2.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +4 -5
- package/dist/ccxt.browser.js +748 -169
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/ascendex.js +11 -1
- package/dist/cjs/src/base/Exchange.js +26 -2
- package/dist/cjs/src/binance.js +24 -7
- package/dist/cjs/src/bingx.js +37 -1
- package/dist/cjs/src/bitfinex.js +3 -0
- package/dist/cjs/src/bitfinex2.js +16 -1
- package/dist/cjs/src/bitflyer.js +19 -0
- package/dist/cjs/src/bitget.js +32 -17
- package/dist/cjs/src/bitopro.js +3 -0
- package/dist/cjs/src/bitrue.js +13 -7
- package/dist/cjs/src/bitvavo.js +3 -0
- package/dist/cjs/src/btcmarkets.js +1 -1
- package/dist/cjs/src/btcturk.js +2 -1
- package/dist/cjs/src/coinex.js +182 -54
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/currencycom.js +1 -1
- package/dist/cjs/src/delta.js +3 -1
- package/dist/cjs/src/digifinex.js +4 -2
- package/dist/cjs/src/exmo.js +11 -12
- package/dist/cjs/src/gate.js +13 -10
- package/dist/cjs/src/hitbtc.js +26 -2
- package/dist/cjs/src/htx.js +2 -2
- package/dist/cjs/src/huobijp.js +1 -1
- package/dist/cjs/src/hyperliquid.js +249 -12
- package/dist/cjs/src/idex.js +1 -1
- package/dist/cjs/src/krakenfutures.js +4 -7
- package/dist/cjs/src/kucoin.js +7 -4
- package/dist/cjs/src/lbank.js +3 -0
- package/dist/cjs/src/mexc.js +1 -1
- package/dist/cjs/src/oceanex.js +1 -1
- package/dist/cjs/src/okx.js +24 -10
- package/dist/cjs/src/phemex.js +3 -1
- package/dist/cjs/src/pro/kucoin.js +11 -6
- package/dist/cjs/src/wazirx.js +1 -1
- package/dist/cjs/src/zonda.js +3 -0
- package/examples/js/benchmark.js +104 -0
- package/examples/js/cli.js +0 -2
- package/examples/ts/benchmark.ts +134 -0
- package/examples/ts/cli.ts +0 -2
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +3 -3
- package/js/src/ascendex.d.ts +5 -12
- package/js/src/ascendex.js +11 -1
- package/js/src/base/Exchange.d.ts +5 -4
- package/js/src/base/Exchange.js +26 -2
- package/js/src/base/types.d.ts +12 -1
- package/js/src/binance.d.ts +5 -12
- package/js/src/binance.js +24 -7
- package/js/src/bingx.d.ts +5 -2
- package/js/src/bingx.js +37 -1
- package/js/src/bitfinex.js +3 -0
- package/js/src/bitfinex2.d.ts +3 -17
- package/js/src/bitfinex2.js +16 -1
- package/js/src/bitflyer.d.ts +1 -0
- package/js/src/bitflyer.js +20 -1
- package/js/src/bitget.d.ts +5 -12
- package/js/src/bitget.js +32 -17
- package/js/src/bitopro.js +3 -0
- package/js/src/bitrue.d.ts +3 -17
- package/js/src/bitrue.js +13 -7
- package/js/src/bitvavo.js +3 -0
- package/js/src/btcmarkets.js +1 -1
- package/js/src/btcturk.js +2 -1
- package/js/src/coinex.d.ts +4 -11
- package/js/src/coinex.js +182 -54
- package/js/src/cryptocom.js +1 -1
- package/js/src/currencycom.js +1 -1
- package/js/src/delta.d.ts +5 -37
- package/js/src/delta.js +3 -1
- package/js/src/digifinex.d.ts +5 -13
- package/js/src/digifinex.js +4 -2
- package/js/src/exmo.d.ts +5 -37
- package/js/src/exmo.js +11 -12
- package/js/src/gate.d.ts +5 -33
- package/js/src/gate.js +13 -10
- package/js/src/hitbtc.d.ts +5 -12
- package/js/src/hitbtc.js +26 -2
- package/js/src/htx.js +2 -2
- package/js/src/huobijp.js +1 -1
- package/js/src/hyperliquid.d.ts +7 -4
- package/js/src/hyperliquid.js +249 -12
- package/js/src/idex.js +1 -1
- package/js/src/krakenfutures.js +4 -7
- package/js/src/kucoin.js +7 -4
- package/js/src/kucoinfutures.d.ts +2 -2
- package/js/src/lbank.js +3 -0
- package/js/src/mexc.d.ts +3 -3
- package/js/src/mexc.js +1 -1
- package/js/src/oceanex.js +1 -1
- package/js/src/okx.d.ts +5 -33
- package/js/src/okx.js +24 -10
- package/js/src/phemex.d.ts +3 -11
- package/js/src/phemex.js +3 -1
- package/js/src/pro/kucoin.js +11 -6
- package/js/src/wazirx.js +1 -1
- package/js/src/zonda.js +3 -0
- package/package.json +3 -2
- package/skip-tests.json +3 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import asTable from 'as-table';
|
|
3
|
+
import ccxt, { version } from '../../js/ccxt.js';
|
|
4
|
+
const stats = (times) => {
|
|
5
|
+
// calculate statistics
|
|
6
|
+
const sum = times.reduce((a, b) => a + b, 0);
|
|
7
|
+
const avg = Math.round(sum / times.length);
|
|
8
|
+
const min = Math.min(...times);
|
|
9
|
+
const max = Math.max(...times);
|
|
10
|
+
times.sort((a, b) => a - b);
|
|
11
|
+
const median = times.length % 2 === 0 ? (times[times.length / 2 - 1] + times[times.length / 2]) / 2 : times[Math.floor(times.length / 2)];
|
|
12
|
+
return { min, 'average': avg, max, median, 'iterations': times.length };
|
|
13
|
+
};
|
|
14
|
+
async function benchmark(exchangeId, method, args, verbose = false, minIterations = 10, argsv = '') {
|
|
15
|
+
const exchange = new ccxt.pro[exchangeId]({});
|
|
16
|
+
const languages = ['js', 'py', 'php', 'cs'];
|
|
17
|
+
const commands = languages.map((language) => ({
|
|
18
|
+
'language': language,
|
|
19
|
+
'method': method,
|
|
20
|
+
'command': `npm run cli.${language} ${exchangeId} ${method} ${args.join(' ')} -- ${argsv} --poll`,
|
|
21
|
+
}));
|
|
22
|
+
const wsMethod = method + 'Ws';
|
|
23
|
+
if (exchange.has[wsMethod]) {
|
|
24
|
+
const wsCommands = languages.map((language) => ({
|
|
25
|
+
'language': language,
|
|
26
|
+
'method': wsMethod,
|
|
27
|
+
'command': `npm run cli.${language} ${exchangeId} ${wsMethod} ${args.join(' ')} -- ${argsv} --poll`,
|
|
28
|
+
}));
|
|
29
|
+
commands.push(...wsCommands);
|
|
30
|
+
}
|
|
31
|
+
const regex = /iteration (\d+) passed in (\d+) ms/g;
|
|
32
|
+
async function runCommand(command) {
|
|
33
|
+
if (verbose) {
|
|
34
|
+
console.log(exchange.iso8601(new Date().getTime()), ' running command:', command);
|
|
35
|
+
}
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const [cmd, ...args] = command.split(' ');
|
|
38
|
+
const child = spawn(cmd, args);
|
|
39
|
+
const matches = [];
|
|
40
|
+
const language = command.slice(8, 15);
|
|
41
|
+
child.stdout.on('data', (data) => {
|
|
42
|
+
const message = data.toString();
|
|
43
|
+
matches.push(...Array.from(message.matchAll(regex)));
|
|
44
|
+
const match = matches[matches.length - 1];
|
|
45
|
+
if (match && match[1] && match[2]) {
|
|
46
|
+
const iteration = parseInt(match[1]);
|
|
47
|
+
const time = parseInt(match[2]);
|
|
48
|
+
if (iteration <= minIterations) {
|
|
49
|
+
if (verbose) {
|
|
50
|
+
console.log(exchange.iso8601(new Date().getTime()), `${language} iteration ${iteration} passed in ${time} ms`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const times = matches.map((m) => parseInt(m[2]));
|
|
55
|
+
child.kill();
|
|
56
|
+
if (verbose) {
|
|
57
|
+
console.log(exchange.iso8601(new Date().getTime()), `killed process - ${language} iteration ${iteration} passed in ${time} ms`);
|
|
58
|
+
}
|
|
59
|
+
resolve({ times });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
child.stderr.on('data', (data) => {
|
|
64
|
+
const message = data.toString();
|
|
65
|
+
console.error(exchange.iso8601(new Date().getTime()), `command ${command} failed. stderr: ${message}`);
|
|
66
|
+
const times = matches.map((m) => parseInt(m[2]));
|
|
67
|
+
resolve({ times });
|
|
68
|
+
});
|
|
69
|
+
child.on('close', (code) => {
|
|
70
|
+
const times = matches.map((m) => parseInt(m[2]));
|
|
71
|
+
resolve({ times });
|
|
72
|
+
console.log(exchange.iso8601(new Date().getTime()), `${language} child process exited with code ${code}`);
|
|
73
|
+
});
|
|
74
|
+
child.on('error', (err) => {
|
|
75
|
+
console.error(exchange.iso8601(new Date().getTime()), `command ${command} failed. error: ${err}`);
|
|
76
|
+
reject(err);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const benchmarks = [];
|
|
81
|
+
const results = await Promise.all(commands.map((c) => runCommand(c.command)));
|
|
82
|
+
for (let i = 0; i < results.length; i++) {
|
|
83
|
+
const result = results[i];
|
|
84
|
+
benchmarks.push({ 'language': commands[i].language, 'method': commands[i].method, ...stats(result.times) });
|
|
85
|
+
}
|
|
86
|
+
if (verbose) {
|
|
87
|
+
const rawResults = results.map((r, i) => ({ 'language': commands[i].language, 'method': commands[i].method, ...stats(r.times), 'times': r.times }));
|
|
88
|
+
console.log(rawResults);
|
|
89
|
+
}
|
|
90
|
+
console.log(asTable(benchmarks));
|
|
91
|
+
}
|
|
92
|
+
const [_, , exchangeId, methodName, ...params] = process.argv.filter((x) => !x.startsWith('--'));
|
|
93
|
+
const verbose = process.argv.includes('--verbose');
|
|
94
|
+
const minIterationsString = process.argv.find((x) => x.startsWith('--min-iterations='))?.slice(18);
|
|
95
|
+
const minIterations = minIterationsString ? parseInt(minIterationsString) : 10;
|
|
96
|
+
const argsv = process.argv.filter((x) => x.startsWith('--') && !x.startsWith('--min-iterations')).join(' ');
|
|
97
|
+
console.log((new Date()).toISOString());
|
|
98
|
+
console.log('Node.js:', process.version);
|
|
99
|
+
console.log('CCXT v' + version);
|
|
100
|
+
const start = new Date().getTime();
|
|
101
|
+
await benchmark(exchangeId, methodName, params, verbose, minIterations, argsv);
|
|
102
|
+
const end = new Date().getTime();
|
|
103
|
+
console.log((new Date().toISOString()), 'Total time:', end - start, 'ms');
|
|
104
|
+
process.exit(0);
|
package/examples/js/cli.js
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import asTable from 'as-table';
|
|
3
|
+
import ccxt, { version } from '../../js/ccxt.js';
|
|
4
|
+
|
|
5
|
+
interface Stats {
|
|
6
|
+
min: number;
|
|
7
|
+
average: number;
|
|
8
|
+
max: number;
|
|
9
|
+
median: number;
|
|
10
|
+
iterations: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Test {
|
|
14
|
+
language: string;
|
|
15
|
+
method: string;
|
|
16
|
+
command: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Benchmark extends Omit<Test, 'command'>, Stats { }
|
|
20
|
+
|
|
21
|
+
const stats = (times: number[]): Stats => {
|
|
22
|
+
// calculate statistics
|
|
23
|
+
const sum = times.reduce ((a, b) => a + b, 0);
|
|
24
|
+
const avg = Math.round (sum / times.length);
|
|
25
|
+
const min = Math.min (...times);
|
|
26
|
+
const max = Math.max (...times);
|
|
27
|
+
times.sort ((a, b) => a - b);
|
|
28
|
+
const median = times.length % 2 === 0 ? (times[times.length / 2 - 1] + times[times.length / 2]) / 2 : times[Math.floor (times.length / 2)];
|
|
29
|
+
return { min, 'average': avg, max, median, 'iterations': times.length };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
async function benchmark (exchangeId, method, args, verbose = false, minIterations = 10, argsv = '') {
|
|
33
|
+
const exchange = new ccxt.pro[exchangeId] ({});
|
|
34
|
+
const languages = [ 'js', 'py', 'php', 'cs' ];
|
|
35
|
+
const commands: Test[] = languages.map ((language) => ({
|
|
36
|
+
'language': language,
|
|
37
|
+
'method': method,
|
|
38
|
+
'command': `npm run cli.${language} ${exchangeId} ${method} ${args.join (' ')} -- ${argsv} --poll`,
|
|
39
|
+
}));
|
|
40
|
+
const wsMethod = method + 'Ws';
|
|
41
|
+
if (exchange.has[wsMethod]) {
|
|
42
|
+
const wsCommands: Test[] = languages.map ((language) => ({
|
|
43
|
+
'language': language,
|
|
44
|
+
'method': wsMethod,
|
|
45
|
+
'command': `npm run cli.${language} ${exchangeId} ${wsMethod} ${args.join (' ')} -- ${argsv} --poll`,
|
|
46
|
+
}));
|
|
47
|
+
commands.push (...wsCommands);
|
|
48
|
+
}
|
|
49
|
+
const regex = /iteration (\d+) passed in (\d+) ms/g;
|
|
50
|
+
|
|
51
|
+
async function runCommand (command: string) {
|
|
52
|
+
if (verbose) {
|
|
53
|
+
console.log (exchange.iso8601 (new Date ().getTime ()), ' running command:', command);
|
|
54
|
+
}
|
|
55
|
+
return new Promise<{ times: number[] }> ((resolve, reject) => {
|
|
56
|
+
const [ cmd, ...args ] = command.split (' ');
|
|
57
|
+
|
|
58
|
+
const child = spawn (cmd, args);
|
|
59
|
+
const matches = [];
|
|
60
|
+
const language = command.slice (8, 15);
|
|
61
|
+
child.stdout.on ('data', (data: Buffer) => {
|
|
62
|
+
const message = data.toString ();
|
|
63
|
+
matches.push (...Array.from (message.matchAll (regex)));
|
|
64
|
+
const match = matches[matches.length - 1];
|
|
65
|
+
|
|
66
|
+
if (match && match[1] && match[2]) {
|
|
67
|
+
const iteration = parseInt (match[1]);
|
|
68
|
+
const time = parseInt (match[2]);
|
|
69
|
+
|
|
70
|
+
if (iteration <= minIterations) {
|
|
71
|
+
if (verbose) {
|
|
72
|
+
console.log (exchange.iso8601 (new Date ().getTime ()), `${language} iteration ${iteration} passed in ${time} ms`);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
const times = matches.map ((m) => parseInt (m[2]));
|
|
76
|
+
child.kill ();
|
|
77
|
+
if (verbose) {
|
|
78
|
+
console.log (exchange.iso8601 (new Date ().getTime ()), `killed process - ${language} iteration ${iteration} passed in ${time} ms`);
|
|
79
|
+
}
|
|
80
|
+
resolve ({ times });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
child.stderr.on ('data', (data: Buffer) => {
|
|
86
|
+
const message = data.toString ();
|
|
87
|
+
console.error (exchange.iso8601 (new Date ().getTime ()), `command ${command} failed. stderr: ${message}`);
|
|
88
|
+
const times = matches.map ((m) => parseInt (m[2]));
|
|
89
|
+
resolve ({ times });
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
child.on ('close', (code: number) => {
|
|
93
|
+
const times = matches.map ((m) => parseInt (m[2]));
|
|
94
|
+
resolve ({ times });
|
|
95
|
+
console.log (exchange.iso8601 (new Date ().getTime ()), `${language} child process exited with code ${code}`);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
child.on ('error', (err) => {
|
|
99
|
+
console.error (exchange.iso8601 (new Date ().getTime ()), `command ${command} failed. error: ${err}`);
|
|
100
|
+
reject (err);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const benchmarks: Benchmark[] = [];
|
|
106
|
+
const results = await Promise.all (commands.map ((c) => runCommand (c.command)));
|
|
107
|
+
for (let i = 0; i < results.length; i++) {
|
|
108
|
+
const result = results[i];
|
|
109
|
+
benchmarks.push ({ 'language': commands[i].language, 'method': commands[i].method, ...stats (result.times) });
|
|
110
|
+
}
|
|
111
|
+
if (verbose) {
|
|
112
|
+
const rawResults = results.map ((r, i) => ({ 'language': commands[i].language, 'method': commands[i].method, ...stats (r.times), 'times': r.times }));
|
|
113
|
+
console.log (rawResults);
|
|
114
|
+
}
|
|
115
|
+
console.log (asTable (benchmarks));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const [ _, , exchangeId, methodName, ...params ] = process.argv.filter ((x) => !x.startsWith ('--'));
|
|
119
|
+
const verbose = process.argv.includes ('--verbose');
|
|
120
|
+
const minIterationsString = process.argv.find ((x) => x.startsWith ('--min-iterations='))?.slice (18);
|
|
121
|
+
const minIterations = minIterationsString ? parseInt (minIterationsString) : 10;
|
|
122
|
+
const argsv = process.argv.filter ((x) => x.startsWith ('--') && !x.startsWith ('--min-iterations')).join (' ');
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
console.log ((new Date ()).toISOString ());
|
|
126
|
+
console.log ('Node.js:', process.version);
|
|
127
|
+
console.log ('CCXT v' + version);
|
|
128
|
+
|
|
129
|
+
const start = new Date ().getTime ();
|
|
130
|
+
await benchmark (exchangeId, methodName, params, verbose, minIterations, argsv);
|
|
131
|
+
const end = new Date ().getTime ();
|
|
132
|
+
|
|
133
|
+
console.log ((new Date ().toISOString ()), 'Total time:', end - start, 'ms');
|
|
134
|
+
process.exit (0);
|
package/examples/ts/cli.ts
CHANGED
package/js/ccxt.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Precise } from './src/base/Precise.js';
|
|
|
3
3
|
import * as functions from './src/base/functions.js';
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain } from './src/base/types.js';
|
|
6
|
-
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout,
|
|
7
|
-
declare const version = "4.2.
|
|
6
|
+
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
|
|
7
|
+
declare const version = "4.2.87";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
|
@@ -519,5 +519,5 @@ declare const ccxt: {
|
|
|
519
519
|
zaif: typeof zaif;
|
|
520
520
|
zonda: typeof zonda;
|
|
521
521
|
} & typeof functions & typeof errors;
|
|
522
|
-
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout,
|
|
522
|
+
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseinternational, coinbasepro, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
523
523
|
export default ccxt;
|
package/js/ccxt.js
CHANGED
|
@@ -35,10 +35,10 @@ import { Exchange } from './src/base/Exchange.js';
|
|
|
35
35
|
import { Precise } from './src/base/Precise.js';
|
|
36
36
|
import * as functions from './src/base/functions.js';
|
|
37
37
|
import * as errors from './src/base/errors.js';
|
|
38
|
-
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout,
|
|
38
|
+
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.88';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -392,6 +392,6 @@ pro.exchanges = Object.keys(pro);
|
|
|
392
392
|
pro['Exchange'] = Exchange; // now the same for rest and ts
|
|
393
393
|
//-----------------------------------------------------------------------------
|
|
394
394
|
const ccxt = Object.assign({ version, Exchange, Precise, 'exchanges': Object.keys(exchanges), 'pro': pro }, exchanges, functions, errors);
|
|
395
|
-
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout,
|
|
395
|
+
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseinternational, coinbasepro, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
396
396
|
export default ccxt;
|
|
397
397
|
//-----------------------------------------------------------------------------
|
package/js/src/ascendex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/ascendex.js';
|
|
2
|
-
import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Num, Currency, Market, Leverage, Leverages, Account, MarginModes, MarginMode } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Num, Currency, Market, Leverage, Leverages, Account, MarginModes, MarginMode, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class ascendex
|
|
5
5
|
* @augments Exchange
|
|
@@ -70,17 +70,10 @@ export default class ascendex extends Exchange {
|
|
|
70
70
|
fundingDatetime: string;
|
|
71
71
|
};
|
|
72
72
|
fetchFundingRates(symbols?: Strings, params?: {}): Promise<any>;
|
|
73
|
-
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<
|
|
74
|
-
parseMarginModification(data: any, market?: Market):
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
amount: any;
|
|
78
|
-
code: string;
|
|
79
|
-
symbol: string;
|
|
80
|
-
status: string;
|
|
81
|
-
};
|
|
82
|
-
reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
83
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
73
|
+
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
|
|
74
|
+
parseMarginModification(data: any, market?: Market): MarginModification;
|
|
75
|
+
reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
76
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
84
77
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
85
78
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
|
|
86
79
|
fetchLeverageTiers(symbols?: Strings, params?: {}): Promise<{}>;
|
package/js/src/ascendex.js
CHANGED
|
@@ -2876,15 +2876,25 @@ export default class ascendex extends Exchange {
|
|
|
2876
2876
|
});
|
|
2877
2877
|
}
|
|
2878
2878
|
parseMarginModification(data, market = undefined) {
|
|
2879
|
+
//
|
|
2880
|
+
// addMargin/reduceMargin
|
|
2881
|
+
//
|
|
2882
|
+
// {
|
|
2883
|
+
// "code": 0
|
|
2884
|
+
// }
|
|
2885
|
+
//
|
|
2879
2886
|
const errorCode = this.safeString(data, 'code');
|
|
2880
2887
|
const status = (errorCode === '0') ? 'ok' : 'failed';
|
|
2881
2888
|
return {
|
|
2882
2889
|
'info': data,
|
|
2890
|
+
'symbol': market['symbol'],
|
|
2883
2891
|
'type': undefined,
|
|
2884
2892
|
'amount': undefined,
|
|
2893
|
+
'total': undefined,
|
|
2885
2894
|
'code': market['quote'],
|
|
2886
|
-
'symbol': market['symbol'],
|
|
2887
2895
|
'status': status,
|
|
2896
|
+
'timestamp': undefined,
|
|
2897
|
+
'datetime': undefined,
|
|
2888
2898
|
};
|
|
2889
2899
|
}
|
|
2890
2900
|
async reduceMargin(symbol, amount, params = {}) {
|
|
@@ -3,7 +3,7 @@ import { // eslint-disable-line object-curly-newline
|
|
|
3
3
|
ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotAvailable, RateLimitExceeded } from "./errors.js";
|
|
4
4
|
import WsClient from './ws/WsClient.js';
|
|
5
5
|
import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
|
|
6
|
-
import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings } from './types.js';
|
|
6
|
+
import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, MarginModification } from './types.js';
|
|
7
7
|
export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, BorrowRate, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings } from './types.js';
|
|
8
8
|
import { ArrayCache, ArrayCacheByTimestamp } from './ws/Cache.js';
|
|
9
9
|
import { OrderBook as Ob } from './ws/OrderBook.js';
|
|
@@ -678,7 +678,7 @@ export default class Exchange {
|
|
|
678
678
|
fetchCrossBorrowRates(params?: {}): Promise<{}>;
|
|
679
679
|
fetchIsolatedBorrowRates(params?: {}): Promise<{}>;
|
|
680
680
|
parseMarketLeverageTiers(info: any, market?: Market): object;
|
|
681
|
-
fetchLeverageTiers(symbols?: string[], params?: {}): Promise<Dictionary<LeverageTier>>;
|
|
681
|
+
fetchLeverageTiers(symbols?: string[], params?: {}): Promise<Dictionary<LeverageTier[]>>;
|
|
682
682
|
parsePosition(position: any, market?: Market): Position;
|
|
683
683
|
parseFundingRateHistory(info: any, market?: Market): FundingRateHistory;
|
|
684
684
|
parseBorrowInterest(info: any, market?: Market): BorrowInterest;
|
|
@@ -697,8 +697,8 @@ export default class Exchange {
|
|
|
697
697
|
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
698
698
|
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
699
699
|
setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<{}>;
|
|
700
|
-
addMargin(symbol: string, amount: number, params?: {}): Promise<
|
|
701
|
-
reduceMargin(symbol: string, amount: number, params?: {}): Promise<
|
|
700
|
+
addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
701
|
+
reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
702
702
|
setMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
|
|
703
703
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<{}>;
|
|
704
704
|
fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
|
|
@@ -943,6 +943,7 @@ export default class Exchange {
|
|
|
943
943
|
safeNumber(obj: object, key: IndexType, defaultNumber?: Num): Num;
|
|
944
944
|
safeNumberN(obj: object, arr: IndexType[], defaultNumber?: Num): Num;
|
|
945
945
|
parsePrecision(precision?: string): string;
|
|
946
|
+
integerPrecisionToAmount(precision: Str): string;
|
|
946
947
|
loadTimeDifference(params?: {}): Promise<any>;
|
|
947
948
|
implodeHostname(url: string): any;
|
|
948
949
|
fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -4707,6 +4707,30 @@ export default class Exchange {
|
|
|
4707
4707
|
}
|
|
4708
4708
|
return parsedPrecision + '1';
|
|
4709
4709
|
}
|
|
4710
|
+
integerPrecisionToAmount(precision) {
|
|
4711
|
+
/**
|
|
4712
|
+
* @ignore
|
|
4713
|
+
* @method
|
|
4714
|
+
* @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
|
|
4715
|
+
* @param {string} precision The number of digits to the right of the decimal
|
|
4716
|
+
* @returns {string} a string number equal to 1e-precision
|
|
4717
|
+
*/
|
|
4718
|
+
if (precision === undefined) {
|
|
4719
|
+
return undefined;
|
|
4720
|
+
}
|
|
4721
|
+
if (Precise.stringGe(precision, '0')) {
|
|
4722
|
+
return this.parsePrecision(precision);
|
|
4723
|
+
}
|
|
4724
|
+
else {
|
|
4725
|
+
const positivePrecisionString = Precise.stringAbs(precision);
|
|
4726
|
+
const positivePrecision = parseInt(positivePrecisionString);
|
|
4727
|
+
let parsedPrecision = '1';
|
|
4728
|
+
for (let i = 0; i < positivePrecision - 1; i++) {
|
|
4729
|
+
parsedPrecision = parsedPrecision + '0';
|
|
4730
|
+
}
|
|
4731
|
+
return parsedPrecision + '0';
|
|
4732
|
+
}
|
|
4733
|
+
}
|
|
4710
4734
|
async loadTimeDifference(params = {}) {
|
|
4711
4735
|
const serverTime = await this.fetchTime(params);
|
|
4712
4736
|
const after = this.milliseconds();
|
|
@@ -5187,8 +5211,8 @@ export default class Exchange {
|
|
|
5187
5211
|
const entry = responseKeys[i];
|
|
5188
5212
|
const dictionary = isArray ? entry : response[entry];
|
|
5189
5213
|
const currencyId = isArray ? this.safeString(dictionary, currencyIdKey) : entry;
|
|
5190
|
-
const currency = this.
|
|
5191
|
-
const code = this.safeString(currency, 'code'
|
|
5214
|
+
const currency = this.safeCurrency(currencyId);
|
|
5215
|
+
const code = this.safeString(currency, 'code');
|
|
5192
5216
|
if ((codes === undefined) || (this.inArray(code, codes))) {
|
|
5193
5217
|
depositWithdrawFees[code] = this.parseDepositWithdrawFee(dictionary, currency);
|
|
5194
5218
|
}
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -252,7 +252,7 @@ export interface Position {
|
|
|
252
252
|
liquidationPrice?: number;
|
|
253
253
|
marginMode?: Str;
|
|
254
254
|
hedged?: boolean;
|
|
255
|
-
|
|
255
|
+
maintenanceMargin?: number;
|
|
256
256
|
maintenanceMarginPercentage?: number;
|
|
257
257
|
initialMargin?: number;
|
|
258
258
|
initialMarginPercentage?: number;
|
|
@@ -432,6 +432,17 @@ export interface Leverage {
|
|
|
432
432
|
longLeverage: number;
|
|
433
433
|
shortLeverage: number;
|
|
434
434
|
}
|
|
435
|
+
export interface MarginModification {
|
|
436
|
+
'info': any;
|
|
437
|
+
'symbol': string;
|
|
438
|
+
'type': 'add' | 'reduce' | 'set' | undefined;
|
|
439
|
+
'amount': Num;
|
|
440
|
+
'total': Num;
|
|
441
|
+
'code': Str;
|
|
442
|
+
'status': Str;
|
|
443
|
+
'timestamp': Int;
|
|
444
|
+
'datetime': Str;
|
|
445
|
+
}
|
|
435
446
|
export interface Leverages extends Dictionary<Leverage> {
|
|
436
447
|
}
|
|
437
448
|
export interface LastPrices extends Dictionary<LastPrice> {
|
package/js/src/binance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/binance.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class binance
|
|
5
5
|
* @augments Exchange
|
|
@@ -196,7 +196,7 @@ export default class binance extends Exchange {
|
|
|
196
196
|
previousFundingTimestamp: any;
|
|
197
197
|
previousFundingDatetime: any;
|
|
198
198
|
};
|
|
199
|
-
parseAccountPositions(account: any): any[];
|
|
199
|
+
parseAccountPositions(account: any, filterClosed?: boolean): any[];
|
|
200
200
|
parseAccountPosition(position: any, market?: Market): {
|
|
201
201
|
info: any;
|
|
202
202
|
id: any;
|
|
@@ -306,16 +306,9 @@ export default class binance extends Exchange {
|
|
|
306
306
|
calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
|
|
307
307
|
request(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any, config?: {}): Promise<any>;
|
|
308
308
|
modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
|
|
309
|
-
parseMarginModification(data: any, market?: Market):
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
amount: number;
|
|
313
|
-
code: any;
|
|
314
|
-
symbol: string;
|
|
315
|
-
status: string;
|
|
316
|
-
};
|
|
317
|
-
reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
318
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
309
|
+
parseMarginModification(data: any, market?: Market): MarginModification;
|
|
310
|
+
reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
311
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
319
312
|
fetchCrossBorrowRate(code: string, params?: {}): Promise<{
|
|
320
313
|
currency: string;
|
|
321
314
|
rate: number;
|
package/js/src/binance.js
CHANGED
|
@@ -1863,7 +1863,7 @@ export default class binance extends Exchange {
|
|
|
1863
1863
|
'-4140': BadRequest,
|
|
1864
1864
|
'-4141': OperationRejected,
|
|
1865
1865
|
'-4144': BadSymbol,
|
|
1866
|
-
'-4164':
|
|
1866
|
+
'-4164': InvalidOrder,
|
|
1867
1867
|
'-4165': BadRequest,
|
|
1868
1868
|
'-4167': BadRequest,
|
|
1869
1869
|
'-4168': BadRequest,
|
|
@@ -9143,7 +9143,7 @@ export default class binance extends Exchange {
|
|
|
9143
9143
|
'previousFundingDatetime': undefined,
|
|
9144
9144
|
};
|
|
9145
9145
|
}
|
|
9146
|
-
parseAccountPositions(account) {
|
|
9146
|
+
parseAccountPositions(account, filterClosed = false) {
|
|
9147
9147
|
const positions = this.safeList(account, 'positions');
|
|
9148
9148
|
const assets = this.safeList(account, 'assets', []);
|
|
9149
9149
|
const balances = {};
|
|
@@ -9166,7 +9166,8 @@ export default class binance extends Exchange {
|
|
|
9166
9166
|
const code = market['linear'] ? market['quote'] : market['base'];
|
|
9167
9167
|
const maintenanceMargin = this.safeString(position, 'maintMargin');
|
|
9168
9168
|
// check for maintenance margin so empty positions are not returned
|
|
9169
|
-
|
|
9169
|
+
const isPositionOpen = (maintenanceMargin !== '0') && (maintenanceMargin !== '0.00000000');
|
|
9170
|
+
if (!filterClosed || isPositionOpen) {
|
|
9170
9171
|
// sometimes not all the codes are correctly returned...
|
|
9171
9172
|
if (code in balances) {
|
|
9172
9173
|
const parsed = this.parseAccountPosition(this.extend(position, {
|
|
@@ -10008,10 +10009,11 @@ export default class binance extends Exchange {
|
|
|
10008
10009
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
10009
10010
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
|
|
10010
10011
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
10011
|
-
* @param {string[]
|
|
10012
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
10012
10013
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10013
10014
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
|
|
10014
10015
|
* @param {string} [params.subType] "linear" or "inverse"
|
|
10016
|
+
* @param {boolean} [params.filterClosed] set to true if you would like to filter out closed positions, default is false
|
|
10015
10017
|
* @returns {object} data on account positions
|
|
10016
10018
|
*/
|
|
10017
10019
|
if (symbols !== undefined) {
|
|
@@ -10048,7 +10050,9 @@ export default class binance extends Exchange {
|
|
|
10048
10050
|
else {
|
|
10049
10051
|
throw new NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
|
|
10050
10052
|
}
|
|
10051
|
-
|
|
10053
|
+
let filterClosed = undefined;
|
|
10054
|
+
[filterClosed, params] = this.handleOptionAndParams(params, 'fetchAccountPositions', 'filterClosed', false);
|
|
10055
|
+
const result = this.parseAccountPositions(response, filterClosed);
|
|
10052
10056
|
symbols = this.marketSymbols(symbols);
|
|
10053
10057
|
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
10054
10058
|
}
|
|
@@ -11186,7 +11190,7 @@ export default class binance extends Exchange {
|
|
|
11186
11190
|
}
|
|
11187
11191
|
await this.loadMarkets();
|
|
11188
11192
|
const market = this.market(symbol);
|
|
11189
|
-
amount = this.
|
|
11193
|
+
amount = this.amountToPrecision(symbol, amount);
|
|
11190
11194
|
const request = {
|
|
11191
11195
|
'type': addOrReduce,
|
|
11192
11196
|
'symbol': market['id'],
|
|
@@ -11215,6 +11219,16 @@ export default class binance extends Exchange {
|
|
|
11215
11219
|
});
|
|
11216
11220
|
}
|
|
11217
11221
|
parseMarginModification(data, market = undefined) {
|
|
11222
|
+
//
|
|
11223
|
+
// add/reduce margin
|
|
11224
|
+
//
|
|
11225
|
+
// {
|
|
11226
|
+
// "code": 200,
|
|
11227
|
+
// "msg": "Successfully modify position margin.",
|
|
11228
|
+
// "amount": 0.001,
|
|
11229
|
+
// "type": 1
|
|
11230
|
+
// }
|
|
11231
|
+
//
|
|
11218
11232
|
const rawType = this.safeInteger(data, 'type');
|
|
11219
11233
|
const resultType = (rawType === 1) ? 'add' : 'reduce';
|
|
11220
11234
|
const resultAmount = this.safeNumber(data, 'amount');
|
|
@@ -11222,11 +11236,14 @@ export default class binance extends Exchange {
|
|
|
11222
11236
|
const status = (errorCode === '200') ? 'ok' : 'failed';
|
|
11223
11237
|
return {
|
|
11224
11238
|
'info': data,
|
|
11239
|
+
'symbol': market['symbol'],
|
|
11225
11240
|
'type': resultType,
|
|
11226
11241
|
'amount': resultAmount,
|
|
11242
|
+
'total': undefined,
|
|
11227
11243
|
'code': undefined,
|
|
11228
|
-
'symbol': market['symbol'],
|
|
11229
11244
|
'status': status,
|
|
11245
|
+
'timestamp': undefined,
|
|
11246
|
+
'datetime': undefined,
|
|
11230
11247
|
};
|
|
11231
11248
|
}
|
|
11232
11249
|
async reduceMargin(symbol, amount, params = {}) {
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bingx.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Dict, Leverage, MarginMode, Num } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Dict, Leverage, MarginMode, Num, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bingx
|
|
5
5
|
* @augments Exchange
|
|
@@ -109,7 +109,10 @@ export default class bingx extends Exchange {
|
|
|
109
109
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
110
110
|
parseTransactionStatus(status: string): string;
|
|
111
111
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
|
|
112
|
-
|
|
112
|
+
addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
113
|
+
reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
114
|
+
setMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
115
|
+
parseMarginModification(data: any, market?: Market): MarginModification;
|
|
113
116
|
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
114
117
|
parseLeverage(leverage: any, market?: any): Leverage;
|
|
115
118
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|