主页 > imtoken官网下载广告 > CCXT(加密货币

CCXT(加密货币

imtoken官网下载广告 2024-01-06 05:13:30

CCXT (CryptoCurrency eXchange) 交易库,一个 JavaScript/Python/PHP 加密货币交易库比特币支付接口php,支持 100 多种山寨币和比特币交易所。

用于加密货币交易和电子商务的 JavaScript/Python/PHP 库比特币支付接口php,支持许多比特币/以太币/山寨币交易所和商家 API。

CCXT 库用于连接和交易全球的加密货币/山寨币交易所和支付处理服务。 它提供对市场数据的快速访问,用于存储、分析、可视化、指标开发、算法交易、策略回测、机器人编程、网上商店集成和相关软件工程。

它旨在供编码人员、开发人员、熟练交易员、数据科学家和金融分析师用来构建交易算法。

当前功能列表:

认证交易所支持的加密货币交易所

ccxt库目前支持以下131个加密货币交易所和交易API(太多看不下去了,去github就不一一列举了):

上面的列表经常更新,定期引入和添加新的加密货币市场、山寨币交易所、错误修复、API 端点。 有关更多详细信息,请参阅手册,如果您在上面的列表中没有找到加密货币交易市场和/或想添加另一个交易所,请通过 GitHub 或通过电子邮件向我们发送链接,方法是在此处发布问题。

该库受 MIT 许可,这意味着任何开发人员都可以自由构建商业和开源软件,但使用它需要您自担风险且无保证。

安装

安装 ccxt 库的最简单方法是使用内置包管理器:

该库作为具有最小依赖性和要求的一体化模块实现提供:

它也可以从 ccxt GitHub 存储库中克隆到项目目录中:

git clone https://github.com/ccxt/ccxt.git

将此库安装到您的代码中的另一种方法是手动将各个文件复制到您的工作目录中,并使用适合您的环境的语言扩展名。

JavaScript(国家公共管理机构)

CCXT 的 JavaScript 版本可用于 Node 和 Web 浏览器。 需要 ES6 和异步/等待语法支持 (Node 7.6.0+)。 当使用 Webpack 和 Babel 编译时,确保它在你的 babel-loader 配置中。

npm install ccxt

var ccxt = require ('ccxt')
console.log (ccxt.exchanges) // print all available exchanges

JavaScript(用于脚本标签):

多合一浏览器包(包括依赖项),由 unpkg CDN 提供服务,unpkg CDN 是一个快速的全球内容交付网络,适用于 NPM 上的所有内容。

创建一个全局 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

php支付宝app支付接口_比特币交易查询接口_比特币支付接口php

该库支持在 Python 3.5.3+ 中使用 asyncio 和 async/await 的并发异步模式:

import ccxt.async_support as ccxt # link against the asynchronous version of ccxt

PHP

它需要通用的 PHP 模块:

include "ccxt.php";
var_dump (ccxtExchange::$exchanges); // print a list of all available exchange classes

利用

ccxt 库由公共部分和私有部分组成。 任何人都可以在安装后立即使用公共部分,即插即用。 公共 API 提供对来自所有交易市场的公共信息的开放访问,无需注册用户帐户,也无需 API 密钥。

公共 API 包括以下内容:

要使用私有 API 进行交易,您需要从交易市场获取 API 密钥。 这通常意味着注册交易所并使用您的帐户创建 API 密钥。 大多数交易所都需要个人信息或 ID,可能还需要某种验证。 如果你想交易,你需​​要自己注册,这个图书馆不会为你创建账户或 API 密钥。 一些交易 API 在代码本身中公开了用于注册帐户的接口方法,但大多数交易都没有。 您必须在他们的网站上注册并创建一个 API 密钥。

私有 API 允许以下内容:

该库为所有交易所实现了完整的公共和私有 REST API。 JavaScript、PHP、Python 和其他语言的 WebSocket 和 FIX 实现即将推出。

ccxt 库支持驼峰式表示法(在 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 huobi     = new ccxt.huobi ()
    let okcoinusd = new ccxt.okcoinusd ({
        apiKey: 'YOUR_PUBLIC_API_KEY',
        secret: 'YOUR_SECRET_PRIVATE_KEY',
    })
    const exchangeId = 'binance'

php支付宝app支付接口_比特币交易查询接口_比特币支付接口php

, 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 (huobi.id, await huobi.loadMarkets ()) console.log (kraken.id, await kraken.fetchOrderBook (kraken.symbols[0])) console.log (bitfinex.id, await bitfinex.fetchTicker ('BTC/USD')) console.log (huobi.id, await huobi.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

比特币支付接口php_php支付宝app支付接口_比特币交易查询接口

# coding=utf-8
import ccxt
hitbtc = ccxt.hitbtc({'verbose': True})
bitmex = ccxt.bitmex()
huobi  = ccxt.huobi()
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(huobi.id, huobi.load_markets())

比特币支付接口php_php支付宝app支付接口_比特币交易查询接口

print(hitbtc.fetch_order_book(hitbtc.symbols[0])) print(bitmex.fetch_ticker('BTC/USD')) print(huobi.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 ccxtpoloniex ();
$bittrex  = new ccxtbittrex  (array ('verbose' => true));
$quoinex  = new ccxtquoinex   ();
$zaif     = new ccxtzaif     (array (
    'apiKey' => 'YOUR_PUBLIC_API_KEY',
    'secret' => 'YOUR_SECRET_PRIVATE_KEY',
));
$hitbtc   = new ccxthitbtc   (array (
    'apiKey' => 'YOUR_PUBLIC_API_KEY',
    'secret' => 'YOUR_SECRET_PRIVATE_KEY',
));

php支付宝app支付接口_比特币支付接口php_比特币交易查询接口

$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'));

================================================ == =====================