Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions js/src/bitfinex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,19 @@ export default class bitfinex extends Exchange {
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
/**
* @method
* @name bitfinex#fetchTransfers
* @description fetch internal transfers as unified transfer structures from ledger entries
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest transfer, default is undefined
* @param {int} [limit] max number of transfers to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
ledgerEntryToTransfer(entry: LedgerEntry): TransferEntry;
parseTransferStatus(status: Str): Str;
convertDerivativesId(currency: any, type: any): any;
/**
Expand Down Expand Up @@ -254,6 +266,19 @@ export default class bitfinex extends Exchange {
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
/**
* @method
* @name bitfinex#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
* @see https://docs.bitfinex.com/reference/rest-auth-orders-history
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
/**
* @method
* @name bitfinex#fetchOrderTrades
Expand Down Expand Up @@ -324,6 +349,30 @@ export default class bitfinex extends Exchange {
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
/**
* @method
* @name bitfinex#fetchDeposits
* @description fetch all deposits made to an account
* @see https://docs.bitfinex.com/reference/rest-auth-movements
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest deposit, default is undefined
* @param {int} [limit] max number of deposits to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
/**
* @method
* @name bitfinex#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://docs.bitfinex.com/reference/rest-auth-movements
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest withdrawal, default is undefined
* @param {int} [limit] max number of withdrawals to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
/**
* @method
* @name bitfinex#withdraw
Expand Down
87 changes: 87 additions & 0 deletions js/src/bitfinex.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class bitfinex extends Exchange {
'fetchDepositAddress': true,
'fetchDepositAddresses': false,
'fetchDepositAddressesByNetwork': false,
'fetchDeposits': true,
'fetchDepositsWithdrawals': true,
'fetchFundingHistory': false,
'fetchFundingRate': 'emulated',
Expand All @@ -92,6 +93,7 @@ export default class bitfinex extends Exchange {
'fetchOrderBook': true,
'fetchOrderBooks': false,
'fetchOrderTrades': true,
'fetchOrders': true,
'fetchPosition': false,
'fetchPositionMode': false,
'fetchPositions': true,
Expand All @@ -103,6 +105,7 @@ export default class bitfinex extends Exchange {
'fetchTradingFees': true,
'fetchTransactionFees': undefined,
'fetchTransactions': 'emulated',
'fetchTransfers': 'emulated',
'reduceMargin': false,
'repayCrossMargin': false,
'repayIsolatedMargin': false,
Expand All @@ -112,6 +115,7 @@ export default class bitfinex extends Exchange {
'setPositionMode': false,
'signIn': false,
'transfer': true,
'fetchWithdrawals': true,
'withdraw': true,
},
'timeframes': {
Expand Down Expand Up @@ -1046,6 +1050,25 @@ export default class bitfinex extends Exchange {
}
return this.parseTransfer({ 'result': response }, currency);
}
/**
* @method
* @name bitfinex#fetchTransfers
* @description fetch internal transfers as unified transfer structures from ledger entries
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest transfer, default is undefined
* @param {int} [limit] max number of transfers to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
const ledger = await this.fetchLedger(code, since, limit, params);
const transfers = ledger.filter((entry) => entry['type'] === 'transfer');
const result = [];
for (let i = 0; i < transfers.length; i++) {
result.push(this.ledgerEntryToTransfer(transfers[i]));
}
return this.filterBySinceLimit(result, since, limit);
}
parseTransfer(transfer, currency = undefined) {
//
// transfer
Expand Down Expand Up @@ -1089,6 +1112,19 @@ export default class bitfinex extends Exchange {
'info': result,
};
}
ledgerEntryToTransfer(entry) {
return {
'id': this.safeString(entry, 'id'),
'timestamp': this.safeInteger(entry, 'timestamp'),
'datetime': this.safeString(entry, 'datetime'),
'status': this.safeString(entry, 'status'),
'amount': this.safeNumber(entry, 'amount'),
'currency': this.safeString(entry, 'currency'),
'fromAccount': this.safeString(entry, 'account'),
'toAccount': this.safeString(entry, 'referenceAccount'),
'info': entry['info'],
};
}
parseTransferStatus(status) {
const statuses = {
'SUCCESS': 'ok',
Expand Down Expand Up @@ -2249,6 +2285,25 @@ export default class bitfinex extends Exchange {
}
return this.parseOrders(ordersList, market, since, limit);
}
/**
* @method
* @name bitfinex#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
* @see https://docs.bitfinex.com/reference/rest-auth-orders-history
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
const openOrders = await this.fetchOpenOrders(symbol, since, limit, this.extend({}, params));
const closedOrders = await this.fetchClosedOrders(symbol, since, limit, this.extend({}, params));
const uniqueOrders = this.removeRepeatedElementsFromArray(openOrders.concat(closedOrders), false);
const sortedOrders = this.sortBy(uniqueOrders, 'timestamp');
return this.filterBySinceLimit(sortedOrders, since, limit);
}
/**
* @method
* @name bitfinex#fetchOrderTrades
Expand Down Expand Up @@ -2728,6 +2783,38 @@ export default class bitfinex extends Exchange {
//
return this.parseTransactions(response, currency, since, limit);
}
/**
* @method
* @name bitfinex#fetchDeposits
* @description fetch all deposits made to an account
* @see https://docs.bitfinex.com/reference/rest-auth-movements
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest deposit, default is undefined
* @param {int} [limit] max number of deposits to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
const transactions = await this.fetchDepositsWithdrawals(code, since, limit, params);
const deposits = transactions.filter((transaction) => transaction['type'] === 'deposit');
return this.filterBySinceLimit(deposits, since, limit);
}
/**
* @method
* @name bitfinex#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://docs.bitfinex.com/reference/rest-auth-movements
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest withdrawal, default is undefined
* @param {int} [limit] max number of withdrawals to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
*/
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
const transactions = await this.fetchDepositsWithdrawals(code, since, limit, params);
const withdrawals = transactions.filter((transaction) => transaction['type'] === 'withdrawal');
return this.filterBySinceLimit(withdrawals, since, limit);
}
/**
* @method
* @name bitfinex#withdraw
Expand Down
8 changes: 6 additions & 2 deletions js/src/bybit.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class bybit extends Exchange {
'fetchOptionChain': true,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrders': false,
'fetchOrders': true,
'fetchOrderTrades': true,
'fetchPosition': true,
'fetchPositionHistory': 'emulated',
Expand Down Expand Up @@ -5039,7 +5039,11 @@ export default class bybit extends Exchange {
*/
const enableUnifiedAccount = this.safeBool(res, 1);
if (enableUnifiedAccount) {
throw new NotSupported(this.id + ' fetchOrders() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrders, fetchClosedOrders or fetchCanceledOrders');
const openOrders = await this.fetchOpenOrders(symbol, since, limit, this.extend({}, params));
const historicalOrders = await this.fetchCanceledAndClosedOrders(symbol, since, limit, this.extend({}, params));
const uniqueOrders = this.removeRepeatedElementsFromArray(openOrders.concat(historicalOrders), false);
const sortedOrders = this.sortBy(uniqueOrders, 'timestamp');
return this.filterBySinceLimit(sortedOrders, since, limit);
}
return await this.fetchOrdersClassic(symbol, since, limit, params);
}
Expand Down
18 changes: 17 additions & 1 deletion js/src/mexc.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Exchange from './abstract/mexc.js';
import type { TransferEntry, IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook, OrderRequest, FundingHistory, Order, Str, Trade, Transaction, Ticker, Tickers, Strings, Market, Currency, Leverage, Num, Account, MarginModification, Currencies, Dict, LeverageTier, LeverageTiers, int, FundingRate, DepositAddress, TradingFeeInterface } from './base/types.js';
import type { TransferEntry, IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook, OrderRequest, FundingHistory, Order, Str, Trade, Transaction, Ticker, Tickers, Strings, Market, Currency, Leverage, Num, Account, MarginModification, Currencies, Dict, LeverageTier, LeverageTiers, int, FundingRate, DepositAddress, TradingFeeInterface, LedgerEntry } from './base/types.js';
/**
* @class mexc
* @augments Exchange
Expand Down Expand Up @@ -641,6 +641,22 @@ export default class mexc extends Exchange {
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
*/
fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
/**
* @method
* @name mexc#fetchLedger
* @description fetch account-movement history as a unified ledger by composing MEXC deposits, withdrawals, and internal transfers
* @param {string} [code] unified currency code of the ledger entries, default is undefined
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
* @param {int} [limit] max number of ledger entries to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.includeDeposits] default true
* @param {boolean} [params.includeWithdrawals] default true
* @param {boolean} [params.includeTransfers] default true
* @returns {object[]} a list of [ledger structures]{@link https://docs.ccxt.com/#/?id=ledger}
*/
fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
transactionToLedgerEntry(transaction: Transaction): LedgerEntry;
transferToLedgerEntry(transfer: TransferEntry): LedgerEntry;
/**
* @method
* @name mexc#transfer
Expand Down
Loading
Loading