shaunr / cexio

该包的最新版本(v1.0)没有可用的许可证信息。

用于与CEX.io API交互的PHP库

该包的规范仓库似乎已消失,因此该包已被冻结。

维护者

详细信息

github.com/ShaunR/php-cexio

v1.0 2017-09-05 20:34 UTC

This package is not auto-updated.

Last update: 2024-02-04 00:05:04 UTC


README

此库提供了一个PHP类,可以轻松与CEX.io API交互。

安装

我建议您使用composer安装此库,但它也可以手动下载并初始化。

composer require shaunr/cexio

用法示例

目前,此库仅支持CEX.io提供的REST API。我怀疑我会支持FIX API,但我计划将来添加WebSocket支持。

REST

<?php

use ShaunR\Cexio\Rest as Cexio;

$cexio = new Cexio([
	'api-endpoint' => 'https://cex.io/api',
	'api-userid' => 'User ID',
	'api-key' => 'API KEY',
	'api-secret' => 'API SECRET'
]);

$balances = $cexio->balance();
foreach ($balances as $symbol => $balance) {
	echo $symbol . " Wallet has " . $balance->available . " available\n";
}

公共函数

公共函数需要任何认证信息,对所有世界开放。如果在初始化此库时传递了API用户ID、API密钥或API密钥,它们将不会发送到CEX.IO。

https://cex.io/rest-api#currency-limits

$cexio->currencyLimits();

https://cex.io/rest-api#ticker

$cexio->ticker('BTC', 'USD');

https://cex.io/rest-api#tickers-all

$cexio->tickers('USD', 'EUR', 'RUB', 'BTC');

https://cex.io/rest-api#lprice

$cexio->lastPrice('BTC', 'USD');

https://cex.io/rest-api#lprice-all

$cexio->lastPrices('BTC', 'USD', 'LTC');

https://cex.io/rest-api#converter

$cexio->convert('BTC', 'USD', [ 'amnt' => 2.5 ]);

https://cex.io/rest-api#chart

$cexio->priceStats('BTC', 'USD', [
	'lastHours' => 24, 
	'maxRespArrSize' = 100
]);

https://cex.io/rest-api#minute-chart

$cexio->ohlcv('20160228', 'BTC', 'USD');

https://cex.io/rest-api#orderbook

$cexio->orderBook('BTC', 'USD', [
	'depth' => 1
]);

https://cex.io/rest-api#trade-history

$cexio->tradeHistory('BTC', 'USD', [
	'since' => 1
]);

私有函数

私有函数需要认证,并限制在CEX.IO API部分下设置的IP地址。初始化此库时,您将需要API用户ID、API密钥和API密钥。它们将始终通过POST请求发送到CEX.IO。您可以在CEX.IO网站上的API部分创建和找到您的认证信息。

https://cex.io/rest-api#balance

$cexio->balance();

https://cex.io/rest-api#open-orders

$cexio->openOrders('BTC', 'USD');

https://cex.io/rest-api#active-order-status

$cexio->activeOrdersStatus([
	'orders_list' => [ 8550492, 8550495, 8550497 ]
]);

https://cex.io/rest-api#archived-orders

$cexio->archivedOrders('BTC', 'USD', [
	'limit' => 100,
	'dateTo' => 1504303313,
	'dateFrom' => 1504302313,
	'lastTxDateTo' => 1504303313,
	'lastTxDateFrom' => 1504302313,
	'status' => 'cd'
]);

https://cex.io/rest-api#cancel-order

$cexio->cancelOrder([
	'id' => 1
]);

https://cex.io/rest-api#cancel-all

$cexio->cancelOrders('BTC', 'USD');

https://cex.io/rest-api#place-order

$cexio->placeOrder('BTC', 'USD', [
	'type' => 'buy',
	'amount' => '1.1',
	'price' => '1.00'
]);

https://cex.io/rest-api#place-instant-order

$cexio->placeOrder('BTC', 'USD', [
	'type' => 'buy',
	'amount' => '1.1',
	'order_type' => 'market'
]);

https://cex.io/rest-api#get-order-details

$cexio->getOrder([ 'id' => 1 ]);

https://cex.io/rest-api#get-order-tx

$cexio->getOrderTx([ 'id' => 1 ]);

https://cex.io/rest-api#get-address

$cexio->getAddress([ 'currency' => 'BTC' ]);

https://cex.io/rest-api#get-fee

$cexio->getMyFee();

https://cex.io/rest-api#cancel-replace

$cexio->cancelReplaceOrder('BTC', 'USD', [
	'type' => 'buy',
	'amount' => 1,
	'price' => 1.50,
	'order_id' => 123456
]);

https://cex.io/rest-api#open-position

$cexio->openPosition('BTC', 'USD', [
	'amount' => '1',
	'symbol' => 'BTC',
	'leverage' => '2',
	'ptype' => 'long',
	'anySlippage' => 'true',
	'eoprice' => '650.3232',
	'stopLossPrice' => '600.3232'
]);

https://cex.io/rest-api#open-positions

$cexio->openPositions('BTC', 'USD');

https://cex.io/rest-api#close-position

$cexio->closePosition('BTC', 'USD', [
	'id' => 104034
]);

捐赠

如果您觉得这个有用,并想表示感激,您的捐赠总是受欢迎的!

  • 比特币 (BTC): 1M5aBCJ217LMinFCTRx1p7JQMgYCsTsJ2F
  • 以太坊 (ETH): 0xe26be81d7933c86c0cf08aa3ccf6b4874bfce830
  • 比特币现金 (BCC/BCH): 16bJ91NZutTmoxaiQXgz7voWVhRaNoFTuY

谢谢!