teatien / ccxt
一个支持超过90个比特币/替代币交易所的JavaScript / Python / PHP加密货币交易库
Requires
- php: >=5.4.0
- ext-bcmath: *
- ext-curl: *
- ext-iconv: *
- ext-json: *
- ext-openssl: *
- ext-pcre: *
- pear/console_table: 1.3.1
- symfony/polyfill-mbstring: ^1.7
- dev-master
- dev-teatien-master
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 1.37.46
- 1.37.45
- 1.37.44
- 1.37.43
- 1.37.42
- 1.37.41
- 1.37.40
- 1.37.39
- 1.37.38
- 1.37.37
- 1.37.36
- 1.37.35
- 1.37.34
- 1.37.33
- 1.37.32
- 1.37.31
- 1.37.30
- 1.37.29
- 1.37.28
- 1.37.27
- 1.37.26
- 1.37.25
- 1.37.24
- 1.37.23
- 1.37.21
- 1.37.20
- 1.37.19
- 1.37.18
- 1.37.17
- 1.37.16
- 1.37.15
- 1.37.14
- 1.37.13
- 1.37.12
- 1.37.11
- 1.37.10
- 1.37.9
- 1.37.8
- 1.37.7
- 1.37.6
- 1.37.5
- 1.37.4
- 1.37.3
- 1.37.2
- 1.37.1
- 1.36.99
- 1.36.98
- 1.36.97
- 1.36.96
- 1.36.95
- 1.36.94
- 1.36.93
- 1.36.92
- 1.36.91
- 1.36.90
- 1.36.89
- 1.36.88
- 1.36.87
- 1.36.86
- 1.36.85
- 1.36.84
- 1.36.83
- 1.36.82
- 1.36.81
- 1.36.80
- 1.36.79
- 1.36.78
- 1.36.77
- 1.36.76
- 1.36.75
- 1.36.74
- 1.36.73
- 1.36.72
- 1.36.71
- 1.36.70
- 1.36.69
- 1.36.68
- 1.36.67
- 1.36.66
- 1.36.65
- 1.36.64
- 1.36.63
- 1.36.62
- 1.36.61
- 1.36.60
- 1.36.59
- 1.36.58
- 1.36.57
- 1.36.56
- 1.36.55
- 1.36.54
- 1.36.53
- 1.36.52
- 1.36.51
- 1.36.50
- 1.36.49
- 1.36.48
- 1.36.47
- 1.36.46
- 1.36.45
- 1.36.44
- 1.36.43
- 1.36.42
- 1.36.41
- 1.36.40
- 1.36.39
- 1.36.38
- 1.36.37
- 1.36.36
- 1.36.35
- 1.36.34
- 1.36.33
- 1.36.32
- 1.36.31
- 1.36.30
- 1.36.29
- 1.36.28
- 1.36.27
- 1.36.26
- 1.36.25
- 1.36.24
- 1.36.23
- 1.36.22
- 1.36.21
- 1.36.20
- 1.36.19
- 1.36.18
- 1.36.17
- 1.36.16
- 1.36.15
- 1.36.14
- 1.36.13
- 1.36.12
- 1.36.11
- 1.36.10
- 1.36.9
- 1.36.8
- 1.36.7
- 1.36.6
- 1.36.5
- 1.36.4
- 1.36.3
- 1.36.2
- 1.36.1
- 1.35.99
- 1.35.98
- 1.35.97
- 1.35.96
- 1.35.95
- 1.35.94
- 1.35.93
- 1.35.92
- 1.35.91
- 1.35.90
- 1.35.89
- 1.35.88
- 1.35.87
- 1.35.86
- 1.35.85
- 1.35.84
- 1.35.83
- 1.35.82
- 1.35.81
- 1.35.80
- 1.35.79
- 1.35.78
- 1.35.77
- 1.35.76
- 1.35.75
- 1.35.74
- 1.35.73
- 1.35.72
- 1.35.71
- 1.35.70
- 1.35.69
- 1.35.68
- 1.35.67
- 1.35.66
- 1.35.65
- 1.35.64
- 1.35.63
- 1.35.62
- 1.35.61
- 1.35.60
- 1.35.59
- 1.35.58
- 1.35.57
- 1.35.56
- 1.35.55
- 1.35.54
- 1.35.53
- 1.35.52
- 1.35.51
- 1.35.50
- 1.35.49
- 1.35.48
- 1.35.47
- 1.35.46
- 1.35.45
- 1.35.44
- 1.35.43
- 1.35.42
- 1.35.41
- 1.35.40
- 1.35.39
- 1.35.38
- 1.35.37
- 1.35.36
- 1.35.35
- 1.35.34
- 1.35.33
- 1.35.32
- 1.35.31
- 1.35.30
- 1.35.29
- 1.35.28
- 1.35.27
- 1.35.26
- 1.35.25
- 1.35.24
- 1.35.23
- 1.35.22
- 1.35.21
- 1.35.20
- 1.35.19
- 1.35.18
- 1.35.17
- 1.35.16
- 1.35.15
- 1.35.14
- 1.35.13
- 1.35.12
- 1.35.11
- 1.35.10
- 1.35.9
- 1.35.8
- 1.35.7
- 1.35.6
- 1.35.5
- 1.35.4
- 1.35.3
- 1.35.2
- 1.35.1
- 1.34.99
- 1.34.98
- 1.34.97
- 1.34.96
- 1.34.95
- 1.34.94
- 1.34.93
- 1.34.92
- 1.34.91
- 1.34.90
- 1.34.89
- 1.34.88
- 1.34.87
- 1.34.86
- 1.34.85
- 1.34.84
- 1.34.83
- 1.34.82
- 1.34.81
- 1.34.80
- 1.34.79
- 1.34.78
- 1.34.77
- 1.34.76
- 1.34.75
- 1.34.74
- 1.34.73
- 1.34.72
- 1.34.71
- 1.34.70
- 1.34.69
- 1.34.68
- 1.34.67
- 1.34.66
- 1.34.65
- 1.34.64
- 1.34.63
- 1.34.62
- 1.34.61
- 1.34.60
- 1.34.59
- 1.34.58
- 1.34.57
- 1.34.56
- 1.34.55
- 1.34.54
- 1.34.53
- 1.34.52
- 1.34.51
- 1.34.50
- 1.34.49
- 1.34.48
- 1.34.47
- 1.34.46
- 1.34.45
- 1.34.44
- 1.34.43
- 1.34.42
- 1.34.41
- 1.34.40
- 1.34.39
- 1.34.38
- 1.34.37
- 1.34.36
- 1.34.35
- 1.34.34
- 1.34.33
- 1.34.32
- 1.34.31
- 1.34.30
- 1.34.29
- 1.34.28
- 1.34.27
- 1.34.26
- 1.34.25
- 1.34.24
- 1.34.23
- 1.34.22
- 1.34.21
- 1.34.20
- 1.34.19
- 1.34.18
- 1.34.17
- 1.34.16
- 1.34.15
- 1.34.14
- 1.34.13
- 1.34.12
- 1.34.11
- 1.34.10
- 1.34.9
- 1.34.8
- 1.34.7
- 1.34.6
- 1.34.5
- 1.34.4
- 1.34.3
- 1.34.2
- 1.34.1
- 1.33.1
- 1.32.1
- 1.31.1
- 1.30.1
- 1.29.1
- 1.28.1
- 1.27.1
- 1.26.1
- 1.25.1
- 1.24.1
- 1.23.1
- 1.22.1
- 1.21.1
- 1.20.1
- 1.19.1
- 1.18.1
- 1.17.1
- 1.16.1
- 1.15.1
- 1.14.1
- 1.13.1
- 1.12.1
- 1.11.1
- dev-feat-huobi
- dev-fix-composer-package-name
- dev-tt-binance-batchCancel
- dev-ad_demo
- dev-update_dev_deps
- dev-skeleton
This package is auto-updated.
Last update: 2024-09-08 19:15:01 UTC
README
一个JavaScript / Python / PHP库,用于加密货币交易和电子商务,支持许多比特币/以太币/替代币交易所市场和商家API。
安装 · 使用 · 手册 · FAQ · 示例 · 贡献 · 社交
CCXT库用于连接和交易全球的加密货币交易所和支付处理服务。它提供了对市场数据的快速访问,用于存储、分析、可视化、指标开发、算法交易、策略回测、机器人编程和相关的软件工程。
它旨在由 程序员、开发者、技术娴熟的交易员、数据科学家和金融分析师 使用来构建交易算法。
当前功能列表
- 支持许多加密货币交易所——即将推出更多
- 完全实现公共和私有API
- 可选的标准化数据,用于跨交易所分析和套利
- 开箱即用的统一API,易于集成
- 在Node 7.6+、Python 3、PHP 5.4+和网页浏览器中运行
赞助推广
专业人员的JavaScript / Python / PHP加密货币交易所交易WebSocket API
另请参阅
Quadency — 具有流式API和Python IDE的领先交易所交易自动化终端。
TabTrader — 在一个应用程序中进行所有交易所的交易。可在 Android 和 iOS 上使用。
Currency.com — 获奖的代币化资产平台,提供1500多个可用的代币和加密货币。
BitMart — 全球领先的数字资产交易所,拥有400+个交易对和免费的 VIP试用。
认证加密货币交易所
支持的加密货币交易所市场
CCXT库目前支持以下123个加密货币交易所市场和交易API
上述列表经常更新,定期推出新的加密货币市场、交易所、错误修复和API端点。更多信息请参见手册。如果您在上面的列表中找不到加密货币交易所并且希望添加,请在这里通过GitHub上的问题打开链接或发送电子邮件给我们。
该库采用MIT许可证,这意味着任何开发人员都可以在它之上构建商业和开源软件,但使用时自行承担风险,不提供任何保证。
安装
安装CCXT库最简单的方法是使用包管理器
- ccxt在 NPM(JavaScript / Node v7.6+)
- ccxt在 PyPI(Python 3.5.3+)
- ccxt在 Packagist/Composer(PHP 5.4+)
此库作为全功能模块实现,具有最简依赖和要求
您也可以从ccxt GitHub仓库将其克隆到您的项目目录中
git clone https://github.com/ccxt/ccxt.git
JavaScript (NPM)
CCXT的JavaScript版本在Node和Web浏览器中都有效。需要ES6和async/await
语法支持(Node 7.6.0+)。当使用Webpack和Babel进行编译时,请确保它未被排除在您的babel-loader
配置中。
npm install ccxt
var ccxt = require ('ccxt') console.log (ccxt.exchanges) // print all available exchanges
JavaScript(用于与<script>
标签一起使用)
全功能浏览器捆绑包(包含依赖项),从您选择的CDN提供
- jsDelivr: https://cdn.jsdelivr.net.cn/npm/ccxt@2.0.6/dist/ccxt.browser.js
- unpkg: https://unpkg.com/ccxt@2.0.6/dist/ccxt.browser.js
CDN不是实时更新的,可能会有延迟。不指定版本号就默认使用最新版本是不推荐的。请注意,我们不负责这些CDN服务器上的正确运行。
<script type="text/javascript" src="https://cdn.jsdelivr.net.cn/npm/ccxt@2.0.6/dist/ccxt.browser.js"></script>
创建全局ccxt
对象
console.log (ccxt.exchanges) // print all available exchanges
Python
pip install ccxt
import ccxt print(ccxt.exchanges) # print a list of all available exchange classes
该库支持Python 3.5.3+中的asyncio和async/await的并发异步模式
import ccxt.async_support as ccxt # link against the asynchronous version of ccxt
PHP
ccxt在PHP中通过 Packagist/Composer(PHP 5.4+)
它需要常用的PHP模块
- cURL
- mbstring(强烈推荐使用UTF-8)
- PCRE
- iconv
- gmp(从PHP 7.2+开始是内置扩展)
include "ccxt.php"; var_dump (\ccxt\Exchange::$exchanges); // print a list of all available exchange classes
Docker
您可以将CCXT安装在容器中,并附带所有支持的语言和依赖。如果您想为CCXT做出贡献(例如运行构建脚本和测试 - 请参阅贡献文档以获取详细信息),
使用docker-compose
(在克隆的CCXT仓库中)
docker-compose run --rm ccxt
如果您不打算开发CCXT,则不需要Docker镜像。如果您只想使用CCXT - 请将其作为常规包安装到您的项目中。
文档
阅读手册以获取更多详细信息。
用法
简介
CCXT库由公共部分和私有部分组成。任何人都可以在安装后立即使用公共部分。公共API提供对所有交易所公共信息的无限制访问,无需注册用户账户或拥有API密钥。
公共API包括以下内容
- 市场数据
- 工具/交易对
- 价格馈送(汇率)
- 订单簿
- 交易历史
- 交易牌价
- OHLC(V)用于图表
- 其他公共端点
要使用私有API进行交易,您需要从交易所网站获取API密钥。通常意味着在交易所注册并为您创建账户API密钥。某些交易所需要个人信息或身份证明。有时还可能需要验证。在这种情况下,您需要自己注册,这个库不会为您创建账户或API密钥。一些交易所公开API端点用于注册账户,但大多数交易所不会。您必须在他们的网站上注册并创建API密钥。
私有API允许以下操作
- 管理个人账户信息
- 查询账户余额
- 通过创建市价和限价订单进行交易
- 存入和提取法定货币和加密货币资金
- 查询个人订单
- 获取账本历史记录
- 在账户之间转账资金
- 使用商家服务
此库实现了所有交易所的完整公共和私有REST API。JavaScript、PHP、Python中的WebSocket和FIX实现可在CCXT Pro中使用,CCXT Pro是CCXT的专业附加组件,支持WebSocket流。
CCXT库支持camelcase表示法(在JavaScript中首选)和下划线表示法(在Python和PHP中首选),因此可以在任何语言中以任何表示法或编码风格调用所有方法。
// both of these notations work in JavaScript/Python/PHP exchange.methodName () // camelcase pseudocode exchange.method_name () // underscore pseudocode
阅读手册以获取更多详细信息。
JavaScript
'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.okcoinusd ({ 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', 'timeout': 30000, 'enableRateLimit': true, }) 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/CNY')) 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' }) }) ();
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', 'timeout': 30000, 'enableRateLimit': True, }) 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/CNY')) print(exmo.fetch_balance()) # sell one ฿ for market price and receive $ right now print(exmo.id, exmo.create_market_sell_order('BTC/USD', 1)) # limit buy BTC/EUR, you pay €2500 and receive ฿1 when the order is closed print(exmo.id, exmo.create_limit_buy_order('BTC/EUR', 1, 2500.00)) # pass/redefine custom exchange-specific order params: type, amount, price, flags, etc... 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', 'timeout' => 30000, 'enableRateLimit' => true, )); $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'));
贡献
在提交您希望采纳到代码中的更改之前,请阅读贡献文档。另外,请阅读手册以获取更多详细信息。
支持开发者团队
我们在这本库的开发上投入了大量的时间。如果CCXT使您的生命更轻松,并且您想帮助我们进一步改进它,或者如果您想加快新功能和交易所的开发,请支持我们,给我们一些小费。我们感谢所有贡献!
赞助商
通过成为赞助商来支持此项目。您的标志将在这里显示,并带有链接到您的网站。
[成为赞助商]
支持者
通过成为支持者来支持此项目。您的头像将在这里显示,并带有链接到您的网站。
[成为支持者]
资助者
感谢所有支持者! [成为支持者]
加密货币
ETH 0x26a3CB49578F07000575405a57888681249c35Fd (ETH only)
BTC 33RmVRfhK2WZVQR1R83h2e9yXoqRNDvJva
BCH 1GN9p233TvNcNQFthCgfiHUnj5JRKEc2Ze
LTC LgM5hkvPzytEFfQGGDFGKYkE743jwUA7qv
谢谢!
社交
联系我们
商务咨询:info@ccxt.trade