1

i am trying to open and close short positions on FTX using ccxt with python. I do not find any kind of information or examples about how to do this.

Does anyone know how to do that, or has any example on opening and closing short positions using ccxt over FTX?

Thank you so much!

David

dvlt
  • 41
  • 1
  • 3

1 Answers1

1
import ccxt

ftx = ccxt.ftx({
            'enableRateLimit': True,
                "apiKey": "-----------------------",
                "secret": "-----------------------",
            #'headers': {
             #   'FTX-SUBACCOUNT': "----",
            #},
            "hostname": "ftx.com"
        })
response = ftx.set_leverage(1)
print('set_leverage - ', response)

#Long
ftx.create_order('USDT-PERP', 'market', 'buy', 10)

ftx.create_order('USDT-PERP', 'market', 'sell', 10)

#Short
ftx.create_order('USDT-PERP', 'market', 'sell', 10)

ftx.create_order('USDT-PERP', 'market', 'buy', 10)
  • 1
    I would use the unified names like `BTC/USD:USD` [as outlined here](https://docs.ccxt.com/en/latest/manual.html#contract-naming-conventions) – Sam Apr 26 '22 at 11:19