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

BITGET create order error #22547

Closed
bgparkloop opened this issue May 18, 2024 · 3 comments · Fixed by #22610
Closed

BITGET create order error #22547

bgparkloop opened this issue May 18, 2024 · 3 comments · Fixed by #22610

Comments

@bgparkloop
Copy link

bgparkloop commented May 18, 2024

Operating System

Windows

Programming Languages

Python

CCXT Version

4.3.27

Description

I develop auto trading for bitcoin.
A few month ago, my code was correctly ran but, today error is happening below.
I set the "one-way mode" and position mode "False".
This error is also happening trade type : "market".
How should it fixed?

Error message

Traceback (most recent call last):
  File ".\test2.py", line 26, in <module>
    amount=0.01,
  File "C:\ProgramData\Anaconda3\lib\site-packages\ccxt\bitget.py", line 2345, in create_order
    response = getattr(self, method)(self.extend(request, omitted))
  File "C:\ProgramData\Anaconda3\lib\site-packages\ccxt\base\exchange.py", line 505, in inner
    return entry(_self, **inner_kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\ccxt\base\exchange.py", line 2850, in request
    return self.fetch2(path, api, method, params, headers, body, config, context)
  File "C:\ProgramData\Anaconda3\lib\site-packages\ccxt\base\exchange.py", line 2847, in fetch2
    return self.fetch(request['url'], request['method'], request['headers'], request['body'])
  File "C:\ProgramData\Anaconda3\lib\site-packages\ccxt\base\exchange.py", line 641, in fetch
    skip_further_error_handling = self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
  File "C:\ProgramData\Anaconda3\lib\site-packages\ccxt\bitget.py", line 4029, in handle_errors
    raise ExchangeError(feedback)  # unknown message
ccxt.base.errors.ExchangeError: bitget {"code":"40774","msg":"The order type for unilateral position must also be the unilateral position type.","requestTime":1716038326382,"data":null}

Code

  trade_symbol = 'ETH/USDT:USDT'

api = ccxt.bitget({
    'apiKey': config['BITGET']['API'],
    'secret': config['BITGET']['SECRET_KEY'],
    'password': config['BITGET']['PASSWD'],
    'enableRateLimit': True, # required https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
    'options': {
        'defaultType': 'swap',
        # 'createMarketBuyOrderRequiresPrice': False,
    },})

api.set_position_mode(False, trade_symbol)
api.set_margin_mode('fixed', trade_symbol)

order = api.create_order(symbol=trade_symbol,
                        amount=0.01,
                        type='limit',
                        side='buy',
                        price=3500,
                        )
@carlosmiei
Copy link
Collaborator

Hello @bgparkloop, can you try to provide "oneWayMode": true in params ?

@bgparkloop
Copy link
Author

@carlosmiei
Yes, i did but, showing same error message.

@ttodua
Copy link
Member

ttodua commented May 24, 2024

@bgparkloop after the linked PR is merged, the issue should be gone. however, in future, you will be able to control hedged position mode by passing params = {'hedged': True/False} into create_order?

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

Successfully merging a pull request may close this issue.

3 participants