question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code that previously worked with Binance API is no longer working ( ccxt.base.errors.NotSupported: binance does not have a testnet/sandbox URL for sapi endpoints)

See original GitHub issue
  • OS : Ubuntu 19.10 (Linux)
  • Programming Language version: Python 3.7
  • CCXT version: 1.34.38

Hi,

I had some code that was working before but is no longer working now.

The problem seems to be with: exchange.sapi_post_futures_transfer

Before, for me, it worked on both TEST and PROD servers. But now, when running it on TEST, I get the following error: ccxt.base.errors.NotSupported: binance does not have a testnet/sandbox URL for sapi endpoints

Question: Has something changed? If so, what can one do to fix the problem?

TIA

This is how I am connecting to the server:

    def __init__( self, client_id : int = 0, exchange_type : str =  t_bin_param.BIN_TRADE_SPOT, \
                    binance_server_mode : str = 'TEST' ):

        if not ( client_id > 0 and binance_server_mode == 'TEST' or binance_server_mode == 'PROD'):
            raise ValueError ( '-29553', ' data passed in not valid ' + str ( self.binance_server_mode ))

        if not ( exchange_type == t_bin_param.BIN_TRADE_SPOT  or exchange_type == t_bin_param.BIN_TRADE_MARGIN or \
                exchange_type == t_bin_param.BIN_TRADE_FUTURES ):
            raise ValueError ( '-48593', ' data passed in not valid ' + str ( self.binance_server_mode ))

        self.client_id                = client_id
        self.exchange_type     = exchange_type
        self.server_mode        = binance_server_mode

        # get the logoin paramters
        self.__exchange_server_login( )
        return
def __exchange_server_login( self ):

  [... snip ...[
   elif ( self.exchange_type == t_bin_param.BIN_TRADE_FUTURES ):
        self.exchange = ccxt.binance({
            'apiKey': FUTURES_LD_API_KEY, 'secret': FUTURES_LD_API_SECRET, 'timeout': 30000, 'enableRateLimit': True,
            'rateLimit': 250, 'options': { 'defaultType': 'future', 'adjustForTimeDifference': True,},
        })
        logging.info("\t->TRADE ACCOUNT: FUTURES")

    if ( self.server_mode == 'TEST' ):
        self.exchange.set_sandbox_mode(True) # TESTING SANDBOX

    #self.exchange.verbose = True  # UNCOMMENT THIS AFTER LOADING THE MARKETS FOR DEBUGGING
    self.exchange.load_markets()
 [... snitp ...]

Below is the code that is actually running:

            in_symbol          = in_symbol.upper()
            base_currency      = in_symbol.split('/')[0] # like BTC
            quote_currency     = in_symbol.split('/')[1] # like USDT

            code        = quote_currency
            amount      = float( in_amount  )
            currency    = self.exchange.currency(code)

            transfer_value = 3          # assume it is going FROM: SPOT TO: a COIN- futures account
            if ( code == 'USDT' ):
                transfer_value = 1      # assume it is going FROM: SPOT TO: a USDT futures account

            in_symbol = in_symbol.replace("/", "")
            response = self.exchange.sapi_post_futures_transfer({
                'asset' : currency['id'],
                'amount': self.exchange.amount_to_precision( in_symbol,  abs( float( amount)) ),
                'type'  : transfer_value })

            print('Moving', code, 'funds from your spot account to your futures account')

**But am receiving the following error BUT it used to work: **

ERROR: ccxt.base.errors.NotSupported: binance does not have a testnet/sandbox URL for sapi endpoints

ERR-FEC3A96B8   Traceback (most recent call last):
  File "/root/trade_exchange/api_work/trade_binance/bin_kroitor.py", line 306, in money_move_from_futures_to_spot
    'type'  : transfer_value })
  File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 465, in inner
    return entry(_self, **inner_kwargs)
  File "/usr/local/lib/python3.7/dist-packages/ccxt/binance.py", line 2363, in request
    response = self.fetch2(path, api, method, params, headers, body)
  File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 485, in fetch2
    request = self.sign(path, api, method, params, headers, body)
  File "/usr/local/lib/python3.7/dist-packages/ccxt/binance.py", line 2252, in sign
    raise NotSupported(self.id + ' does not have a testnet/sandbox URL for ' + api + ' endpoints')
ccxt.base.errors.NotSupported: binance does not have a testnet/sandbox URL for sapi endpoints

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kroitorcommented, Feb 20, 2021

@dpalmeira thanks for your feedback, appreciate it!

1reaction
dpalmeiracommented, Feb 20, 2021

Yeahh!! It works well again with the v 1.42.10 (I tested your example, plus my original code)

Thank you so much for your help @kroitor it was really a fast fix!

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to tell ccxt to use binance / bybit testnet - Stack Overflow
I want to get candle data from the testnet as well as the main net. I looked at ccxt code and there are...
Read more >
CCXT doesn't load balance on BINANCE : Forums
CCXT doesn't load balance on BINANCE. hi? there is some problems HTTPError Traceback (most recent call last) File ~/.local/lib/ ...
Read more >
freqtrade.exceptions.operationalexception: could not load ...
I previously ran freqtrade in dry run mode, everything worked. Now I've changed some setting in Binance (entered my IP address, as it...
Read more >
Exchange-specific Notes - Freqtrade
Freqtrade is based on CCXT library that supports over 100 cryptocurrency exchange markets and trading APIs. The complete up-to-date list can be found...
Read more >
How to Test My Functions on Binance Testnet
You will be redirected back to the Spot Test Network page. Here you can see your testing API Keys. If you don't have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found