ccxt 4.2.23 → 4.2.25
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/README.md +3 -3
- package/dist/ccxt.browser.js +447 -12
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binanceus.js +108 -6
- package/dist/cjs/src/bingx.js +1 -1
- package/dist/cjs/src/bitfinex2.js +189 -1
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/bitopro.js +146 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binanceus.d.ts +52 -1
- package/js/src/binanceus.js +108 -6
- package/js/src/bingx.js +2 -2
- package/js/src/bitfinex2.d.ts +6 -3
- package/js/src/bitfinex2.js +189 -1
- package/js/src/gate.js +1 -1
- package/js/src/phemex.js +1 -1
- package/js/src/pro/bitopro.d.ts +4 -1
- package/js/src/pro/bitopro.js +147 -2
- package/package.json +1 -1
- package/skip-tests.json +1 -0
package/dist/cjs/ccxt.js
CHANGED
|
@@ -174,7 +174,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
174
174
|
|
|
175
175
|
//-----------------------------------------------------------------------------
|
|
176
176
|
// this is updated by vss.js when building
|
|
177
|
-
const version = '4.2.
|
|
177
|
+
const version = '4.2.25';
|
|
178
178
|
Exchange["default"].ccxtVersion = version;
|
|
179
179
|
const exchanges = {
|
|
180
180
|
'ace': ace,
|
|
@@ -10,6 +10,7 @@ class binanceus extends binance {
|
|
|
10
10
|
'id': 'binanceus',
|
|
11
11
|
'name': 'Binance US',
|
|
12
12
|
'countries': ['US'],
|
|
13
|
+
'hostname': 'binance.us',
|
|
13
14
|
'rateLimit': 50,
|
|
14
15
|
'certified': false,
|
|
15
16
|
'pro': true,
|
|
@@ -17,10 +18,11 @@ class binanceus extends binance {
|
|
|
17
18
|
'logo': 'https://user-images.githubusercontent.com/1294454/65177307-217b7c80-da5f-11e9-876e-0b748ba0a358.jpg',
|
|
18
19
|
'api': {
|
|
19
20
|
'web': 'https://www.binance.us',
|
|
20
|
-
'sapi': 'https://api.binance.us/sapi/v1',
|
|
21
|
-
'wapi': 'https://api.binance.us/wapi/v3',
|
|
22
21
|
'public': 'https://api.binance.us/api/v3',
|
|
23
22
|
'private': 'https://api.binance.us/api/v3',
|
|
23
|
+
'sapi': 'https://api.binance.us/sapi/v1',
|
|
24
|
+
'sapiV2': 'https://api.binance.us/sapi/v2',
|
|
25
|
+
'sapiV3': 'https://api.binance.us/sapi/v3',
|
|
24
26
|
},
|
|
25
27
|
'www': 'https://www.binance.us',
|
|
26
28
|
'referral': 'https://www.binance.us/?ref=35005074',
|
|
@@ -81,13 +83,13 @@ class binanceus extends binance {
|
|
|
81
83
|
'api': {
|
|
82
84
|
'public': {
|
|
83
85
|
'get': {
|
|
84
|
-
'exchangeInfo': 10,
|
|
85
86
|
'ping': 1,
|
|
86
87
|
'time': 1,
|
|
87
|
-
'
|
|
88
|
+
'exchangeInfo': 10,
|
|
88
89
|
'trades': 1,
|
|
89
|
-
'aggTrades': 1,
|
|
90
90
|
'historicalTrades': 5,
|
|
91
|
+
'aggTrades': 1,
|
|
92
|
+
'depth': { 'cost': 1, 'byLimit': [[100, 1], [500, 5], [1000, 10], [5000, 50]] },
|
|
91
93
|
'klines': 1,
|
|
92
94
|
'ticker/price': { 'cost': 1, 'noSymbol': 2 },
|
|
93
95
|
'avgPrice': 1,
|
|
@@ -98,7 +100,107 @@ class binanceus extends binance {
|
|
|
98
100
|
},
|
|
99
101
|
'private': {
|
|
100
102
|
'get': {
|
|
101
|
-
'
|
|
103
|
+
'account': 10,
|
|
104
|
+
'rateLimit/order': 20,
|
|
105
|
+
'order': 2,
|
|
106
|
+
'openOrders': { 'cost': 3, 'noSymbol': 40 },
|
|
107
|
+
'myTrades': 10,
|
|
108
|
+
'myPreventedMatches': 10,
|
|
109
|
+
'allOrders': 10,
|
|
110
|
+
'orderList': 2,
|
|
111
|
+
'allOrderList': 10,
|
|
112
|
+
'openOrderList': 3,
|
|
113
|
+
},
|
|
114
|
+
'post': {
|
|
115
|
+
'order': 1,
|
|
116
|
+
'order/test': 1,
|
|
117
|
+
'order/cancelReplace': 1,
|
|
118
|
+
'order/oco': 1,
|
|
119
|
+
},
|
|
120
|
+
'delete': {
|
|
121
|
+
'order': 1,
|
|
122
|
+
'openOrders': 1,
|
|
123
|
+
'orderList': 1,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
'sapi': {
|
|
127
|
+
'get': {
|
|
128
|
+
'system/status': 1,
|
|
129
|
+
'asset/assetDistributionHistory': 1,
|
|
130
|
+
'asset/query/trading-fee': 1,
|
|
131
|
+
'asset/query/trading-volume': 1,
|
|
132
|
+
'sub-account/spotSummary': 1,
|
|
133
|
+
'sub-account/status': 1,
|
|
134
|
+
'otc/coinPairs': 1,
|
|
135
|
+
'otc/orders/{orderId}': 1,
|
|
136
|
+
'otc/orders': 1,
|
|
137
|
+
'ocbs/orders': 1,
|
|
138
|
+
'capital/config/getall': 1,
|
|
139
|
+
'capital/withdraw/history': 1,
|
|
140
|
+
'fiatpayment/query/withdraw/history': 1,
|
|
141
|
+
'capital/deposit/address': 1,
|
|
142
|
+
'capital/deposit/hisrec': 1,
|
|
143
|
+
'fiatpayment/query/deposit/history': 1,
|
|
144
|
+
'capital/sub-account/deposit/address': 1,
|
|
145
|
+
'capital/sub-account/deposit/history': 1,
|
|
146
|
+
'asset/query/dust-logs': 1,
|
|
147
|
+
'asset/query/dust-assets': 1,
|
|
148
|
+
'marketing/referral/reward/history': 1,
|
|
149
|
+
'staking/asset': 1,
|
|
150
|
+
'staking/stakingBalance': 1,
|
|
151
|
+
'staking/history': 1,
|
|
152
|
+
'staking/stakingRewardsHistory': 1,
|
|
153
|
+
'custodian/balance': 1,
|
|
154
|
+
'custodian/supportedAssetList': 1,
|
|
155
|
+
'custodian/walletTransferHistory': 1,
|
|
156
|
+
'custodian/custodianTransferHistory': 1,
|
|
157
|
+
'custodian/openOrders': 1,
|
|
158
|
+
'custodian/order': 1,
|
|
159
|
+
'custodian/orderHistory': 1,
|
|
160
|
+
'custodian/tradeHistory': 1,
|
|
161
|
+
'custodian/settlementSetting': 1,
|
|
162
|
+
'custodian/settlementHistory': 1,
|
|
163
|
+
'cl/transferHistory': 1,
|
|
164
|
+
'apipartner/checkEligibility': 1,
|
|
165
|
+
'apipartner/rebateHistory': 1,
|
|
166
|
+
},
|
|
167
|
+
'post': {
|
|
168
|
+
'otc/quotes': 1,
|
|
169
|
+
'otc/orders': 1,
|
|
170
|
+
'fiatpayment/withdraw/apply': 1,
|
|
171
|
+
'capital/withdraw/apply': 1,
|
|
172
|
+
'asset/dust': 10,
|
|
173
|
+
'staking/stake': 1,
|
|
174
|
+
'staking/unstake': 1,
|
|
175
|
+
'custodian/walletTransfer': 1,
|
|
176
|
+
'custodian/custodianTransfer': 1,
|
|
177
|
+
'custodian/undoTransfer': 1,
|
|
178
|
+
'custodian/order': 1,
|
|
179
|
+
'custodian/ocoOrder': 1,
|
|
180
|
+
'cl/transfer': 1,
|
|
181
|
+
},
|
|
182
|
+
'delete': {
|
|
183
|
+
'custodian/cancelOrder': 1,
|
|
184
|
+
'custodian/cancelOrdersBySymbol': 1,
|
|
185
|
+
'custodian/cancelOcoOrder': 1,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
'sapiV2': {
|
|
189
|
+
'get': {
|
|
190
|
+
'cl/account': 10,
|
|
191
|
+
'cl/alertHistory': 1,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
'sapiV3': {
|
|
195
|
+
'get': {
|
|
196
|
+
'accountStatus': 1,
|
|
197
|
+
'apiTradingStatus': 1,
|
|
198
|
+
'sub-account/list': 1,
|
|
199
|
+
'sub-account/transfer/history': 1,
|
|
200
|
+
'sub-account/assets': 1,
|
|
201
|
+
},
|
|
202
|
+
'post': {
|
|
203
|
+
'sub-account/transfer': 1,
|
|
102
204
|
},
|
|
103
205
|
},
|
|
104
206
|
},
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -360,7 +360,7 @@ class bingx extends bingx$1 {
|
|
|
360
360
|
'100500': errors.ExchangeError,
|
|
361
361
|
'100503': errors.ExchangeError,
|
|
362
362
|
'80001': errors.BadRequest,
|
|
363
|
-
'80012': errors.
|
|
363
|
+
'80012': errors.InsufficientFunds,
|
|
364
364
|
'80014': errors.BadRequest,
|
|
365
365
|
'80016': errors.OrderNotFound,
|
|
366
366
|
'80017': errors.OrderNotFound,
|
|
@@ -50,11 +50,13 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
50
50
|
'fetchFundingRates': true,
|
|
51
51
|
'fetchIndexOHLCV': false,
|
|
52
52
|
'fetchLedger': true,
|
|
53
|
+
'fetchLiquidations': true,
|
|
53
54
|
'fetchMarginMode': false,
|
|
54
55
|
'fetchMarkOHLCV': false,
|
|
55
56
|
'fetchMyTrades': true,
|
|
56
57
|
'fetchOHLCV': true,
|
|
57
58
|
'fetchOpenInterest': true,
|
|
59
|
+
'fetchOpenInterestHistory': true,
|
|
58
60
|
'fetchOpenOrder': true,
|
|
59
61
|
'fetchOpenOrders': true,
|
|
60
62
|
'fetchOrder': true,
|
|
@@ -3034,7 +3036,73 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
3034
3036
|
//
|
|
3035
3037
|
return this.parseOpenInterest(response[0], market);
|
|
3036
3038
|
}
|
|
3039
|
+
async fetchOpenInterestHistory(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
3040
|
+
/**
|
|
3041
|
+
* @method
|
|
3042
|
+
* @name bitfinex2#fetchOpenInterestHistory
|
|
3043
|
+
* @description retrieves the open interest history of a currency
|
|
3044
|
+
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
|
|
3045
|
+
* @param {string} symbol unified CCXT market symbol
|
|
3046
|
+
* @param {string} timeframe the time period of each row of data, not used by bitfinex2
|
|
3047
|
+
* @param {int} [since] the time in ms of the earliest record to retrieve as a unix timestamp
|
|
3048
|
+
* @param {int} [limit] the number of records in the response
|
|
3049
|
+
* @param {object} [params] exchange specific parameters
|
|
3050
|
+
* @param {int} [params.until] the time in ms of the latest record to retrieve as a unix timestamp
|
|
3051
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
3052
|
+
* @returns An array of [open interest structures]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
3053
|
+
*/
|
|
3054
|
+
await this.loadMarkets();
|
|
3055
|
+
let paginate = false;
|
|
3056
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchOpenInterestHistory', 'paginate');
|
|
3057
|
+
if (paginate) {
|
|
3058
|
+
return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, '8h', params, 5000);
|
|
3059
|
+
}
|
|
3060
|
+
const market = this.market(symbol);
|
|
3061
|
+
let request = {
|
|
3062
|
+
'symbol': market['id'],
|
|
3063
|
+
};
|
|
3064
|
+
if (since !== undefined) {
|
|
3065
|
+
request['start'] = since;
|
|
3066
|
+
}
|
|
3067
|
+
if (limit !== undefined) {
|
|
3068
|
+
request['limit'] = limit;
|
|
3069
|
+
}
|
|
3070
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
3071
|
+
const response = await this.publicGetStatusDerivSymbolHist(this.extend(request, params));
|
|
3072
|
+
//
|
|
3073
|
+
// [
|
|
3074
|
+
// [
|
|
3075
|
+
// 1706295191000, // timestamp
|
|
3076
|
+
// null,
|
|
3077
|
+
// 42152.425382, // derivative mid price
|
|
3078
|
+
// 42133, // spot mid price
|
|
3079
|
+
// null,
|
|
3080
|
+
// 37671589.7853521, // insurance fund balance
|
|
3081
|
+
// null,
|
|
3082
|
+
// 1706313600000, // timestamp of next funding
|
|
3083
|
+
// 0.00018734, // accrued funding for next period
|
|
3084
|
+
// 3343, // next funding step
|
|
3085
|
+
// null,
|
|
3086
|
+
// 0.00007587, // current funding
|
|
3087
|
+
// null,
|
|
3088
|
+
// null,
|
|
3089
|
+
// 42134.1, // mark price
|
|
3090
|
+
// null,
|
|
3091
|
+
// null,
|
|
3092
|
+
// 5775.20348804, // open interest number of contracts
|
|
3093
|
+
// null,
|
|
3094
|
+
// null,
|
|
3095
|
+
// null,
|
|
3096
|
+
// 0.0005, // average spread without funding payment
|
|
3097
|
+
// 0.0025 // funding payment cap
|
|
3098
|
+
// ],
|
|
3099
|
+
// ]
|
|
3100
|
+
//
|
|
3101
|
+
return this.parseOpenInterests(response, market, since, limit);
|
|
3102
|
+
}
|
|
3037
3103
|
parseOpenInterest(interest, market = undefined) {
|
|
3104
|
+
//
|
|
3105
|
+
// fetchOpenInterest:
|
|
3038
3106
|
//
|
|
3039
3107
|
// [
|
|
3040
3108
|
// "tXRPF0:USTF0", // market id
|
|
@@ -3063,17 +3131,137 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
3063
3131
|
// 0.0025 // funding payment cap
|
|
3064
3132
|
// ]
|
|
3065
3133
|
//
|
|
3134
|
+
// fetchOpenInterestHistory:
|
|
3135
|
+
//
|
|
3136
|
+
// [
|
|
3137
|
+
// 1706295191000, // timestamp
|
|
3138
|
+
// null,
|
|
3139
|
+
// 42152.425382, // derivative mid price
|
|
3140
|
+
// 42133, // spot mid price
|
|
3141
|
+
// null,
|
|
3142
|
+
// 37671589.7853521, // insurance fund balance
|
|
3143
|
+
// null,
|
|
3144
|
+
// 1706313600000, // timestamp of next funding
|
|
3145
|
+
// 0.00018734, // accrued funding for next period
|
|
3146
|
+
// 3343, // next funding step
|
|
3147
|
+
// null,
|
|
3148
|
+
// 0.00007587, // current funding
|
|
3149
|
+
// null,
|
|
3150
|
+
// null,
|
|
3151
|
+
// 42134.1, // mark price
|
|
3152
|
+
// null,
|
|
3153
|
+
// null,
|
|
3154
|
+
// 5775.20348804, // open interest number of contracts
|
|
3155
|
+
// null,
|
|
3156
|
+
// null,
|
|
3157
|
+
// null,
|
|
3158
|
+
// 0.0005, // average spread without funding payment
|
|
3159
|
+
// 0.0025 // funding payment cap
|
|
3160
|
+
// ]
|
|
3161
|
+
//
|
|
3162
|
+
const interestLength = interest.length;
|
|
3163
|
+
const openInterestIndex = (interestLength === 23) ? 17 : 18;
|
|
3066
3164
|
const timestamp = this.safeInteger(interest, 1);
|
|
3067
3165
|
const marketId = this.safeString(interest, 0);
|
|
3068
3166
|
return this.safeOpenInterest({
|
|
3069
3167
|
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3070
|
-
'openInterestAmount': this.safeNumber(interest,
|
|
3168
|
+
'openInterestAmount': this.safeNumber(interest, openInterestIndex),
|
|
3071
3169
|
'openInterestValue': undefined,
|
|
3072
3170
|
'timestamp': timestamp,
|
|
3073
3171
|
'datetime': this.iso8601(timestamp),
|
|
3074
3172
|
'info': interest,
|
|
3075
3173
|
}, market);
|
|
3076
3174
|
}
|
|
3175
|
+
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
3176
|
+
/**
|
|
3177
|
+
* @method
|
|
3178
|
+
* @name bitfinex2#fetchLiquidations
|
|
3179
|
+
* @description retrieves the public liquidations of a trading pair
|
|
3180
|
+
* @see https://docs.bitfinex.com/reference/rest-public-liquidations
|
|
3181
|
+
* @param {string} symbol unified CCXT market symbol
|
|
3182
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
3183
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
3184
|
+
* @param {object} [params] exchange specific parameters
|
|
3185
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
3186
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
3187
|
+
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
|
|
3188
|
+
*/
|
|
3189
|
+
await this.loadMarkets();
|
|
3190
|
+
let paginate = false;
|
|
3191
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
|
|
3192
|
+
if (paginate) {
|
|
3193
|
+
return await this.fetchPaginatedCallDeterministic('fetchLiquidations', symbol, since, limit, '8h', params, 500);
|
|
3194
|
+
}
|
|
3195
|
+
const market = this.market(symbol);
|
|
3196
|
+
let request = {};
|
|
3197
|
+
if (since !== undefined) {
|
|
3198
|
+
request['start'] = since;
|
|
3199
|
+
}
|
|
3200
|
+
if (limit !== undefined) {
|
|
3201
|
+
request['limit'] = limit;
|
|
3202
|
+
}
|
|
3203
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
3204
|
+
const response = await this.publicGetLiquidationsHist(this.extend(request, params));
|
|
3205
|
+
//
|
|
3206
|
+
// [
|
|
3207
|
+
// [
|
|
3208
|
+
// [
|
|
3209
|
+
// "pos",
|
|
3210
|
+
// 171085137,
|
|
3211
|
+
// 1706395919788,
|
|
3212
|
+
// null,
|
|
3213
|
+
// "tAVAXF0:USTF0",
|
|
3214
|
+
// -8,
|
|
3215
|
+
// 32.868,
|
|
3216
|
+
// null,
|
|
3217
|
+
// 1,
|
|
3218
|
+
// 1,
|
|
3219
|
+
// null,
|
|
3220
|
+
// 33.255
|
|
3221
|
+
// ]
|
|
3222
|
+
// ],
|
|
3223
|
+
// ]
|
|
3224
|
+
//
|
|
3225
|
+
return this.parseLiquidations(response, market, since, limit);
|
|
3226
|
+
}
|
|
3227
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
3228
|
+
//
|
|
3229
|
+
// [
|
|
3230
|
+
// [
|
|
3231
|
+
// "pos",
|
|
3232
|
+
// 171085137, // position id
|
|
3233
|
+
// 1706395919788, // timestamp
|
|
3234
|
+
// null,
|
|
3235
|
+
// "tAVAXF0:USTF0", // market id
|
|
3236
|
+
// -8, // amount in contracts
|
|
3237
|
+
// 32.868, // base price
|
|
3238
|
+
// null,
|
|
3239
|
+
// 1,
|
|
3240
|
+
// 1,
|
|
3241
|
+
// null,
|
|
3242
|
+
// 33.255 // acquired price
|
|
3243
|
+
// ]
|
|
3244
|
+
// ]
|
|
3245
|
+
//
|
|
3246
|
+
const entry = liquidation[0];
|
|
3247
|
+
const timestamp = this.safeInteger(entry, 2);
|
|
3248
|
+
const marketId = this.safeString(entry, 4);
|
|
3249
|
+
const contracts = Precise["default"].stringAbs(this.safeString(entry, 5));
|
|
3250
|
+
const contractSize = this.safeString(market, 'contractSize');
|
|
3251
|
+
const baseValue = Precise["default"].stringMul(contracts, contractSize);
|
|
3252
|
+
const price = this.safeString(entry, 11);
|
|
3253
|
+
return this.safeLiquidation({
|
|
3254
|
+
'info': entry,
|
|
3255
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
|
|
3256
|
+
'contracts': this.parseNumber(contracts),
|
|
3257
|
+
'contractSize': this.parseNumber(contractSize),
|
|
3258
|
+
'price': this.parseNumber(price),
|
|
3259
|
+
'baseValue': this.parseNumber(baseValue),
|
|
3260
|
+
'quoteValue': this.parseNumber(Precise["default"].stringMul(baseValue, price)),
|
|
3261
|
+
'timestamp': timestamp,
|
|
3262
|
+
'datetime': this.iso8601(timestamp),
|
|
3263
|
+
});
|
|
3264
|
+
}
|
|
3077
3265
|
}
|
|
3078
3266
|
|
|
3079
3267
|
module.exports = bitfinex2;
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -3437,7 +3437,7 @@ class gate extends gate$1 {
|
|
|
3437
3437
|
// "price": "333"
|
|
3438
3438
|
// }
|
|
3439
3439
|
//
|
|
3440
|
-
const id = this.
|
|
3440
|
+
const id = this.safeString2(trade, 'id', 'trade_id');
|
|
3441
3441
|
let timestamp = this.safeTimestamp2(trade, 'time', 'create_time');
|
|
3442
3442
|
timestamp = this.safeInteger(trade, 'create_time_ms', timestamp);
|
|
3443
3443
|
const marketId = this.safeString2(trade, 'currency_pair', 'contract');
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -3766,7 +3766,7 @@ class phemex extends phemex$1 {
|
|
|
3766
3766
|
const contracts = this.safeString(position, 'size');
|
|
3767
3767
|
const contractSize = this.safeValue(market, 'contractSize');
|
|
3768
3768
|
const contractSizeString = this.numberToString(contractSize);
|
|
3769
|
-
const leverage = this.parseNumber(Precise["default"].stringAbs((this.
|
|
3769
|
+
const leverage = this.parseNumber(Precise["default"].stringAbs((this.safeString2(position, 'leverage', 'leverageRr'))));
|
|
3770
3770
|
const entryPriceString = this.safeString2(position, 'avgEntryPrice', 'avgEntryPriceRp');
|
|
3771
3771
|
const rawSide = this.safeString(position, 'side');
|
|
3772
3772
|
let side = undefined;
|
|
@@ -13,7 +13,7 @@ class bitopro extends bitopro$1 {
|
|
|
13
13
|
'has': {
|
|
14
14
|
'ws': true,
|
|
15
15
|
'watchBalance': true,
|
|
16
|
-
'watchMyTrades':
|
|
16
|
+
'watchMyTrades': true,
|
|
17
17
|
'watchOHLCV': false,
|
|
18
18
|
'watchOrderBook': true,
|
|
19
19
|
'watchOrders': false,
|
|
@@ -174,6 +174,150 @@ class bitopro extends bitopro$1 {
|
|
|
174
174
|
this.trades[symbol] = tradesCache;
|
|
175
175
|
client.resolve(tradesCache, messageHash);
|
|
176
176
|
}
|
|
177
|
+
async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
178
|
+
/**
|
|
179
|
+
* @method
|
|
180
|
+
* @name bitopro#watchMyTrades
|
|
181
|
+
* @description watches information on multiple trades made by the user
|
|
182
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/private/matches_stream.md
|
|
183
|
+
* @param {string} symbol unified market symbol of the market trades were made in
|
|
184
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
185
|
+
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
186
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
187
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
|
|
188
|
+
*/
|
|
189
|
+
this.checkRequiredCredentials();
|
|
190
|
+
await this.loadMarkets();
|
|
191
|
+
let messageHash = 'USER_TRADE';
|
|
192
|
+
if (symbol !== undefined) {
|
|
193
|
+
const market = this.market(symbol);
|
|
194
|
+
messageHash = messageHash + ':' + market['symbol'];
|
|
195
|
+
}
|
|
196
|
+
const url = this.urls['ws']['private'] + '/' + 'user-trades';
|
|
197
|
+
this.authenticate(url);
|
|
198
|
+
const trades = await this.watch(url, messageHash, undefined, messageHash);
|
|
199
|
+
if (this.newUpdates) {
|
|
200
|
+
limit = trades.getLimit(symbol, limit);
|
|
201
|
+
}
|
|
202
|
+
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
203
|
+
}
|
|
204
|
+
handleMyTrade(client, message) {
|
|
205
|
+
//
|
|
206
|
+
// {
|
|
207
|
+
// "event": "USER_TRADE",
|
|
208
|
+
// "timestamp": 1694667358782,
|
|
209
|
+
// "datetime": "2023-09-14T12:55:58.782Z",
|
|
210
|
+
// "data": {
|
|
211
|
+
// "base": "usdt",
|
|
212
|
+
// "quote": "twd",
|
|
213
|
+
// "side": "ask",
|
|
214
|
+
// "price": "32.039",
|
|
215
|
+
// "volume": "1",
|
|
216
|
+
// "fee": "6407800",
|
|
217
|
+
// "feeCurrency": "twd",
|
|
218
|
+
// "transactionTimestamp": 1694667358,
|
|
219
|
+
// "eventTimestamp": 1694667358,
|
|
220
|
+
// "orderID": 390733918,
|
|
221
|
+
// "orderType": "LIMIT",
|
|
222
|
+
// "matchID": "bd07673a-94b1-419e-b5ee-d7b723261a5d",
|
|
223
|
+
// "isMarket": false,
|
|
224
|
+
// "isMaker": false
|
|
225
|
+
// }
|
|
226
|
+
// }
|
|
227
|
+
//
|
|
228
|
+
const data = this.safeValue(message, 'data', {});
|
|
229
|
+
const baseId = this.safeString(data, 'base');
|
|
230
|
+
const quoteId = this.safeString(data, 'quote');
|
|
231
|
+
const base = this.safeCurrencyCode(baseId);
|
|
232
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
233
|
+
const symbol = this.symbol(base + '/' + quote);
|
|
234
|
+
const messageHash = this.safeString(message, 'event');
|
|
235
|
+
if (this.myTrades === undefined) {
|
|
236
|
+
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
237
|
+
this.myTrades = new Cache.ArrayCacheBySymbolById(limit);
|
|
238
|
+
}
|
|
239
|
+
const trades = this.myTrades;
|
|
240
|
+
const parsed = this.parseWsTrade(data);
|
|
241
|
+
trades.append(parsed);
|
|
242
|
+
client.resolve(trades, messageHash);
|
|
243
|
+
client.resolve(trades, messageHash + ':' + symbol);
|
|
244
|
+
}
|
|
245
|
+
parseWsTrade(trade, market = undefined) {
|
|
246
|
+
//
|
|
247
|
+
// {
|
|
248
|
+
// "base": "usdt",
|
|
249
|
+
// "quote": "twd",
|
|
250
|
+
// "side": "ask",
|
|
251
|
+
// "price": "32.039",
|
|
252
|
+
// "volume": "1",
|
|
253
|
+
// "fee": "6407800",
|
|
254
|
+
// "feeCurrency": "twd",
|
|
255
|
+
// "transactionTimestamp": 1694667358,
|
|
256
|
+
// "eventTimestamp": 1694667358,
|
|
257
|
+
// "orderID": 390733918,
|
|
258
|
+
// "orderType": "LIMIT",
|
|
259
|
+
// "matchID": "bd07673a-94b1-419e-b5ee-d7b723261a5d",
|
|
260
|
+
// "isMarket": false,
|
|
261
|
+
// "isMaker": false
|
|
262
|
+
// }
|
|
263
|
+
//
|
|
264
|
+
const id = this.safeString(trade, 'matchID');
|
|
265
|
+
const orderId = this.safeString(trade, 'orderID');
|
|
266
|
+
const timestamp = this.safeTimestamp(trade, 'transactionTimestamp');
|
|
267
|
+
const baseId = this.safeString(trade, 'base');
|
|
268
|
+
const quoteId = this.safeString(trade, 'quote');
|
|
269
|
+
const base = this.safeCurrencyCode(baseId);
|
|
270
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
271
|
+
const symbol = this.symbol(base + '/' + quote);
|
|
272
|
+
market = this.safeMarket(symbol, market);
|
|
273
|
+
const price = this.safeString(trade, 'price');
|
|
274
|
+
const type = this.safeStringLower(trade, 'orderType');
|
|
275
|
+
let side = this.safeString(trade, 'side');
|
|
276
|
+
if (side !== undefined) {
|
|
277
|
+
if (side === 'ask') {
|
|
278
|
+
side = 'sell';
|
|
279
|
+
}
|
|
280
|
+
else if (side === 'bid') {
|
|
281
|
+
side = 'buy';
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const amount = this.safeString(trade, 'volume');
|
|
285
|
+
let fee = undefined;
|
|
286
|
+
const feeAmount = this.safeString(trade, 'fee');
|
|
287
|
+
const feeSymbol = this.safeCurrencyCode(this.safeString(trade, 'feeCurrency'));
|
|
288
|
+
if (feeAmount !== undefined) {
|
|
289
|
+
fee = {
|
|
290
|
+
'cost': feeAmount,
|
|
291
|
+
'currency': feeSymbol,
|
|
292
|
+
'rate': undefined,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const isMaker = this.safeValue(trade, 'isMaker');
|
|
296
|
+
let takerOrMaker = undefined;
|
|
297
|
+
if (isMaker !== undefined) {
|
|
298
|
+
if (isMaker) {
|
|
299
|
+
takerOrMaker = 'maker';
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
takerOrMaker = 'taker';
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return this.safeTrade({
|
|
306
|
+
'id': id,
|
|
307
|
+
'info': trade,
|
|
308
|
+
'order': orderId,
|
|
309
|
+
'timestamp': timestamp,
|
|
310
|
+
'datetime': this.iso8601(timestamp),
|
|
311
|
+
'symbol': symbol,
|
|
312
|
+
'takerOrMaker': takerOrMaker,
|
|
313
|
+
'type': type,
|
|
314
|
+
'side': side,
|
|
315
|
+
'price': price,
|
|
316
|
+
'amount': amount,
|
|
317
|
+
'cost': undefined,
|
|
318
|
+
'fee': fee,
|
|
319
|
+
}, market);
|
|
320
|
+
}
|
|
177
321
|
async watchTicker(symbol, params = {}) {
|
|
178
322
|
/**
|
|
179
323
|
* @method
|
|
@@ -316,6 +460,7 @@ class bitopro extends bitopro$1 {
|
|
|
316
460
|
'TICKER': this.handleTicker,
|
|
317
461
|
'ORDER_BOOK': this.handleOrderBook,
|
|
318
462
|
'ACCOUNT_BALANCE': this.handleBalance,
|
|
463
|
+
'USER_TRADE': this.handleMyTrade,
|
|
319
464
|
};
|
|
320
465
|
const event = this.safeString(message, 'event');
|
|
321
466
|
const method = this.safeValue(methods, event);
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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 } from './src/base/types.js';
|
|
6
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, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.24";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
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, AuthenticationError, AddressPending, NoChange } 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.25';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|