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

{"code":-2015,"msg":"Invalid API-key, IP Getting with private_post_order_oco (but ID works with everything else) #8089

Closed
cadmufasa opened this issue Dec 6, 2020 · 5 comments
Assignees
Labels

Comments

@cadmufasa
Copy link

  • OS: Linux (Ubuntu)
  • Programming Language version: Python 3.7
  • CCXT version:

Hi, I am working with the Binance TESTNET. I have used this same ID to create LIMIT and MARKET orders with no issue - but - when I try to create an OCO order, I get permission errors.

What am I doing wrong?

TIA

    def futures_open_oco_order ( self, in_symbol : str  = '' , in_side : str = '',  in_amount : float = 0,
            in_stop_price : float = 0, in_limit_price : float = 0, in_last_chance_price : float = 0 ):


[... snip ...]
            # get the IDs together before going any further
            server_params  = {}
            mainLocalID    = t_tradeid.get_unique_id( self.client_id )
            mainXChangeID  = t_tradeid.generate_xchange_id( mainLocalID )
            server_params['newClientOrderId'] = mainXChangeID

            response = self.exchange.fapiPrivate_get_positionside_dual()

            if not (response['dualSidePosition']):
                response = self.exchange.fapiPrivatePostPositionSideDual ({'dualSidePosition':'true'})

            # now set up the account so that it is ISOLATED
            try:
                response = self.exchange.fapiPrivate_post_margintype({ 'symbol': market['id'],
                    'marginType': 'ISOLATED',  })

            except ccxt.ExchangeError as f: # issue similar to the -4046 one above
                 if ( f.args[0].find("-4046") == -1 ): #
                    raise  # (otherwise CONTINUE processing)

[... snip ...]
            # set up variables to be passed in
            symbol  = market['id']

[... snip...]
            retval = self.exchange.private_post_order_oco({
                'symbol': symbol,
                'side': side,
                'quantity': self.exchange.amount_to_precision(symbol, amount),
                'price': self.exchange.currency_to_precision( quote_currency, abs(float( in_last_chance_price ))),
                'stopPrice': self.exchange.currency_to_precision( quote_currency, abs(float(in_stop_price))),
                'stopLimitPrice': self.exchange.currency_to_precision( quote_currency, abs(float( in_limit_price ))),
                'positionSide': self.position_side[side],
                'listClientOrderId' : mainXChangeID,
                'limitClientOrderId': mainXChangeID + '-L',
                'stopClientOrderId' : mainXChangeID + '-S',
            })

[ ... snip ...]

The error I am getting is as follows:

error binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}

The ID works with the LIMIT and MARKET order creation functionalities fine.

@kroitor
Copy link
Member

kroitor commented Dec 6, 2020

Have you checked your API key permissions on the website?

@kroitor kroitor self-assigned this Dec 6, 2020
@kroitor
Copy link
Member

kroitor commented Dec 6, 2020

I don't think Binance's Futures Testnet supports OCO orders:

Screen Shot 2020-12-06 at 22 10 41

As opposed to the Binance's Spot/Margin OCO orders on production:

Screen Shot 2020-12-06 at 22 11 50

I suggest to forward this question to Binance's API support channel on Telegram.
Let us know if the above does not help.

@kroitor kroitor closed this as completed Dec 6, 2020
@cadmufasa
Copy link
Author

Hi and thanks for responding so quickly :)

I followed this information here:
https://dev.binance.vision/t/why-do-i-see-this-error-invalid-api-key-ip-or-permissions-for-action/93

I only saw the place where one could obtain the API KEYs (where one does the trades - I tried to upload a picture but was not successful) - My understanding is that the Testnet does not support Margins at this time - correct? Will try this on the SPOT exchange

Regards.

@kroitor
Copy link
Member

kroitor commented Dec 6, 2020

@cadmufasa

My understanding is that the Testnet does not support Margins at this time - correct? Will try this on the SPOT exchange

Yes, that's correct, however, I'd still recommend to confirm this with Binance's API support channel on Telegram, so that you have the info first-hand.

@2pd
Copy link

2pd commented Dec 7, 2020

Binance support OCO orders on :

  • SPOT: yes for production and testnet
  • Futures: No for production or testnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants