-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
huobi spot
github-actions[bot] edited this page Jun 11, 2026
·
2 revisions
# -*- coding: utf-8 -*-
import os
from random import randint
import sys
import ccxt # noqa: E402
print('CCXT Version:', ccxt.__version__)
exchange = ccxt.huobi({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_API_SECRET',
'options': {
'defaultType': 'spot',
},
})
markets = exchange.load_markets()
# exchange.verbose = True # uncomment for debugging purposes if necessary
# creating and canceling a stop-limit buy order
symbol = 'ADA/USDT'
order_type = 'limit'
side = 'buy'
offset = 'open'
amount = 10
price = 0.5
stopPrice = 0.6
operator = 'lte'
params = {'offset': offset, 'stopPrice': stopPrice, 'operator': operator}
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, params={"side": "buy"})
print(open_orders)
#Order cancelation
cancelOrder = exchange.cancel_order(order['id'], symbol)
print(cancelOrder)
except Exception as e:
print(type(e).__name__, str(e))
# creating and canceling a stop limit sell order
symbol = 'ADA/USDT'
order_type = 'limit'
side = 'sell'
offset = 'open'
amount = 10
price = 5
stopPrice = 5
operator = 'gte'
params = {'offset': offset, 'stopPrice': stopPrice, 'operator': operator}
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, params={"side": "sell"})
print(open_orders)
#Order cancelation
cancelOrder = exchange.cancel_order(order['id'], symbol)
print(cancelOrder)
except Exception as e:
print(type(e).__name__, str(e))(If the page is not being rendered for you, you can refer to the mirror at https://docs.ccxt.com/)
- Install
- Examples
- Manual
- CCXT Pro
- Contributing
- Supported Exchanges
- Exchanges By Country
- API Spec By Method
- FAQ
- Changelog
- Awesome
- API Spec by Exchange
- alpaca
- apex
- aster
- backpack
- bigone
- binance
- bingx
- bit2c
- bitbank
- bitbns
- bitfinex
- bitflyer
- bitget
- bithumb
- bitmex
- bitopro
- bitrue
- bitso
- bitstamp
- bitteam
- bittrade
- bitvavo
- blockchaincom
- blofin
- btcbox
- btcmarkets
- btcturk
- btse
- bullish
- bybit
- bydfi
- cex
- coinbase
- coinbaseexchange
- coinbaseinternational
- coincheck
- coinex
- coinmate
- coinone
- coinsph
- coinspot
- cryptocom
- cryptomus
- deepcoin
- delta
- deribit
- derive
- digifinex
- dydx
- extended
- foxbit
- gate
- gemini
- grvt
- hashkey
- hibachi
- hitbtc
- hollaex
- htx
- hyperliquid
- independentreserve
- indodax
- kraken
- krakenfutures
- kucoin
- kucoinfutures
- latoken
- lbank
- lighter
- luno
- mercado
- mexc
- modetrade
- mudrex
- nado
- ndax
- okx
- onetrading
- p2b
- pacifica
- paradex
- paymium
- phemex
- poloniex
- revolutx
- tokocrypto
- toobit
- upbit
- weex
- whitebit
- woo
- woofipro
- xt
- zaif
- zebpay
- API Spec by Prediction Exchange