<commit_before># -*- coding: utf-8 -*-

import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt  # noqa: E402


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

kraken.load_markets()

for symbol in kraken.symbols:
    print(
        symbol,
        'Available leverage levels',
        'Buy:', kraken.markets[symbol]['info']['leverage_buy'],
        'Sell:', kraken.markets[symbol]['info']['leverage_sell']
    )

# with create_order all params (including the price=None) are needed!
# the extra param should be "leverage", not "leverage_sell" nor "leverage-sell"
kraken.create_order('BTC/USD', 'market', 'sell', 0.01, None, {'leverage': 3})

# or use a shorthand create_market_sell_order (no "price" param)
kraken.create_market_sell_order('BTC/USD', 0.01, {'leverage': 3})<commit_msg>added a clarifying comment to kraken leveraged order example<commit_after># -*- coding: utf-8 -*-

import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt  # noqa: E402


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

kraken.load_markets()

for symbol in kraken.symbols:
    print(
        symbol,
        'Available leverage levels',
        'Buy:', kraken.markets[symbol]['info']['leverage_buy'],
        'Sell:', kraken.markets[symbol]['info']['leverage_sell']
    )

# THIS IS A KRAKEN-SPECIFIC EXAMPLE
# THE LEVERAGE WILL NOT WORK WITH OTHER EXCHANGES THE SAME WAS
# USE IMPLICIT METHODS FOR MARGIN/LEVERAGED ORDERS WITH OTHER EXCHANGES
# https://github.com/ccxt/ccxt/wiki/Manual#implicit-api-methods

# with create_order all params (including the price=None) are needed!
# the extra param should be "leverage", not "leverage_sell" nor "leverage-sell"
kraken.create_order('BTC/USD', 'market', 'sell', 0.01, None, {'leverage': 3})

# or use a shorthand create_market_sell_order (no "price" param)
kraken.create_market_sell_order('BTC/USD', 0.01, {'leverage': 3})
{'fraction_non_alphanumeric': 0.1522866572371523, 'fraction_numerical': 0.011315417256011316, 'mean_word_length': 4.455012853470437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2262582', 'n_tokens_mistral': 800, 'n_tokens_neox': 758, 'n_words': 179}