# -*- coding: utf-8 -*-

import os
from random import randint
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


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

exchange = ccxt.huobi({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
    'options': {
        'defaultType': 'future',
    },
})

markets = exchange.load_markets()


# exchange.verbose = True  # uncomment for debugging purposes if necessary

# Example 1: Creating/canceling a stop limit order
symbol = 'ADA/USDT'
order_type = 'buy-limit'
side = 'buy'
offset = 'open'
cli_order_id = randint(0,1000)
amount = 10
price = 0.5
stopPrice = 0.6

params = {'offset': offset, 'client_order_id': cli_order_id, 'stopPrice': stopPrice}

try:

    # Order creation
    order = exchange.create_order(symbol, order_type, side, amount, price, params)
    print(order)

    # List open positions
    open_orders = exchange.fetch_open_orders(symbol)
    # print(open_orders)

    #Order cancelation
    cancelOrder = exchange.cancel_order(order['id'], symbol)
    print(cancelOrder)
except Exception as e:
    print(type(e).__name__, str(e))
@@ -284,66 +284,8 @@
 i(%7B%0A
-    'apiKey': 'YOUR_API_KEY',%0A    'secret': 'YOUR_SECRET',
 %0A   
@@ -326,14 +326,12 @@
 ': '
-future
+spot
 ',%0A 
@@ -647,16 +647,31 @@
 ce = 0.6
+%0Aoperator='lte'
 %0A%0Aparams
@@ -747,16 +747,38 @@
 topPrice
+, 'operator': operator
 %7D%0A%0Atry:%0A
@@ -973,24 +973,48 @@
 rders(symbol
+, params=%7B%22side%22: %22buy%22%7D
 )%0A    # prin

complete first example