ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
31.94k stars 7.38k forks source link

Kraken "settle-position" order type in CCXT #7557

Closed serteikas closed 3 years ago

serteikas commented 3 years ago

How to replicate Kraken "settle-position" order type in CCXT?

ordertype = order type:
    market
    limit (price = limit price)
    stop-loss (price = stop loss price)
    take-profit (price = take profit price)
    stop-loss-profit (price = stop loss price, price2 = take profit price)
    stop-loss-profit-limit (price = stop loss price, price2 = take profit price)
    stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price)
    take-profit-limit (price = take profit trigger price, price2 = triggered limit price)
    trailing-stop (price = trailing stop offset)
    trailing-stop-limit (price = trailing stop offset, price2 = triggered limit offset)
    stop-loss-and-limit (price = stop loss price, price2 = limit price)
    **settle-position**

I've tried using additional parameters (ex: "type': 'settle-position') but it did not work. Is this order type supported if so what would be the correct syntax for it?

Thanks.

kroitor commented 3 years ago

You can do that with CCXT using params overrides as described in the Manual:

import ccxt
from pprint import pprint

print('CCXT Version:', ccxt.__version__)

exchange = ccxt.kraken({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
    'enableRateLimit': True,
})

markets = exchange.load_markets()

# exchange.verbose = True  # uncomment for debugging purposes

symbol = 'BTC/USD'
type = 'market'
side = 'buy'  # or 'sell'
amount = YOUR_AMOUNT_HERE
price = None
params = {'ordertype':'settle-position'}

order = exchange.create_order(symbol, type, side, amount, price, params)
pprint(order)

In general, I'd highly recommend reading the entire Manual from top to bottom, that will save your time:

Let us know if the above does not answer your question.