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

Borrow rate types and parsers #22205

Merged
merged 16 commits into from Apr 28, 2024
Merged

Conversation

samgermain
Copy link
Member

@samgermain samgermain commented Apr 19, 2024

  • new types IsolatedBorrowRate, IsolatedBorrowRates, CrossBorrowRates
  • BorrowRate type renamed to CrossBorrowRate (it's so far unused, so this shouldn't create problems)
  • new methods parseIsolatedBorrowRates and parseIsolatedBorrowRate
  • add return types for fetchCrossBorrowRate and fetchCrossBorrowRates

Testing

2024-04-19T22:52:17.387Z
Node.js: v18.12.0
CCXT v4.3.1
bitmart.fetchIsolatedBorrowRates ()
2024-04-19T22:52:22.054Z iteration 0 passed in 855 ms

{
  'BLUR/USDT': {
    symbol: 'BLUR/USDT',
    base: 'BLUR',
    baseRate: 0.00002291,
    quote: 'USDT',
    quoteRate: 0.00002291,
    period: 3600000,
    timestamp: undefined,
    datetime: undefined,
    info: {
      symbol: 'BLUR_USDT',
      max_leverage: '5',
      symbol_enabled: false,
      base: {
        currency: 'BLUR',
        daily_interest: '0.00055000',
        hourly_interest: '0.00002291',
        max_borrow_amount: '22163.21000000',
        min_borrow_amount: '0.00000001',
        borrowable_amount: '0.00000000'
      },
      quote: {
        currency: 'USDT',
        daily_interest: '0.00055000',
        hourly_interest: '0.00002291',
        max_borrow_amount: '20000.00000000',
        min_borrow_amount: '0.00000001',
        borrowable_amount: '0.00000000'
      }
    }
  },
2024-04-19T22:57:04.152Z
Node.js: v18.12.0
CCXT v4.3.1
coinex.fetchIsolatedBorrowRates ()
2024-04-19T22:57:08.433Z iteration 0 passed in 1943 ms

{
  'BTC/USDT': {
    symbol: 'BTC/USDT',
    base: 'BTC',
    baseRate: 0.001,
    quote: 'USDT',
    quoteRate: 0.001,
    period: 86400000,
    timestamp: undefined,
    datetime: undefined,
    info: {
      market: 'BTCUSDT',
      leverage: 10,
      BTC: { min_amount: '0.0008', max_amount: '200', day_rate: '0.001' },
      USDT: { min_amount: '50', max_amount: '500000', day_rate: '0.001' }
    }
  },
  
2024-04-19T23:00:52.202Z
Node.js: v18.12.0
CCXT v4.3.1
htx.fetchIsolatedBorrowRates ()
2024-04-19T23:00:58.107Z iteration 0 passed in 2113 ms

{
  '1INCH/USDT': {
    symbol: '1INCH/USDT',
    base: '1INCH',
    baseRate: 0.00075,
    quote: 'USDT',
    quoteRate: 0.00027151,
    period: 86400000,
    timestamp: undefined,
    datetime: undefined,
    info: {
      symbol: '1inchusdt',
      currencies: [
        {
          currency: '1inch',
          'interest-rate': '0.00075',
          'min-loan-amt': '24.000000000000000000',
          'max-loan-amt': '1800.000000000000000000',
          'loanable-amt': '0.0',
          'actual-rate': '0.00075'
        },
        {
          currency: 'usdt',
          'interest-rate': '0.00027151',
          'min-loan-amt': '10.000000000000000000',
          'max-loan-amt': '1100.000000000000000000',
          'loanable-amt': '0.0',
          'actual-rate': '0.00027151'
        }
      ]
    }
  },
  

@samgermain
Copy link
Member Author

@carlosmiei It looks like the type import isn't being transpiled, do you know why this isn't happening?

 % py bitmart fetchIsolatedBorrowRates
Traceback (most recent call last):
  File "/Users/samgermain/Documents/CCXT/ccxt/examples/py/cli.py", line 18, in <module>
    import ccxt.pro as ccxtpro
  File "/Users/samgermain/Documents/CCXT/ccxt/python/ccxt/__init__.py", line 87, in <module>
    from ccxt.binance import binance                                      # noqa: F401
  File "/Users/samgermain/Documents/CCXT/ccxt/python/ccxt/binance.py", line 39, in <module>
    class binance(Exchange, ImplicitAPI):
  File "/Users/samgermain/Documents/CCXT/ccxt/python/ccxt/binance.py", line 10397, in binance
    def fetch_cross_borrow_rate(self, code: str, params={}) -> CrossBorrowRate:
NameError: name 'CrossBorrowRate' is not defined

@samgermain
Copy link
Member Author

Unrelated failed build

FAILED gemini (C# ): (explain @ run-tests.js:353)

	C# version: 7.0.17

	[INFO] TESTING  cs {"exchange":"gemini","symbol":"all","isWs":false} 

	[TEST_FAILURE] Exchange can not load markets One or more errors occurred. (gemini The Gemini Exchange is currently undergoing maintenance. Please check https://status.gemini.com/ for more information.) gemini   loadMarkets [] (explain @ run-tests.js:354)

FAIL ["gemini"] (run-tests.js:439)

@samgermain samgermain closed this Apr 23, 2024
@samgermain samgermain reopened this Apr 23, 2024
@samgermain
Copy link
Member Author

Unrelated failed build

FAILED bitmart (Python Async WS): (explain @ run-tests.js:358)

	

	[INFO] TESTING  py {'exchange': 'bitmart', 'symbol': None, 'method': None, 'isWs': True} 

	

	[INFO:MAIN] Exchange loaded 1758 symbols

	[INFO:MAIN] Selected SPOT SYMBOL: BTC/USDT

	[INFO:MAIN] Selected SWAP SYMBOL: BTC/USDT:USDT

	[TEST_FAILURE] [AssertionError] Traceback (most recent call last):

	  File "python/ccxt/test/test_async.py", line 511, in test_safe

	    await self.test_method(method_name, exchange, args, is_public)

	  File "python/ccxt/test/test_async.py", line 454, in test_method

	    await call_method(self.test_files, method_name, exchange, skipped_properties_for_method, args)

	  File "python/ccxt/test/test_async.py", line 191, in call_method

	    return await getattr(test_files[methodName], methodNameToCall)(exchange, skippedProperties, *args)

	  File "/home/travis/build/ccxt/ccxt/python/ccxt/pro/test/Exchange/test_watch_trades_for_symbols.py", line 39, in test_watch_trades_for_symbols

	    test_shared_methods.assert_timestamp_order(exchange, method, symbol, response)

	  File "/home/travis/build/ccxt/ccxt/python/ccxt/test/base/test_shared_methods.py", line 283, in assert_timestamp_order

	    assert comparison, exchange.id + ' ' + method + ' ' + string_value(code_or_symbol) + ' must return a ' + ascending_or_descending + ' sorted array of items by timestamp, but ' + str(current_ts) + ' is opposite with its next ' + str(next_ts) + ' ' + exchange.json(items)

	AssertionError: bitmart watchTradesForSymbols BTC/USDT must return a ascending sorted array of items by timestamp, but 1713835085000 is opposite with its next 1713835084000 [{"info":{"ms_t":1713835085031,"price":"67022.00","s_t":1713835085,"side":"sell","size":"0.00013","symbol":"BTC_USDT"},"id":null,"order":null,"timestamp":1713835085000,"datetime":"2024-04-23T01:18:05.000Z","symbol":"BTC/USDT","type":null,"side":"sell","price":67022.0,"amount":0.00013,"cost":8.71286,"takerOrMaker":null,"fee":null,"fees":[]},{"info":{"ms_t":1713835084967,"price":"67022.00","s_t":1713835084,"side":"buy","size":"0.00013","symbol":"BTC_USDT"},"id":null,"order":null,"timestamp":1713835084000,"datetime":"2024-04-23T01:18:04.000Z","symbol":"BTC/USDT","type":null,"side":"buy","price":67022.0,"amount":0.00013,"cost":8.71286,"takerOrMaker":null,"fee":null,"fees":[]},{"info":{"ms_t":1713835085150,"price":"67022.00","s_t":1713835085,"side":"buy","size":"0.00011","symbol":"BTC_USDT"},"id":null,"order":null,"timestamp":1713835085000,"datetime":"2024-04-23T01:18:05.000Z","symbol":"BTC/USDT","type":null,"side":"buy","price":67022.0,"amount":0.00011,"cost":7.37242,"takerOrMaker":null,"fee":null,"fees":[]},{"info":{"ms_t":1713835085150,"price":"67022.00","s_t":1713835085,"side":"buy","size":"0.00013","symbol":"BTC_USDT"},"id":null,"order":null,"timestamp":1713835085000,"datetime":"2024-04-23T01:18:05.000Z","symbol":"BTC/USDT","type":null,"side":"buy","price":67022.0,"amount":0.00013,"cost":8.71286,"takerOrMaker":null,"fee":null,"fees":[]},{"info":{"ms_t":1713835085224,"price":"67021.99","s_t":1713835085,"side":"sell","size":"0.00290","symbol":"BTC_USDT"},"id":null,"order":null,"timestamp":1713835085000,"datetime":"2024-04-23T01:18:05.000Z","symbol":"BTC/USDT","type":null,"side":"sell","price":67021.99,"amount":0.0029,"cost":194.363771,"takerOrMaker":null,"fee":null,"fees":[]},{"info":{"ms_t":1713835085293,"price":"67022.01","s_t":1713835085,"side":"sell","size":"0.00013","symbol":"BTC_USDT"},"id":null,"order":null,"timestamp":1713835085000,"datetime":"2024-04-23T01:18:05.000Z","symbol":"BTC/USDT","type":null,"side":"sell","price":67022.01,"amount":0.00013,"cost":8.7128613,"takerOrMaker":null,"fee":null,"fees":[]}]

	 bitmart (WS) spot watchTradesForSymbols [["BTC/USDT"]]

	[TEST_FAILURE] bitmart (WS) spot PUBLIC_TESTS Failed methods : watchTradesForSymbols (explain @ run-tests.js:359)
	```

@samgermain
Copy link
Member Author

@carlosmiei carlosmiei merged commit b0ce488 into ccxt:master Apr 28, 2024
2 checks passed
kroitor pushed a commit that referenced this pull request Apr 28, 2024
* chore: new type IsolatedBorrowRate

* refactor: changed BorrowRate type to CrossBorrowRate

* feat(base/exchange): parseIsolatedBorrowRates, parseIsolatedBorrowRate

* feat: new types - CrossBorrowRate, IsolatedBorrowRate

* fetchCrossBorrowRate(s) return type

* fetch(Cross|Isolated)BorrowRate(s) return types

* base/Exchange import CrossBorrowRate

* Exchange.ts removed BorrowRate type

* types.py linting

* fix crossborrowRates transpiling

* bybit minor fix

---------

Co-authored-by: carlosmiei <[email protected]>

[ci skip]
@samgermain samgermain deleted the isolated-borrow-rate branch April 29, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants