Skip to content

Commit

Permalink
add trading
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Aug 20, 2020
1 parent 47b7166 commit 2454d8c
Show file tree
Hide file tree
Showing 4 changed files with 397 additions and 10 deletions.
180 changes: 176 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ Most of the interface is now complete, and the user can continue to extend it ba

#### Installation
```
composer require linwj/huobi
composer require linwj/crex24
```

Support for more request Settings [More](https://github.com/zhouaini528/huobi-php/blob/master/tests/spot/proxy.php#L21)
Support for more request Settings
```php
$huobi=new HuobiSpot();
$crex=new Crex();

//You can set special needs
$huobi->setOptions([
$crex->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,

Expand All @@ -65,3 +65,175 @@ $huobi->setOptions([
]);
```

### Spot API

Market related API [More](https://github.com/zhouaini528/crex24-php/blob/master/tests/market.php)
```php
try {
$result=$crex->market()->getCurrencies();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getInstruments();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getTickers();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getRecentTrades([
'instrument'=>'LTC-BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getOrderBook([
'instrument'=>'LTC-BTC',
'limit'=>10
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getOhlcv([
'instrument'=>'LTC-BTC',
'granularity'=>'30m'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getTradingFeeSchedules();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getWithdrawalFees([
'currency'=>'LTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
```

Accounts related API [More](https://github.com/zhouaini528/crex24-php/blob/master/tests/account.php)
```php
try {
$result=$crex->account()->getBalance([
//'currency'=>'FREE'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->account()->getDepositAddress([
'currency'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->account()->getDepositAddress([
'currency'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->account()->getMoneyTransfers();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
```

Order related API [More](https://github.com/zhouaini528/crex24-php/blob/master/tests/order.php)

```php
try {
$result=$crex->trading()->postPlaceOrder([
'instrument'=>'ETH-BTC',
'side'=>'buy',
'type'=>'limit',
'volume'=>'100',
'price'=>'0.01',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getOrderStatus([
'id'=>'xxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getOrderTrades([
'id'=>'xxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->postCancelOrdersById([
//'id'=>'xxxxxxxxxx'
'id'=>['111111','22222222']
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getOrderHistory();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getTradeHistory();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
```

[More Tests](https://github.com/zhouaini528/crex24-php/tree/master/tests)

[More API](https://github.com/zhouaini528/crex24-php/tree/master/src/Api)


177 changes: 174 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ Crex24 文档地址 [https://docs.crex24.com/trade-api/v2/](https://docs.crex24.
composer require linwj/crex24
```

支持更多的请求设置 [More](https://github.com/zhouaini528/huobi-php/blob/master/tests/spot/proxy.php#L21)
支持更多的请求设置
```php
$huobi=new HuobiSpot();
$crex=new Crex();

//You can set special needs
$huobi->setOptions([
$crex->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,

Expand All @@ -64,3 +64,174 @@ $huobi->setOptions([
//'verify'=>false,
]);
```

### 现货交易 API

Market related API [More](https://github.com/zhouaini528/crex24-php/blob/master/tests/market.php)
```php
try {
$result=$crex->market()->getCurrencies();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getInstruments();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getTickers();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getRecentTrades([
'instrument'=>'LTC-BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getOrderBook([
'instrument'=>'LTC-BTC',
'limit'=>10
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getOhlcv([
'instrument'=>'LTC-BTC',
'granularity'=>'30m'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getTradingFeeSchedules();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->market()->getWithdrawalFees([
'currency'=>'LTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
```

Accounts related API [More](https://github.com/zhouaini528/crex24-php/blob/master/tests/account.php)
```php
try {
$result=$crex->account()->getBalance([
//'currency'=>'FREE'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->account()->getDepositAddress([
'currency'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->account()->getDepositAddress([
'currency'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->account()->getMoneyTransfers();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
```

Order related API [More](https://github.com/zhouaini528/crex24-php/blob/master/tests/order.php)

```php
try {
$result=$crex->trading()->postPlaceOrder([
'instrument'=>'ETH-BTC',
'side'=>'buy',
'type'=>'limit',
'volume'=>'100',
'price'=>'0.01',
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getOrderStatus([
'id'=>'xxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getOrderTrades([
'id'=>'xxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->postCancelOrdersById([
//'id'=>'xxxxxxxxxx'
'id'=>['111111','22222222']
]);
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getOrderHistory();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}

try {
$result=$crex->trading()->getTradeHistory();
print_r($result);
}catch (\Exception $e){
print_r($e->getMessage());
}
```

[More Tests](https://github.com/zhouaini528/crex24-php/tree/master/tests)

[More API](https://github.com/zhouaini528/crex24-php/tree/master/src/Api)
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "linwj/crex",
"name": "linwj/crex24",
"type": "library",
"description": "Crex API Like the official document interface, Support for arbitrary extension.",
"description": "Crex24 API Like the official document interface, Support for arbitrary extension.",
"license": "MIT",
"keywords": ["crex","bitmex", "binance", "okex", "huobi","kucoin","kumex"],
"keywords": ["crex24","bitmex", "binance", "okex", "huobi","kucoin","kumex"],
"authors": [
{
"name": "linwenjun",
Expand Down
Loading

0 comments on commit 2454d8c

Please sign in to comment.