CCXT是一个用于加密货币交易和电子商务的JavaScript/Python/PHP库,支持许多比特币/以太/山寨币交易市场和商家API。
CCXT库用于连接和交易全球的加密货币交易和支付处理服务。它可以快速访问市场数据,用于存储,分析,可视化,指标开发,算法交易,策略回溯测试,机器人编程和相关软件工程。
它旨在供编码人员,开发人员,技术熟练的交易员,数据科学家和金融分析师用于构建交易算法。
示例代码:
'usestrict';constccxt=require('ccxt');(asyncfunction(){letkraken=newccxt.kraken()letbitfinex=newccxt.bitfinex({verbose:true})lethuobipro=newccxt.huobipro()letokcoinusd=newccxt.okcoinusd({apiKey:'YOUR_PUBLIC_API_KEY',secret:'YOUR_SECRET_PRIVATE_KEY',})constexchangeId='binance',exchangeClass=ccxt[exchangeId],exchange=newexchangeClass({'apiKey':'YOUR_API_KEY','secret':'YOUR_SECRET','timeout':30000,'enableRateLimit':true,})console.log(kraken.id,awaitkraken.loadMarkets())console.log(bitfinex.id,awaitbitfinex.loadMarkets())console.log(huobipro.id,awaithuobipro.loadMarkets())console.log(kraken.id,awaitkraken.fetchOrderBook(kraken.symbols[0]))console.log(bitfinex.id,awaitbitfinex.fetchTicker('BTC/USD'))console.log(huobipro.id,awaithuobipro.fetchTrades('ETH/CNY'))console.log(okcoinusd.id,awaitokcoinusd.fetchBalance())//sell1BTC/USDformarketprice,sellabitcoinfordollarsimmediatelyconsole.log(okcoinusd.id,awaitokcoinusd.createMarketSellOrder('BTC/USD',1))//buy1BTC/USDfor$2500,youpay$2500andreceive฿1whentheorderisclosedconsole.log(okcoinusd.id,awaitokcoinusd.createLimitBuyOrder('BTC/USD',1,2500.00))//pass/redefinecustomexchange-specificorderparams:type,amount,priceorwhatever//useacustomordertypebitfinex.createLimitSellOrder('BTC/USD',1,10,{'type':'trailing-stop'})})();
评论