Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fetchBorrowRate #22279

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions build/transpile.js
Expand Up @@ -298,8 +298,10 @@ class Transpiler {
[ /\.urlencodeWithArrayRepeat\s/g, '.urlencode_with_array_repeat' ],
[ /\.call\s*\(this, /g, '(' ],
[ /\.getSupportedMapping\s/g, '.get_supported_mapping'],
[ /\.fetchBorrowRates\s/g, '.fetch_borrow_rates'],
[ /\.fetchBorrowRate\s/g, '.fetch_borrow_rate'],
[ /\.fetchCrossBorrowRates\s/g, '.fetch_cross_borrow_rates'],
[ /\.fetchCrossBorrowRate\s/g, '.fetch_cross_borrow_rate'],
[ /\.fetchIsolatedBorrowRates\s/g, '.fetch_isolated_borrow_rates'],
[ /\.fetchIsolatedBorrowRate\s/g, '.fetch_isolated_borrow_rate'],
[ /\.handleMarketTypeAndParams\s/g, '.handle_market_type_and_params'],
[ /\.checkOrderArguments\s/g, '.check_order_arguments'],
[ /\.isPostOnly\s/g, '.is_post_only'],
Expand Down
11 changes: 2 additions & 9 deletions ts/src/base/Exchange.ts
Expand Up @@ -541,11 +541,8 @@ export default class Exchange {
'fetchBalanceWs': undefined,
'fetchBidsAsks': undefined,
'fetchBorrowInterest': undefined,
'fetchBorrowRate': undefined,
'fetchBorrowRateHistories': undefined,
'fetchBorrowRateHistory': undefined,
'fetchBorrowRates': undefined,
'fetchBorrowRatesPerSymbol': undefined,
'fetchCanceledAndClosedOrders': undefined,
'fetchCanceledOrders': undefined,
'fetchClosedOrder': undefined,
Expand Down Expand Up @@ -3422,10 +3419,6 @@ export default class Exchange {
});
}

async fetchBorrowRate (code: string, amount, params = {}): Promise<{}> {
throw new NotSupported (this.id + ' fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead');
}

async repayCrossMargin (code: string, amount, params = {}): Promise<{}> {
throw new NotSupported (this.id + ' repayCrossMargin is not support yet');
}
Expand Down Expand Up @@ -4457,7 +4450,7 @@ export default class Exchange {

async fetchCrossBorrowRate (code: string, params = {}): Promise<{}> {
await this.loadMarkets ();
if (!this.has['fetchBorrowRates']) {
if (!this.has['fetchCrossBorrowRates']) {
throw new NotSupported (this.id + ' fetchCrossBorrowRate() is not supported yet');
}
const borrowRates = await this.fetchCrossBorrowRates (params);
Expand All @@ -4470,7 +4463,7 @@ export default class Exchange {

async fetchIsolatedBorrowRate (symbol: string, params = {}): Promise<{}> {
await this.loadMarkets ();
if (!this.has['fetchBorrowRates']) {
if (!this.has['fetchIsolatedBorrowRates']) {
throw new NotSupported (this.id + ' fetchIsolatedBorrowRate() is not supported yet');
}
const borrowRates = await this.fetchIsolatedBorrowRates (params);
Expand Down
3 changes: 0 additions & 3 deletions ts/src/binanceus.ts
Expand Up @@ -55,11 +55,8 @@ export default class binanceus extends binance {
'closePosition': false,
'createReduceOnlyOrder': false,
'fetchBorrowInterest': false,
'fetchBorrowRate': false,
'fetchBorrowRateHistories': false,
'fetchBorrowRateHistory': false,
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchFundingHistory': false,
'fetchFundingRate': false,
'fetchFundingRateHistory': false,
Expand Down
3 changes: 0 additions & 3 deletions ts/src/bitfinex2.ts
Expand Up @@ -50,11 +50,8 @@ export default class bitfinex2 extends Exchange {
'editOrder': true,
'fetchBalance': true,
'fetchBorrowInterest': false,
'fetchBorrowRate': false,
'fetchBorrowRateHistories': false,
'fetchBorrowRateHistory': false,
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchClosedOrder': true,
'fetchClosedOrders': true,
'fetchCrossBorrowRate': false,
Expand Down
3 changes: 0 additions & 3 deletions ts/src/okcoin.ts
Expand Up @@ -39,11 +39,8 @@ export default class okcoin extends Exchange {
'createOrder': true,
'fetchBalance': true,
'fetchBorrowInterest': false,
'fetchBorrowRate': false,
'fetchBorrowRateHistories': false,
'fetchBorrowRateHistory': false,
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchClosedOrders': true,
'fetchCurrencies': true, // see below
'fetchDepositAddress': true,
Expand Down
@@ -1,7 +1,7 @@
import { Exchange } from "../../../../ccxt";
import testSharedMethods from './test.sharedMethods.js';

function testBorrowRate (exchange: Exchange, skippedProperties: object, method: string, entry: object, requestedCode: string) {
function testCrossBorrowRate (exchange: Exchange, skippedProperties: object, method: string, entry: object, requestedCode: string) {
const format = {
'info': {}, // Or []
'currency': 'USDT',
Expand All @@ -19,4 +19,4 @@ function testBorrowRate (exchange: Exchange, skippedProperties: object, method:
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'rate', '0');
}

export default testBorrowRate;
export default testCrossBorrowRate;
28 changes: 28 additions & 0 deletions ts/src/test/Exchange/base/test.isolatedBorrowRate.ts
@@ -0,0 +1,28 @@
import { Exchange } from "../../../../ccxt";
import testSharedMethods from './test.sharedMethods.js';

function testFetchIsolatedBorrowRate (exchange: Exchange, skippedProperties: object, method: string, entry: object, requestedCode: string) {
const format = {
'info': {}, // Or []
'symbol': 'BTC/USDT',
'base': 'BTC',
'baseRate': exchange.parseNumber ('0.0006'), // Interest rate,
'quote': 'USDT',
'quoteRate': exchange.parseNumber ('0.0006'), // Interest rate,
'timestamp': 1638230400000,
'datetime': '2021-11-30T00:00:00.000Z',
'period': 86400000, // Amount of time the interest rate is based on in milliseconds
};
testSharedMethods.assertStructure (exchange, skippedProperties, method, entry, format);
testSharedMethods.assertTimestampAndDatetime (exchange, skippedProperties, method, entry);
testSharedMethods.assertCurrencyCode (exchange, skippedProperties, method, entry, entry['base'], requestedCode);
testSharedMethods.assertCurrencyCode (exchange, skippedProperties, method, entry, entry['quote'], requestedCode);
testSharedMethods.assertSymbol (exchange, skippedProperties, method, entry, 'symbol', requestedCode);
//
// assert (borrowRate['period'] === 86400000 || borrowRate['period'] === 3600000) // Milliseconds in an hour or a day
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'period', '0');
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'baseRate', '0');
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'quoteRate', '0');
}

export default testFetchIsolatedBorrowRate;
16 changes: 16 additions & 0 deletions ts/src/test/Exchange/test.fetchCrossBorrowRates.ts
@@ -0,0 +1,16 @@
import { Exchange } from "../../../ccxt";
import testSharedMethods from './base/test.sharedMethods.js';
import testCrossBorrowRate from './base/test.crossBorrowRate.js';

async function testFetchCrossBorrowRates (exchange: Exchange, skippedProperties: object, symbol: string) {
const method = 'fetchCrossBorrowRates';
const borrowRates = await exchange.fetchCrossBorrowRates (symbol);
const codes = Object.keys (borrowRates);
testSharedMethods.assertNonEmtpyArray (exchange, skippedProperties, method, codes);
for (let i = 0; i < codes.length; i++) {
const code = codes[i];
testCrossBorrowRate (exchange, skippedProperties, method, borrowRates[code], symbol);
}
}

export default testFetchCrossBorrowRates;
16 changes: 16 additions & 0 deletions ts/src/test/Exchange/test.fetchIsolatedBorrowRates.ts
@@ -0,0 +1,16 @@
import { Exchange } from "../../../ccxt";
import testSharedMethods from './base/test.sharedMethods.js';
import testIsolatedBorrowRate from './base/test.isolatedBorrowRate.js';

async function testFetchIsolatedBorrowRates (exchange: Exchange, skippedProperties: object, symbol: string) {
const method = 'fetchIsolatedBorrowRates';
const borrowRates = await exchange.fetchIsolatedBorrowRates (symbol);
const codes = Object.keys (borrowRates);
testSharedMethods.assertNonEmtpyArray (exchange, skippedProperties, method, codes);
for (let i = 0; i < codes.length; i++) {
const code = codes[i];
testIsolatedBorrowRate (exchange, skippedProperties, method, borrowRates[code], symbol);
}
}

export default testFetchIsolatedBorrowRates;
1 change: 0 additions & 1 deletion wiki/Manual.md
Expand Up @@ -2813,7 +2813,6 @@ Data on the borrow rate for a currency can be retrieved using
- `fetchCrossBorrowRates ()` for all currencies borrow rates
- `fetchIsolatedBorrowRate ()` for a trading pairs borrow rate
- `fetchIsolatedBorrowRates ()` for all trading pairs borrow rates
- `fetchBorrowRatesPerSymbol ()` for the borrow rates of currencies in individual markets

```javascript
fetchCrossBorrowRate (code, params = {})
Expand Down