Coinex 现货文档 https://github.com/coinexcom/coinex_exchange_api/wiki
Coinex 期货文档 https://github.com/coinexcom/coinex_perpetual_api
所有接口方法的初始化都与coinex提供的方法相同。更多细节 src/api
大部分的接口已经完成,使用者可以根据我的设计方案继续扩展,欢迎与我一起迭代它。
QQ交流群:668421169
Exchanges 它包含以下所有交易所,强烈推荐使用该SDK。
如果没有找到你想要的交易所SDK你可以告诉我,我来加入它们。
composer require linwj/coinex
Support for more request Settings
//现货初始化
use Lin\Coinex\CoinexExchange;
$coinex=new CoinexExchange();
//期货初始化
use Lin\Coinex\CoinexPerpetual;
$coinex=new CoinexPerpetual();
//支持更多的请求设置
$coinex->setOptions([
//设置请求过期时间,默认60s
'timeout'=>10,
//https://github.com/guzzle/guzzle
'proxy'=>[],
//https://www.php.net/manual/en/book.curl.php
'curl'=>[],
]);
市场 API More
$coinex=new CoinexExchange();
try {
$result=$coinex->market()->getList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinex->market()->getTicker([
'market'=>'BCHBTC'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinex->market()->getDepth([
'market'=>'BCHBTC',
'merge'=>'0.1'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinex->market()->getKline([
'market'=>'BCHBTC',
'type'=>'4hour'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
账户 API More
$coinex=new CoinexExchange($key,$secret);
try {
$result=$coinex->account()->getBalanceInfo([
//You can 'access_id' and 'tonxe' leave it blank
'access_id'=>$key,
'tonce'=>time().'000',
]);
//You can 'access_id' and 'tonxe' leave it blank
$result=$coinex->account()->getBalanceInfo();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
//You can 'access_id' and 'tonxe' leave it blank
$result=$coinex->account()->getBalanceCoinWithdraw();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinex->account()->getCreditInfo();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
交易 API More
$coinex=new CoinexExchange($key,$secret);
try {
//You can 'access_id' and 'tonxe' leave it blank
$result=$coinex->trading()->postMarket([
//'access_id'=>'xxxxx',
//'tonce'=>time().'000',
'market'=>'BCHBTC',
'type'=>'sell',
'amount'=>'1',
'client_id'=>'99999999',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
//You can 'access_id' and 'tonxe' leave it blank
$result=$coinex->trading()->getStatus([
//'access_id'=>'xxxxx',
//'tonce'=>time().'000',
'id'=>'99999999',
'market'=>'BCHBTC',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
//You can 'access_id' and 'tonxe' leave it blank
$result=$coinex->trading()->deletePending([
'id'=>'9999999',
'market'=>'BCHBTC',
'type'=>'0'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
保证金 API More
$coinex=new CoinexExchange($key,$secret);
try {
//You can 'access_id' and 'tonxe' leave it blank
$result=$coinex->margin()->getAccount([
'market'=>'BCHBTC'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinex->margin()->getMarket();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
More Test more
市场 API More
$coinex=new CoinexPerpetual();
try {
$result=$coinex->market()->getList();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->market()->getLimitConfig();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->market()->getTicker([
'market'=>'BTCUSD'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->market()->getTickerAll();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->market()->getDepth([
'market'=>'BTCUSD',
'merge'=>'0.1',
'limit'=>'10'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->market()->getDeals([
'market'=>'BTCUSD',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
订单 API More
$coinex=new CoinexPerpetual($key,$secret);
try {
$result=$coinex->order()->postPutMarket([
'market'=>'BTCUSD',
'side'=>'2',
'amount'=>'10',
'client_id'=>'xxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->order()->postPutStopLimit([
'market'=>'BTCUSD',
'side'=>'2',
'amount'=>'10',
'client_id'=>'xxxxxx',
'stop_type'=>'2',
'stop_price'=>'10000',
'price'=>'9000',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->order()->getStatus([
'market'=>'BTCUSD',
'order_id'=>'9999999',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->order()->postCancel([
'market'=>'BTCUSD',
'order_id'=>'9999999',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
仓位 API More
$coinex=new CoinexPerpetual($key,$secret);
try {
$result=$coinex->position()->getPending([
'market'=>'BTCUSD',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->position()->getFunding([
'market'=>'BTCUSD',
'offset'=>'10',
'limit'=>'10'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
try {
$result=$coinex->position()->postAdjustMargin([
'market'=>'BTCUSD',
'amount'=>'1',
'type'=>'1',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
More Test more