ccxt/ccxt
GitHub: ccxt/ccxt
支持 100 多家加密货币交易所的统一交易 API 库,提供跨平台标准化接口,解决多交易所接入和集成的重复开发问题。
Stars: 42360 | Forks: 8654
# CCXT – CryptoCurrency eXchange Trading Library
[](https://www.npmjs.com/package/ccxt) [](https://npmjs.com/package/ccxt) [](https://pypi.python.org/pypi/ccxt) [](https://www.nuget.org/packages/ccxt) [](https://godoc.org/github.com/ccxt/ccxt/go/v4) [](https://discord.gg/ccxt) [](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [](https://x.com/ccxt_official)
一个支持 JavaScript / TypeScript / Python / C# / PHP / Go 等语言,连接超过 100 个加密货币交易所的 API。
### [安装](#install) · [使用](#usage) · [手册](https://github.com/ccxt/ccxt/wiki) · [常见问题](https://github.com/ccxt/ccxt/wiki/FAQ) · [示例](https://github.com/ccxt/ccxt/tree/master/examples) · [贡献](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md) · [免责声明](#disclaimer) · [社交](#social)
**CCXT** 库用于连接全球的加密货币交易所和支付处理服务并进行交易。它提供了对市场数据的快速访问,可用于数据存储、分析、可视化、指标开发、算法交易、策略回测、机器人编程以及相关的软件工程。
它旨在供**程序员、开发者、具备技术技能的交易者、数据科学家和金融分析师**用于构建交易算法。
当前功能列表:
- 支持许多加密货币交易所 — 即将支持更多
- 完全实现了公共和私有 API
- 提供可选的标准化数据,用于跨交易所分析和套利
- 开箱即用的统一 API,极其易于集成
- 适用于 Node 10.4+、Python 3、PHP 8.1+、netstandard2.0/2.1、Go 1.20+ 以及 Web 浏览器
## 另请参阅
- [](https://www.freqtrade.io) **[Freqtrade](https://www.freqtrade.io)** – 领先的开源加密货币算法交易软件!
- [](https://www.octobot.online) **[OctoBot](https://www.octobot.online)** – 具有高级 Web 界面的加密货币交易机器人。
- [](https://tokenbot.com/?utm_source=github&utm_medium=ccxt&utm_campaign=algodevs) **[TokenBot](https://tokenbot.com/?utm_source=github&utm_medium=ccxt&utm_campaign=algodevs)** – 发现并复制全球最好的算法交易员。
## 认证的加密货币交易所
|logo |id |name |ver |type |certified |pro |discount |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [](https://accounts.binance.com/register?ref=CCXTCOM) | binance | [Binance](https://accounts.binance.com/register?ref=CCXTCOM) | [](https://developers.binance.com/en) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://accounts.binance.com/register?ref=CCXTCOM) |
| [](https://accounts.binance.com/register?ref=CCXTCOM) | binanceusdm | [Binance USDⓈ-M](https://accounts.binance.com/register?ref=CCXTCOM) | [](https://binance-docs.github.io/apidocs/futures/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://accounts.binance.com/register?ref=CCXTCOM) |
| [](https://accounts.binance.com/register?ref=CCXTCOM) | binancecoinm | [Binance COIN-M](https://accounts.binance.com/register?ref=CCXTCOM) | [](https://binance-docs.github.io/apidocs/delivery/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://accounts.binance.com/register?ref=CCXTCOM) |
| [](https://www.bybit.com/invite?ref=XDK12WP) | bybit | [Bybit](https://www.bybit.com/invite?ref=XDK12WP) | [](https://bybit-exchange.github.io/docs/inverse/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](https://www.okx.com/join/CCXTCOM) | okx | [OKX](https://www.okx.com/join/CCXTCOM) | [](https://www.okx.com/docs-v5/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://www.okx.com/join/CCXTCOM) |
| [](https://www.gate.com/share/CCXTGATE) | gate | [Gate](https://www.gate.com/share/CCXTGATE) | [](https://www.gate.com/docs/developers/apiv4/en) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://www.gate.com/share/CCXTGATE) |
| [](https://www.kucoin.com/ucenter/signup?rcode=E5wkqe) | kucoin | [KuCoin](https://www.kucoin.com/ucenter/signup?rcode=E5wkqe) | [](https://docs.kucoin.com) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](https://futures.kucoin.com/?rcode=E5wkqe) | kucoinfutures | [KuCoin Futures](https://futures.kucoin.com/?rcode=E5wkqe) | [](https://docs.kucoin.com) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | bitget | [Bitget](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | [](https://www.bitget.com/api-doc/common/intro) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](https://app.hyperliquid.xyz/) | hyperliquid | [Hyperliquid](https://app.hyperliquid.xyz/) | [](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](https://www.bitmex.com/app/register/NZTR1q) | bitmex | [BitMEX](https://www.bitmex.com/app/register/NZTR1q) | [](https://www.bitmex.com/app/apiOverview) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://www.bitmex.com/app/register/NZTR1q) |
| [](https://bingx.com/invite/OHETOM) | bingx | [BingX](https://bingx.com/invite/OHETOM) | [](https://bingx-api.github.io/docs/) |  | [](https://github.com/ccxt/ccxt/wiki/Cification) | [](https://ccxt.pro) | |
| [](https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223) | htx | [HTX](https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223) | [](https://huobiapi.github.io/docs/spot/v1/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223) |
| [](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | mexc | [MEXC Global](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | [](https://mexcdevelop.github.io/apidocs/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | [](https://developer-pro.bitmart.com/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](http://www.bitmart.com/?r=rQCFLh) |
| [](https://crypto.com/exch/kdacthrnxt) | cryptocom | [Crypto.com](https://crypto.com/exch/kdacthrnxt) | [](https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://crypto.com/exch/kdacthrnxt) |
| [](https://www.coinex.com/register?refer_code=yw5fz) | coinex | [CoinEx](https://www.coinex.com/register?refer_code=yw5fz) | [](https://docs.coinex.com/api/v2) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN) | hashkey | [HashKey Global](https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN) | [](https://hashkeyglobal-apidoc.readme.io/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | |
| [](https://woox.io/register?ref=DIJT0CNL) | woo | [WOO X](https://woox.io/register?ref=DIJT0CNL) | [](https://docs.woox.io/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://woox.io/register?ref=DIJT0CNL) |
| [](https://dex.woo.org/en/trade?ref=CCXT) | woofipro | [WOOFI PRO](https://dex.woo.org/en/trade?ref=CCXT) | [](https://orderly.network/docs/build-on-omnichain/building-on-evm) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) | [](https://dex.woo.org/en/trade?ref=CCXT) |
## 支持的加密货币交易所
CCXT 库目前支持以下 108 个加密货币交易市场和交易 API:
|logo |id |name |ver |type |certified |pro |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|---------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [](undefined) | aftermath | [AftermathFinance](undefined) | [](undefined) |  | | [](https://ccxt.pro) |
| [](https://alpaca.markets) | alpaca | [Alpaca](https://alpaca.markets) | [](https://alpaca.markets/docs/) |  | | [](https://ccxt.pro) |
| [](https://omni.apex.exchange/trade) | apex | [Apex](https://omni.apex.exchange/trade) | [](https://api-docs.pro.apex.exchange) |  | | [](https://ccxt.pro) |
| [](https://arkm.com/register?ref=ccxt) | arkham | [ARKHAM](https://arkm.com/register?ref=ccxt) | [](https://arkm.com/limits-api) |  | | [](https://ccxt.pro) |
| [](https://ascendex.com/en-us/register?inviteCode=EL6BXBQM) | ascendex | [AscendEX](https://ascendex.com/en-us/register?inviteCode=EL6BXBQM) | [](https://ascendex.github.io/ascendex-pro-api/#ascendex-pro-api-documentation) |  | | [](https://ccxt.pro) |
| [](https://www.asterdex.com/en/referral/aA1c2B) | aster | [Aster](https://www.asterdex.com/en/referral/aA1c2B) | [](https://github.com/asterdex/api-docs) |  | | [](https://ccxt.pro) |
| [](https://backpack.exchange/join/ccxt) | backpack | [Backpack](https://backpack.exchange/join/ccxt) | [](https://docs.backpack.exchange/) |  | | [](https://ccxt.pro) |
| [](https://bequant.io/referral/dd104e3bee7634ec) | bequant | [Bequant](https://bequant.io/referral/dd104e3bee7634ec) | [](https://api.bequant.io/) |  | | [](https://ccxt.pro) |
| [](https://b1.run/users/new?code=D3LLBVFT) | bigone | [BigONE](https://b1.run/users/new?code=D3LLBVFT) | [](https://open.big.one/docs/api.html) |  | | |
| [](https://accounts.binance.com/register?ref=CCXTCOM) | binance | [Binance](https://accounts.binance.com/register?ref=CCXTCOM) | [](https://developers.binance.com/en) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
[](https://accounts.binance.com/register?ref=CCXTCOM) | binancecoinm | [Binance COIN-M](https://accounts.binance.com/register?ref=CCXTCOM) | [](https://binance-docs.github.io/apidocs/delivery/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.binance.us/?ref=35005074) | binanceus | [Binance US](https://www.binance.us/?ref=35005074) | [](https://github.com/binance-us/binance-official-api-docs) |  | | [](https://ccxt.pro) |
| [](https://accounts.binance.com/register?ref=CCXTCOM) | binanceusdm | [Binance USDⓈ-M](https://accounts.binance.com/register?ref=CCXTCOM) | [](https://binance-docs.github.io/apidocs/futures/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://bingx.com/invite/OHETOM) | bingx | [BingX](https://bingx.com/invite/OHETOM) | [](https://bingx-api.github.io/docs/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://bit2c.co.il/Aff/63bfed10-e359-420c-ab5a-ad368dab0baf) | bit2c | [Bit2C](https://bit2c.co.il/Aff/63bfed10-e359-420c-ab5a-ad368dab0baf) | [](https://www.bit2c.co.il/home/api) |  | | |
| [](https://bitbank.cc/) | bitbank | [bitbank](https://bitbank.cc/) | [](https://docs.bitbank.cc/) |  | | |
| [](https://ref.bitbns.com/1090961) | bitbns | [Bitbns](https://ref.bitbns.com/1090961) | [](https://bitbns.com/trade/#/api-trading/) |  | | |
| [](https://www.bitfinex.com) | bitfinex | [Bitfinex](https://www.bitfinex.com) | [](https://docs.bitfinex.com/v2/docs/) |  | | [](https://ccxt.pro) |
| [](https://bitflyer.com) | bitflyer | [bitFlyer](https://bitflyer.com) | [](https://lightning.bitflyer.com/docs?lang=en) |  | | |
| [](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | bitget | [Bitget](https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j) | [](https://www.bitget.com/api-doc/common/intro) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.bithumb.com) | bithumb | [Bithumb](https://www.bithumb.com) | [](https://apidocs.bithumb.com) |  | | [](https://ccxt.pro) |
| [](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | [](https://developer-pro.bitmart.com/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.bitmex.com/app/register/NZTR1q) | bitmex | [BitMEX](https://www.bitmex.com/app/register/NZTR1q) | [](https://www.bitmex.com/app/apiOverview) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.bitopro.com) | bitopro | [BitoPro](https://www.bitopro.com) | [](https://github.com/bitoex/bitopro-offical-api-docs/blob/master/v3-1/rest-1/rest.md) |  | | [](https://ccxt.pro) |
| [](https://www.bitrue.com/affiliate/landing?cn=600000&inviteCode=EZWETQE) | bitrue | [Bitrue](https://www.bitrue.com/affiliate/landing?cn=600000&inviteCode=EZWETQE) | [](https://github.com/Bitrue-exchange/bitrue-official-api-docs) |  | | [](https://ccxt.pro) |
| [](https://bitso.com/?ref=itej) | bitso | [Bitso](https://bitso.com/?ref=itej) | [](https://bitso.com/api_info) |  | | |
| [](https://www.bitstamp.net) | bitstamp | [Bitstamp](https://www.bitstamp.net) | [](https://www.bitstamp.net/api) |  | | [](https://ccxt.pro) |
| [](https://bit.team/auth/sign-up?ref=bitboy2023) | bitteam | [BIT.TEAM](https://bit.team/auth/sign-up?ref=bitboy2023) | [](https://bit.team/trade/api/documentation) |  | | |
| [](https://www.bittrade.co.jp/register/?invite_code=znnq3) | bittrade | [BitTrade](https://www.bittrade.co.jp/register/?invite_code=znnq3) | [](https://api-doc.bittrade.co.jp) |  | | [](https://ccxt.pro) |
| [](https://bitvavo.com/?a=24F34952F7) | bitvavo | [Bitvavo](https://bitvavo.com/?a=24F34952F7) | [](https://docs.bitvavo.com/) |  | | [](https://ccxt.pro) |
| [](https://blockchain.com) | blockchaincom | [Blockchain.com](https://blockchain.com) | [](https://api.blockchain.com/v3) |  | | [](https://ccxt.pro) |
| [](https://blofin.com/register?referral_code=f79EsS) | blofin | [BloFin](https://blofin.com/register?referral_code=f79EsS) |](https://blofin.com/docs) |  | | [](https://ccxt.pro) |
| [](https://www.btcbox.co.jp/) | btcbox | [BtcBox](https://www.btcbox.co.jp/) | [](https://blog.btcbox.jp/en/archives/8762) |  | | |
| [](https://btcmarkets.net) | btcmarkets | [BTC Markets](https://btcmarkets.net) | [](https://api.btcmarkets.net/doc/v3) |  | | |
| [](https://www.btcturk.com) | btcturk | [BTCTurk](https://www.btcturk.com) | [](https://github.com/BTCTrader/broker-api-docs) |  | | |
| [](https://bullish.com/) | bullish | [Bullish](https://bullish.com/) | [](https://api.exchange.bullish.com/docs/api/rest/) |  | | [](https://ccxt.pro) |
| [](https://www.bybit.com/invite?ref=XDK12WP) | bybit | [Bybit](https://www.bybit.com/invite?ref=XDK12WP) | [](https://bybit-exchange.github.io/docs/inverse/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://partner.bydfi.com/j/DilWutCI) | bydfi | [BYDFi](https://partner.bydfi.com/j/DilWutCI) | [](https://developers.bydfi.com/en/) |  | | [](https://ccxt.pro) |
| [](https://cex.io/r/0/up105393824/0/) | cex | [CEX.IO](https://cex.io/r/0/up105393824/0/) | [](https://trade.cex.io/docs/) |  | | [](https://ccxt.pro) |
| [](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | coinbase | [Coinbase Advanced](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | [](https://developers.coinbase.com/api/v2) |  | | [](https://ccxt.pro) |
| [](https://coinbase.com/) | coinbaseexchange | [Coinbase Exchange](https://coinbase.com/) | [](https://docs.cloud.coinbase.com/exchange/docs/) |  | | [](https://ccxt.pro) |
| [](https://international.coinbase.com) | coinbaseinternational | [Coinbase International](https://international.coinbase.com) | [](https://docs.cloud.coinbase.com/intx/docs) |  | | [](https://ccxt.pro) |
| [](https://coincheck.com) | coincheck | [coincheck](https://coincheck.com) | [](https://coincheck.com/documents/exchange/api) |  | | |
| [](https://www.coinex.com/register?refer_code=yw5fz) | coinex | [CoinEx](https://www.coinex.com/register?refer_code=yw5fz) | [](https://docs.coinex.com/api/v2) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://coinmate.io?referral=YTFkM1RsOWFObVpmY1ZjMGREQmpTRnBsWjJJNVp3PT0) | coinmate | [CoinMate](https://coinmate.io?referral=YTFkM1RsOWFObVpmY1ZjMGREQmpTRnBsWjJJNVp3PT0) | [](https://coinmate.docs.apiary.io) |  | | |
| [](https://go.coinmetro.com/?ref=crypto24) | coinmetro | [Coinmetro](https://go.coinmetro.com/?ref=crypto24) | [](https://documenter.getpostman.com/view/3653795/SVfWN6KS) |  | | |
| [](https://coinone.co.kr) | coinone | [CoinOne](https://coinone.co.kr) | [](https://doc.coinone.co.kr) |  | | |
| [](https://www.coins.ph/en-ph/register?invite_code=1371062463303277512&broker=9001) | coinsph | [Coins.ph](https://www.coins.ph/en-ph/register?invite_code=1371062463303277512&broker=9001) | [](https://coins-docs.github.io/rest-api) |  | | |
| [](https://www.coinspot.com.au/register?code=PJURCU) | coinspot | [CoinSpot](https://www.coinspot.com.au/register?code=PJURCU) | [](https://www.coinspot.com.au/api) |  | | |
| [](https://crypto.com/exch/kdacthrnxt) | cryptocom | [Crypto.com](https://crypto.com/exch/kdacthrnxt) | [](https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://app.cryptomus.com/signup/?ref=JRP4yj) | cryptomus | [Cryptomus](https://app.cryptomus.com/signup/?ref=JRP4yj) | [](https://doc.cryptomus.com/personal) |  | | |
| [](https://s.deepcoin.com/UzkyODgy) | deepcoin | [DeepCoin](https://s.deepcoin.com/UzkyODgy) | [](https://www.deepcoin.com/docs) |  | | [](https://ccxt.pro) |
| [](https://www.delta.exchange/app/signup/?code=IULYNB) | delta | [Delta Exchange](https://www.delta.exchange/app/signup/?code=IULYNB) | [](https://docs.delta.exchange) |  | | |
| [](https://www.deribit.com/reg-1189.4038) | deribit | [Deribit](https://www.deribit.com/reg-1189.4038) | [](https://docs.deribit.com/v2) |  | | [](https://ccxt.pro) |
| [](https://www.derive.xyz/invite/3VB0B) | derive | [derive](https://www.derive.xyz/invite/3VB0B) | [](https://docs.derive.xyz/docs/) |  | | [](https://ccxt.pro) |
| [](https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp) | digifinex | [DigiFinex](https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp) | [](https://docs.digifinex.com) |  | | |
| [](dydx.trade?ref=ccxt) | dydx | [dYdX](dydx.trade?ref=ccxt) | [](https://docs.dydx.xyz) |  | | [](https://ccxt.pro) |
| [](https://exmo.me/?ref=131685) | exmo | [EXMO](https://exmo.me/?ref=131685) | [](https://exmo.me/en/api_doc?ref=131685) |  | | |
| [](https://fmfw.io/referral/da948b21d6c92d69) | fmfwio | [FMFW.io](https://fmfw.io/referral/da948b21d6c92d69) | [](https://api.fmfw.io/) |  | | |
| [](https://app.foxbit.com.br) | foxbit | [Foxbit](https://app.foxbit.com.br) | [](https://docs.foxbit.com.br) |  | | |
| [](https://www.gate.com/share/CCXTGATE) | gate | [Gate](https://www.gate.com/share/CCXTGATE) | [](https://www.gate.com/docs/developers/apiv4/en) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://gemini.com/) | gemini | [Gemini](https://gemini.com/) | [](https://docs.gemini.com/rest-api) |  | | [](https://ccxt.pro) |
| [](https://grvt.io/?ref=WBLS9D1) | grvt | [GRVT](https://grvt.io/?ref=WBLS9D1) | [](https://api-docs.grvt.io/) |  | | [](https://ccxt.pro) |
| [](https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN) | hashkey | [HashKey Global](https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN) | [](https://hashkeyglobal-apidoc.readme.io/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](hibachi.xyz/r/ZBL2YFWIHU) | hibachi | [Hibachi](hibachi.xyz/r/ZBL2YFWIHU) | [](undefined) |  | | |
| [](https://hitbtc.com/?ref_id=5a5d39a65d466) | hitbtc | [HitBTC](https://hitbtc.com/?ref_id=5a5d39a65d466) | [](https://api.hitbtc.com) |  | | |
| [](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | hollaex | [HollaEx](https://pro.hollaex.com/signup?affiliation_code=QSWA6G) | [](https://apidocs.hollaex.com) |  | | [](https://ccxt.pro) |
| [](https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223) | htx | [HTX](https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223) | [](https://huobiapi.github.io/docs/spot/v1/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://app.hyperliquid.xyz/) | hyperliquid | [Hyperliquid](https://app.hyperliquid.xyz/) | [](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.independentreserve.com) | independentreserve | [Independent Reserve](https://www.independentreserve.com) | [](https://www.independentreserve.com/API) |  | | [](https://ccxt.pro) |
| [](https://indodax.com/ref/testbitcoincoid/1) | indodax | [INDODAX](https://indodax.com/ref/testbitcoincoid/1) | [](https://github.com/btcid/indodax-official-api-docs) |  | | |
| [](https://www.kraken.com) | kraken | [Kraken](https://www.kraken.com) | [](https://docs.kraken.com/rest/) |  | | [](https://ccxt.pro) |
| [](https://futures.kraken.com/) | krakenfutures | [Kraken Futures](https://futures.kraken.com/) | [](https://docs.kraken.com/api/docs/futures-api/trading/market-data/) |  | | [](https://ccxt.pro) |
| [](https://www.kucoin.com/ucenter/signup?rcode=E5wkqe) | kucoin | [KuCoin](https://www.kucoin.com/ucenter/signup?rcode=E5wkqe) | [](https://docs.kucoin.com) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://futures.kucoin.com/?rcode=E5wkqe) | kucoinfutures | [KuCoin Futures](https://futures.kucoin.com/?rcode=E5wkqe) | [](https://docs.kucoin.com) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://latoken.com/invite?r=mvgp2djk) | latoken | [Latoken](https://latoken.com/invite?r=mvgp2djk) | [](https://api.latoken.com) |  | | |
| [](https://www.lbank.com/login/?icode=7QCY) | lbank | [LBank](https://www.lbank.com/login/?icode=7QCY) | [](https://www.lbank.com/en-US/docs/index.html) |  | | [](https://ccxt.pro) |
| [](app.lighter.xyz/?referral=715955W9) | lighter | [Lighter](app.lighter.xyz/?referral=715955W9) | [](https://apidocs.lighter.xyz/) |  | | [](https://ccxt.pro) |
| [](https://www.luno.com/invite/44893A) | luno | [luno](https://www.luno.com/invite/44893A) | [](https://www.luno.com/en/api) |  | | [](https://ccxt.pro) |
| [](https://www.mercadobitcoin.com.br) | mercado | [Mercado Bitcoin](https://www.mercadobitcoin.com.br) | [](https://www.mercadobitcoin.com.br/api-doc) |  | | |
| [](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | mexc | [MEXC Global](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | [](https://mexcdevelop.github.io/apidocs/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://trade.mode.network?ref=MODETRADE) | modetrade | [Mode Trade](https://trade.mode.network?ref=MODETRADE) | [](undefined) |  | | [](https://ccxt.pro) |
| [](https://www.my.okx.com/join/CCXT2023) | myokx | [MyOKX (EEA)](https://www.my.okx.com/join/CCXT2023) | [](https://my.okx.com/docs-v5/en/#overview) |  | | [](https://ccxt.pro) |
| [](https://one.ndax.io/bfQiSL) | ndax | [NDAX](https://one.ndax.io/bfQiSL) | [](https://apidoc.ndax.io/) |  | | [](https://ccxt.pro) |
| [](https://www.novadax.com.br/?s=ccxt) | novadax | [NovaDAX](https://www.novadax.com.br/?s=ccxt) | [](https://doc.novadax.com/pt-BR/) |  | | |
| [](https://www.okx.com/join/CCXTCOM) | okx | [OKX](https://www.okx.com/join/CCXTCOM) | [](https://www.okx.com/docs-v5/en/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.app.okx.com/join/CCXT2023) | okxus | [OKX (US)](https://www.app.okx.com/join/CCXT2023) | [](https://app.okx.com/docs-v5/en/#overview) |  | | [](https://ccxt.pro) |
| [](https://onetrading.com/) | onetrading | [One Trading](https://onetrading.com/) | [](https://docs.onetrading.com) |  | | [](https://ccxt.pro) |
| [](https://ox.fun/register?shareAccountId=5ZUD4a7G) | oxfun | [OXFUN](https://ox.fun/register?shareAccountId=5ZUD4a7G) | [](https://docs.ox.fun/) |  | | [](https://ccxt.pro) |
| [](https://p2pb2b.com?referral=ee784c53) | p2b | [p2b](https://p2pb2b.com?referral=ee784c53) | [](https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md) |  | | [](https://ccxt.pro) |
| [](https://app.pacifica.fi?referral=ccxt) | pacifica | [Pacifica](https://app.pacifica.fi?referral=ccxt) | [](https://docs.pacifica.fi/api-documentation/api/rest-api) |  | | [](https://ccxt.pro) |
| [](https://app.paradex.trade/r/ccxt24) | paradex | [Paradex](https://app.paradex.trade/r/ccxt24) | [](https://docs.api.testnet.paradex.trade/) |  | | [](https://ccxt.pro) |
| [](https://www.paymium.com/page/sign-up?referral=eDAzPoQFMvaAB8sf-qj) | paymium | [Paymium](https://www.paymium.com/page/sign-up?referral=eDAzPoRQFMvaAB8sf-qj) | [](https://github.com/Paymium/api-documentation) |  | | |
| [](https://phemex.com/register?referralCode=EDNVJ) | phemex | [Phemex](https://phemex.com/register?referralCode=EDNVJ) | [](https://phemex-docs.github.io/#overview) |  | | [](https://ccxt.pro) |
| [](https://poloniex.com/signup?c=UBFZJRPJ) | poloniex | [Poloniex](https://poloniex.com/signup?c=UBFZJRPJ) | [](https://api-docs.poloniex.com/spot/) |  | | [](https://ccxt.pro) |
| [](https://tokocrypto.com) | tokocrypto | [Tokocrypto](https://tokocrypto.com) | [](https://www.tokocrypto.com/apidocs/) |  | | |
| [](https://www.toobit.com/en-US/r?i=IFFPy0) | toobit | [Toobit](https://www.toobit.com/en-US/r?i=IFFPy0) | [](https://toobit-docs.github.io/apidocs/spot/v1/en/) |  | | [](https://ccxt.pro) |
| [](https://upbit.com) | upbit | [Upbit](https://upbit.com) | [](https://docs.upbit.com/kr) |  | | [](https://ccxt.pro) |
| [](https://wx.network) | wavesexchange | [Waves.Exchange](https://wx.network) | [](https://docs.wx.network) |  | | |
| [](https://www.weex.com/register?vipCode=qfyh) | weex | [Weex](https://www.weex.com/register?vipCode=qfyh) | [](https://www.weex.com/api-doc) |  | | [](https://ccxt.pro) |
| [](https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963) | whitebit | [WhiteBit](https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963) | [](https://github.com/whitebit-exchange/api-docs) |  | | [](https://ccxt.pro) |
| [](https://woox.io/register?ref=DIJT0CNL) | woo | [WOO X](https://woox.io/register?ref=DIJT0CNL) | [](https://docs.woox.io/) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://dex.woo.org/en/trade?ref=CCXT) | woofipro | [WOOFI PRO](https://dex.woo.org/en/trade?ref=CCXT) | [](https://orderly.network/docs/build-on-omnichain/building-on-evm) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](https://www.xt.com/en/accounts/register?ref=9PTM9VW) | xt | [XT](https://www.xt.com/en/accounts/register?ref=9PTM9VW) | [](https://doc.xt.com/) |  | | [](https://ccxt.pro) |
| [](https://www.yobit.net) | yobit | [YoBit](https://www.yobit.net) | [](https://www.yobit.net/en/api/) |  | | |
| [](https://zaif.jp) | zaif | [Zaif](https://zaif.jp) | [](https://techbureau-api-document.readthedocs.io/ja/latest/index.html) |  | | |
| [](https://www.zebpay.com) | zebpay | [Zebpay](https://www.zebpay.com) | [](https://github.com/zebpay/zebpay-api-references) |  | | |
| [](https://auth.zondaglobal.com/ref/jHlbB4mIkdS1) | zonda | [Zonda](https://auth.zondaglobal.com/ref/jHlbB4mIkdS1) | [](https://docs.zondacrypto.exchange/) |  | | |
上面的列表会定期更新,新的加密市场、交易所、错误修复和 API 端点会定期推出。详情请参阅[手册](https://github.com/ccxt/ccxt/wiki/)。如果您在上面的列表中找不到某个加密货币交易所并希望添加它,请通过在 GitHub 上开启 issue 发送链接或给我们发送电子邮件。
本库采用 [MIT 许可证](https://github.com/ccxt/ccxt/blob/master/LICENSE.txt),这意味着任何开发者都可以完全自由地在其基础上构建商业和开源软件,但使用时需自行承担风险,不作任何担保。
### Builder Code 交易所
|logo |id |名称 |版本 |类型 |认证 |专业版 |
|------------------------------------------------------------------------------------------------------------------------------------------|-------------|------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------:|-------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [](https://www.asterdex.com/en/referral/aA1c2B) | aster | [Aster](https://www.asterdex.com/en/referral/aA1c2B) | [](https://github.com/asterdex/api-docs) |  | | [](https://ccxt.pro) |
| [](https://grvt.io/?ref=WBLS9D1) | grvt | [GRVT](https://grvt.io/?ref=WBLS9D1) | [](https://api-docs.grvt.io/) |  | | [](https://ccxt.pro) |
| [](https://app.hyperliquid.xyz/) | hyperliquid | [Hyperliquid](https://app.hyperliquid.xyz/) | [](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api) |  | [](https://github.com/ccxt/ccxt/wiki/Certification) | [](https://ccxt.pro) |
| [](app.lighter.xyz/?referral=715955W9) | lighter | [Lighter](app.lighter.xyz/?referral=715955W9) | [](https://apidocs.lighter.xyz/) |  | | [](https://ccxt.pro) |
| [](https://app.pacifica.fi?referral=ccxt) | pacifica | [Pacifica](https://app.pacifica.fi?referral=ccxt) | [](https://docs.pacifica.fi/api-documentation/api/rest-api) |  | | [](https://ccxt.pro) |
CCXT 参与了上面列出的交易所的 Builder 计划,这意味着为了支持 CCXT 项目,用户通过 CCXT 使用这些交易所的 API 时,会在交易所费用之上支付一小笔费用 (1 bps)。这是可选的,可以通过设置 `exchange.options['builderFee'] = False` 来禁用。对于所有其他交易所,不收取额外费用,并且在某些情况下,使用 CCXT 会获得折扣或特殊条件。
## 安装说明
安装 CCXT 库最简单的方法是使用包管理器:
- [**NPM** 上的 ccxt](https://www.npmjs.com/package/ccxt) (JavaScript / Node v7.6+)
- [**PyPI** 上的 ccxt](https://pypi.python.org/pypi/ccxt) (Python 3.7.0+)
- [**Packagist/Composer** 上的 ccxt](https://packagist.org/packages/ccxt/ccxt) (PHP 8.1+)
- [**Nuget** 上的 ccxt](https://www.nuget.org/packages/ccxt) (netstandard 2.0)
- [**GO** 上的 ccxt](https://pkg.go.dev/github.com/ccxt/ccxt/go/v4)
本库以一体化模块的实现方式提供,具有最少的依赖和要求:
- JavaScript 中的 [js/](https://github.com/ccxt/ccxt/blob/master/js/)
- Python 中的 [python/](https://github.com/ccxt/ccxt/blob/master/python/) (由 TS 生成)
- PHP 中的 [php/](https://github.com/ccxt/ccxt/blob/master/php/) (由 TS 生成)
- C# 中的 [cs/](https://github.com/ccxt/ccxt/blob/master/cs/) (由 TS 生成)
- Go 中的 [go/](https://github.com/ccxt/ccxt/blob/master/go/) (由 TS 生成)
您也可以从 [ccxt GitHub 仓库](https://github.com/ccxt/ccxt) 将其克隆到您的项目目录中:
```
git clone https://github.com/ccxt/ccxt.git # including 1GB of commit history
# 或
git clone https://github.com/ccxt/ccxt.git --depth 1 # avoid downloading 1GB of commit history
```
### JavaScript (NPM)
JavaScript 版本的 CCXT 可在 Node 和 Web 浏览器中运行。需要 ES6 和 `async/await` 语法支持 (Node 7.6.0+)。使用 Webpack 和 Babel 进行编译时,请确保在您的 `babel-loader` 配置中[未将其排除](https://github.com/ccxt/ccxt/issues/225#issuecomment-331905178)。
[**NPM** 中的 ccxt](https://www.npmjs.com/package/ccxt)
```
npm install ccxt
```
```
//cjs
var ccxt = require ('ccxt')
console.log (ccxt.exchanges) // print all available exchanges
```
```
//esm
import {version, exchanges} from 'ccxt';
console.log(version, Object.keys(exchanges));
```
### JavaScript (用于 `
```
创建一个全局的 `ccxt` 对象:
```
console.log (ccxt.exchanges) // print all available exchanges
```
### Python
[**PyPI** 中的 ccxt](https://pypi.python.org/pypi/ccxt)
```
pip install ccxt
```
```
import ccxt
print(ccxt.exchanges) # print a list of all available exchange classes
```
该库支持在 Python 3.7.0+ 中使用 asyncio 和 async/await 的并发异步模式
```
import ccxt.async_support as ccxt # link against the asynchronous version of ccxt
```
#### orjson 支持
CCXT 也支持使用 `orjson` 进行 JSON 解析,因为它比内置库快得多。在使用 WebSocket 时这一点尤其重要,因为某些交易所会返回需要尽可能快地解析和分发的巨大消息。
但是,`orjson` 默认并未启用,因为并非每个 Python 解释器都支持它。如果您想选择启用,只需在本地环境中安装它 (`pip install orjson`)。CCXT 将检测到安装并自动启用。
#### ECDSA 支持
某些交易所,如 Hyperliquid、Binance 和 Paradex,使用 **ECDSA** 进行请求签名。
默认情况下,CCXT 包含一个纯 Python 的 ECDSA 实现,以确保在所有环境中的兼容性。但是,对于对延迟敏感的应用程序,此实现可能无法满足性能要求。
为了解决这个问题,CCXT 还支持 Coincurve 库,它可以将签名时间从大约 45 毫秒大幅减少到 0.05 毫秒以下。
为了获得最佳性能,我们建议通过以下方式安装 Coincurve:
```
pip install coincurve
```
安装后,CCXT 将自动检测并使用它。
### PHP
[使用 **Packagist/Composer** 安装 PHP 版 ccxt](https://packagist.org/packages/ccxt/ccxt) (PHP 8.1+)
它需要常见的 PHP 模块:
- cURL
- mbstring (强烈建议使用 UTF-8)
- PCRE
- iconv
- gmp
```
include "ccxt.php";
var_dump (\ccxt\Exchange::$exchanges); // print a list of all available exchange classes
```
该库支持在 PHP 8.1+ 中使用 [ReactPHP](https://reactphp.org/) 的工具进行并发异步模式。阅读[手册](https://github.com/ccxt/ccxt/wiki/)了解更多详情。
### .net/C#
[使用 **Nuget** 安装 C# 版 ccxt](https://www.nuget.org/packages/ccxt) (netstandard 2.0 和 netstandard 2.1)
```
using ccxt;
Console.WriteLine(ccxt.Exchanges) // check this later
```
### Go
[使用 **PKG** 安装 GO 版 ccxt](https://pkg.go.dev/github.com/ccxt/ccxt/go/v4)
```
go install github.com/ccxt/ccxt/go/v4@latest
```
```
import "ccxt"
fmt.Println(ccxt.Exchanges)
```
### Docker
您可以将 CCXT 与所有受支持的语言和依赖项一起安装在容器中。如果您想为 CCXT 做贡献(例如,运行构建脚本和测试——请参阅[贡献](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md)文档了解详情),这可能会很有用。
使用 `docker-compose`(在克隆的 CCXT 仓库中):
```
docker-compose run --rm ccxt
```
如果您不打算开发 CCXT,则不需要 Docker 镜像。如果您只是想使用 CCXT——只需将其作为常规包安装到您的项目中即可。
## AI 助手支持
CCXT 为 AI 编程助手 (Claude Code, Cursor, Copilot, Windsurf, Codex 以及其他 30 多个) 提供了特定语言的技能:
```
npx skills add ccxt/ccxt
```
有关更多详细信息,请参阅 [AI 技能文档](https://github.com/ccxt/ccxt/wiki/AI-Skills) 和 [llms.txt](https://raw.githubusercontent.com/ccxt/ccxt/master/llms.txt)。
## 用法
### 介绍
CCXT 库由公共部分和私有部分组成。任何人都可以在安装后立即使用公共部分。公共 API 允许不受限制地访问所有交易市场的公共信息,而无需注册用户帐户或拥有 API 密钥。
公共 API 包括以下内容:
- 市场数据
- 交易品种/交易对
- 价格源(汇率)
- 订单簿
- 交易历史
- 行情
- 用于图表的 OHLC(V)
- 其他公共端点
为了使用私有 API 进行交易,您需要从交易所的网站获取 API 密钥。这通常意味着注册交易所并为您的账户创建 API 密钥。某些交易所需要个人信息或身份证明。有时可能还需要验证。在这种情况下,您需要自行注册,本库不会为您创建账户或 API 密钥。有些交易所公开了用于注册账户的 API 端点,但大多数交易所没有。您必须在其网站上注册并创建 API 密钥。
私有 API 允许以下操作:
- 管理个人账户信息
- 查询账户余额
- 通过下达市价单和限价单进行交易
- 存取法币和加密货币资金
- 查询个人订单
- 获取账本历史
- 在账户之间划转资金
- 使用商户服务
本库为所有交易所实现了完整的公共和私有 REST 和 WebSocket API,支持 TypeScript、JavaScript、PHP 和 Python。
CCXT 库同时支持驼峰命名法(在 TypeScript 和 JavaScript 中首选)和下划线命名法(在 Python 和 PHP 中首选),因此所有方法都可以在任何语言中以任一表示法或编码风格调用。
```
// both of these notations work in JavaScript/Python/PHP
exchange.methodName () // camelcase pseudocode
exchange.method_name () // underscore pseudocode
```
阅读[手册](https://github.com/ccxt/ccxt/wiki/)并查看[示例](https://github.com/ccxt/ccxt/tree/master/examples)以获取更多详细信息。
### JavaScript
**CCXT 现在支持 ESM 和 CJS 模块**
#### CJS
```
// cjs example
'use strict';
const ccxt = require ('ccxt');
(async function () {
let kraken = new ccxt.kraken ()
let bitfinex = new ccxt.bitfinex ({ verbose: true })
let huobipro = new ccxt.huobipro ()
let okcoinusd = new ccxt.okcoin ({
apiKey: 'YOUR_PUBLIC_API_KEY',
secret: 'YOUR_SECRET_PRIVATE_KEY',
})
const exchangeId = 'binance'
, exchangeClass = ccxt[exchangeId]
, exchange = new exchangeClass ({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
})
console.log (kraken.id, await kraken.loadMarkets ())
console.log (bitfinex.id, await bitfinex.loadMarkets ())
console.log (huobipro.id, await huobipro.loadMarkets ())
console.log (kraken.id, await kraken.fetchOrderBook (kraken.symbols[0]))
console.log (bitfinex.id, await bitfinex.fetchTicker ('BTC/USD'))
console.log (huobipro.id, await huobipro.fetchTrades ('ETH/USDT'))
console.log (okcoinusd.id, await okcoinusd.fetchBalance ())
// sell 1 BTC/USD for market price, sell a bitcoin for dollars immediately
console.log (okcoinusd.id, await okcoinusd.createMarketSellOrder ('BTC/USD', 1))
// buy 1 BTC/USD for $2500, you pay $2500 and receive ฿1 when the order is closed
console.log (okcoinusd.id, await okcoinusd.createLimitBuyOrder ('BTC/USD', 1, 2500.00))
// pass/redefine custom exchange-specific order params: type, amount, price or whatever
// use a custom order type
bitfinex.createLimitSellOrder ('BTC/USD', 1, 10, { 'type': 'trailing-stop' })
}) ();
```
#### ESM
```
//esm example
import {version, binance} from 'ccxt';
console.log(version);
const exchange = new binance();
const ticker = await exchange.fetchTicker('BTC/USDT');
console.log(ticker);
```
### Python
```
# coding=utf-8
import ccxt
hitbtc = ccxt.hitbtc({'verbose': True})
bitmex = ccxt.bitmex()
huobipro = ccxt.huobipro()
exmo = ccxt.exmo({
'apiKey': 'YOUR_PUBLIC_API_KEY',
'secret': 'YOUR_SECRET_PRIVATE_KEY',
})
kraken = ccxt.kraken({
'apiKey': 'YOUR_PUBLIC_API_KEY',
'secret': 'YOUR_SECRET_PRIVATE_KEY',
})
exchange_id = 'binance'
exchange_class = getattr(ccxt, exchange_id)
exchange = exchange_class({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
})
hitbtc_markets = hitbtc.load_markets()
print(hitbtc.id, hitbtc_markets)
print(bitmex.id, bitmex.load_markets())
print(huobipro.id, huobipro.load_markets())
print(hitbtc.fetch_order_book(hitbtc.symbols[0]))
print(bitmex.fetch_ticker('BTC/USD'))
print(huobipro.fetch_trades('LTC/USDT'))
print(exmo.fetch_balance())
# 以市价卖出 1 ฿ 并立即获得 $
print(exmo.id, exmo.create_market_sell_order('BTC/USD', 1))
# 限价买入 BTC/EUR,支付 €2500 并在订单成交时获得 ฿1
print(exmo.id, exmo.create_limit_buy_order('BTC/EUR', 1, 2500.00))
# 传递/重新定义交易所特有的自定义订单参数:type、amount、price、flags 等...
kraken.create_market_buy_order('BTC/USD', 1, {'trading_agreement': 'agree'})
```
### PHP
```
include 'ccxt.php';
$poloniex = new \ccxt\poloniex ();
$bittrex = new \ccxt\bittrex (array ('verbose' => true));
$quoinex = new \ccxt\quoinex ();
$zaif = new \ccxt\zaif (array (
'apiKey' => 'YOUR_PUBLIC_API_KEY',
'secret' => 'YOUR_SECRET_PRIVATE_KEY',
));
$hitbtc = new \ccxt\hitbtc (array (
'apiKey' => 'YOUR_PUBLIC_API_KEY',
'secret' => 'YOUR_SECRET_PRIVATE_KEY',
));
$exchange_id = 'binance';
$exchange_class = "\\ccxt\\$exchange_id";
$exchange = new $exchange_class (array (
'apiKey' => 'YOUR_API_KEY',
'secret' => 'YOUR_SECRET',
));
$poloniex_markets = $poloniex->load_markets ();
var_dump ($poloniex_markets);
var_dump ($bittrex->load_markets ());
var_dump ($quoinex->load_markets ());
var_dump ($poloniex->fetch_order_book ($poloniex->symbols[0]));
var_dump ($bittrex->fetch_trades ('BTC/USD'));
var_dump ($quoinex->fetch_ticker ('ETH/EUR'));
var_dump ($zaif->fetch_ticker ('BTC/JPY'));
var_dump ($zaif->fetch_balance ());
// sell 1 BTC/JPY for market price, you pay ¥ and receive ฿ immediately
var_dump ($zaif->id, $zaif->create_market_sell_order ('BTC/JPY', 1));
// buy BTC/JPY, you receive ฿1 for ¥285000 when the order closes
var_dump ($zaif->id, $zaif->create_limit_buy_order ('BTC/JPY', 1, 285000));
// set a custom user-defined id to your order
$hitbtc->create_order ('BTC/USD', 'limit', 'buy', 1, 3000, array ('clientOrderId' => '123'));
```
### .net/C#
```
using ccxt; // importing ccxt
namespace Project;
class Project {
public async static Task CreateOrder() {
var exchange = new Binance();
exchange.apiKey = "my api key";
exchange.secret = "my secret";
// always use the capitalized method (CreateOrder instead of createOrder)
var order = await exchange.CreateOrder("BTC/USDT", "limit", "buy", 1, 50);
Console.WriteLine("Placed Order, order id: " + order.id);
}
}
```
### Go
```
package main
import (
"github.com/ccxt/ccxt/go/v4/go"
"fmt"
)
func main() {
exchange := ccxt.NewBinance(map[string]interface{}{
"apiKey": "MY KEY",
"secret": "MY SECRET",
})
orderParams := map[string]interface{}{
"clientOrderId": "myOrderId68768678",
}
exchange.LoadMarkets()
order, err := exchange.CreateOrder("BTC/USDT", "limit", "buy", 0.001, ccxt.WithCreateOrderPrice(6000), ccxt.WithCreateOrderParams(orderParams))
if err != nil {
if ccxtError, ok := err.(*ccxt.Error); ok {
if ccxtError.Type == "InvalidOrder" {
fmt.Println("Invalid order")
} else {
fmt.Println("Some other error")
}
}
} else {
fmt.Println(*order.Id)
}
// fetching OHLCV
ohlcv, err := exchange.FetchOHLCV("BTC/USDT", ccxt.WithFetchOHLCVTimeframe("5m"), ccxt.WithFetchOHLCVLimit(100))
if err != nil {
fmt.Println("Error: ", err)
} else {
fmt.Println("Got OHLCV!")
}
}
```
#### 可选参数
与 Javascript/Python/PHP/C# 不同,Go 不支持像 `function a(optional = false)` 这样的“传统”可选参数。然而,CCXT 的语言和结构中有一些方法带有可选参数,并且由于 Go 语言是从 Typescript 源代码转译而来的,我们必须找到一种表示它们的方法。
我们决定采用(一语双关)Option 结构体和 `WithX` 方法。
例如,这个 `FetchMyTrades` 函数支持 4 个不同的“可选”参数:symbol、since、limit 和 params。
```
func (this *Binance) FetchMyTrades(options ...FetchMyTradesOptions) ([]Trade, error)
```
我们可以通过这样做来提供它们
```
trades, error := exchange.FetchMyTrades(ccxt.withFetchMyTradesSymbol("BTC/USDT"), ccxt.WithFetchOHLCVLimit(5), ccxt.WithFetchMyTradesParams(orderParams))
```
最后,仅仅因为函数签名规定了像 `symbol` 这样的某些参数是可选的,但这会因交易所而异,您可能需要提供它以避免收到 `SymbolRequired` 错误。
您可以在 `examples/go` 文件夹中查看不同的示例。
## 速率限制
加密货币交易所强制执行速率限制以保护其基础设施,确保所有客户端的公平使用,并防止可能降低其他用户体验性能或可用性的滥用行为。这意味着您不能向交易所发送无限量的请求,必须遵守相应的速率限制。
默认情况下,CCXT 使用**漏桶** 速率限制器来控制传出请求的速度。漏桶速率限制器通过将请求排队并以稳定、固定的速率释放它们来工作。请求的突发会随着时间的推移被平滑处理,而不是立即执行。
但是,如果用户提供 `'rateLimiterAlgorithm': 'rollingWindow'` 选项,ccxt 将从漏桶模型切换到**基于窗口的**速率限制器。基于窗口的限制器强制在固定时间窗口内执行最大请求数(例如,每 X 毫秒 N 个请求)。一旦达到限制,进一步的请求将被延迟,直到当前窗口过期。默认情况下,CCXT 假定 60 秒的窗口,但可以通过提供 `rollingWindowSize: X0000` 毫秒来自定义窗口大小。
示例:
```
exchange = ccxt.binance({
'rateLimiterAlgorithm': 'rollingWindow', # switching to rolling window algorithm
'rollingWindowSize': 5000 # if binance allows X requests per 5 seconds, those requests can be fired in a burst at any time during this window
})
```
## CCXT CLI
阅读文档以获取更多信息和详情:[文档](https://github.com/ccxt/ccxt/tree/master/cli/README.md)
CCXT 还提供了一个命令行界面 (CLI),支持从终端直接与任何受支持的交易所进行交互。您可以快速检查余额、下单或获取交易数据——所有这些都无需编写或执行自定义代码,也无需从头开始构建整个应用程序。这对于简单或对时间敏感的任务(Shell 脚本编写、测试和调试等)特别有用。
### 安装说明
CLI 作为一个 npm 包提供,可以通过执行以下命令进行安装
```
npm i ccxt-cli -g
```
### 用法
您可以使用 `--help` 选项查看 CLI 工作原理的总体概述。该工具允许您通过指定交易所 ID、方法名 和任何必需的参数来调用任何 CCXT 方法。
示例:
```
ccxt binance createOrder BTC/USDT market buy 0.1 // places an order
```
如果您不确定应该提供哪些参数,您可以随时使用 `explain` 命令。
```
ccxt explain createOrder
```
结果:
```
Method: createOrder
Usage:
binance createOrder [price] [params]
Arguments:
- symbol (required) — Market symbol e.g., BTC/USDT
- type (required) — (no description available)
- side (required) — order side e.g., buy or sell
- amount (required) — (no description available)
- price (optional) — Price per unit of asset e.g., 26000.50
- params (optional) — Extra parameters for the exchange e.g., { "recvWindow": 5000 }
```
您可以通过将 API 密钥设置为环境变量(例如:`BINANCE_APIKEY="XXXX"`)或将其添加到位于 `$CACHE/config.json` 的配置文件中来轻松提供 API 密钥。
## 贡献
在进行您希望被代码库采纳的更改之前,请阅读[贡献](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md)文档。此外,请阅读[手册](https://github.com/ccxt/ccxt/wiki)以获取更多详细信息。
## 支持开发团队
我们在这个库的开发上投入了大量的时间。如果 CCXT 让您的生活更轻松,并且您想帮助我们进一步改进它,或者如果您想加速新功能和交易所的开发,请通过打赏来支持我们。我们感谢所有的贡献!
### 赞助商
通过成为赞助商来支持这个项目。
[[成为赞助商](https://opencollective.com/ccxt#sponsor)]
### 支持者
通过成为支持者来支持这个项目。您的头像将显示在此处,并带有指向您网站的链接。
[[成为支持者](https://opencollective.com/ccxt#supporter)]
### 赞助人
感谢我们所有的赞助人]
谢谢!
## 社交
- [](https://twitter.com/ccxt_official) 在 Twitter 上关注我们
- [](https://medium.com/@ccxt) 在 Medium 上阅读我们的博客
- [](https://discord.gg/dhzSKYU) 加入我们的 Discord
- [](https://t.me/ccxt_announcements) Telegram 上的 CCXT 频道(重要公告)
- [](https://t.me/ccxt_chat) Telegram 上的 CCXT 聊天(技术支持)
## Star 历史
[](https://star-history.com/#ccxt/ccxt&Date)
## 免责声明
CCXT 不是一项服务,也不是一台服务器。CCXT 是一个软件。**CCXT 是一款基于 MIT 许可证的免费开源非托管 API 代理软件**。
- **非托管** 意味着 CCXT 不是交易中介,它在任何时候都不持有交易者的资金,交易者安装 CCXT 并使用 CCXT 直接与交易所对话。
- **MIT 许可证** 意味着 CCXT 可以用于任何目的,但使用需自担风险,不作任何担保。
- **API 代理** 意味着 CCXT 的资金来源于交易所 API 代理计划的返佣,并且它是许多交易所的官方 API 代理,所有返佣和相关费用均由交易所完全根据每个合作伙伴交易所制定的相关条款和条件独自处理。
- **免费软件** 意味着 CCXT 是免费使用的,没有隐藏费用,使用 CCXT 时,交易者支付的交易费用与他们直接向交易所支付的费用相同。
- **开源** 意味着任何人都可以使用它,查看代码内部并更改所有内容,包括其他代理。
*CCXT 已加入 Hyperliquid 的 Builder Codes 计划(见公告),并且可能也会使用其推荐代码,该代码为用户在前 2500 万交易量中提供 4% 的费用折扣。*
## 联系我们
商业合作咨询:info@ccxt.trade
标签:API, CMS安全, Go, IPv6支持, JavaScript, OpenVAS, PHP, Python, Ruby工具, TypeScript, 交易所, 代码示例, 加密货币, 区块链, 回测, 套利, 威胁情报, 安全插件, 开发者工具, 开源库, 技术分析, 搜索引擎爬虫, 数字货币, 数据分析, 数据可视化, 无后门, 日志审计, 机器人, 算法交易, 自动交易, 虚拟货币, 逆向工具, 量化交易, 金融市场数据, 金融科技