Skip to content

Commit

Permalink
more interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Mar 26, 2019
1 parent 271dcc2 commit b3b7215
Show file tree
Hide file tree
Showing 24 changed files with 292 additions and 52 deletions.
49 changes: 32 additions & 17 deletions src/Api/Order.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */

namespace Lin\Bitmex\Api;
Expand All @@ -10,15 +13,9 @@
class Order extends Request
{
/**
* $data=[
'symbol'=>'ADAZ18',
//可选参数 具体参考API https://testnet.bitmex.com/api/explorer/#!/Order/Order_getOrders
* 数量
* 时间
];
*
* */
public function get($data=[]){
public function get(array $data=[]){
$this->type='GET';
$this->path='/api/v1/order';
$this->data=$data;
Expand Down Expand Up @@ -52,48 +49,66 @@ public function getAll(array $data){
return $this->get($data);
}

public function put($data){
public function put(array $data){

}

/**
* $data=[
'symbol'=>'XBTUSD',
'price'=>'10',
'side'=>'sell,buy',该参数可以为空。则价格正负代表做多~做空
'side'=>'Sell Buy',
'orderQty'=>'10',
'ordType'=>'Limit',//limit 限价交易
'ordType'=>'Limit',
'clOrdID' Optional Client ID
More https://www.bitmex.com/api/explorer/#!/Order/Order_new
];
* */
public function post($data){
public function post(array $data){
$this->type='POST';
$this->path='/api/v1/order';
$this->data=$data;

return $this->exec();
}

public function delete($data){
/**
*
* */
public function delete(array $data){
$this->type='DELETE';
$this->path='/api/v1/order';
$this->data=$data;

return $this->exec();
}

public function putBulk($data){
/**
*
* */
public function deleteAll(array $data){
$this->type='DELETE';
$this->path='/api/v1/order/all';
$this->data=$data;

return $this->exec();
}

public function putBulk(array $data){

}

public function postBulk($data){
public function postBulk(array $data){

}

public function postCancelAllAfter($data){
public function postCancelAllAfter(array $data){

}

public function postClosePosition($data){
public function postClosePosition(array $data){

}
}
12 changes: 12 additions & 0 deletions src/Api/Position.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public function get(array $data){

return $this->exec();
}

public function postIsolate(array $data){

}

/**
* 设置账户杠杆
Expand All @@ -31,4 +35,12 @@ public function postLeverage(array $data)

return $this->exec();
}

public function postRiskLimit(array $data){

}

public function postTransferMargin(array $data){

}
}
11 changes: 0 additions & 11 deletions tests/Order.php

This file was deleted.

24 changes: 0 additions & 24 deletions tests/OrderBook.php

This file was deleted.

7 changes: 7 additions & 0 deletions tests/announcement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
8 changes: 8 additions & 0 deletions tests/apikey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/chat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/execution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/funding.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/global_notification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/instrument.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/insurance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/leaderboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
7 changes: 7 additions & 0 deletions tests/liquidation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */
57 changes: 57 additions & 0 deletions tests/order.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */

use Lin\Bitmex\Bitmex;

require __DIR__ .'../../vendor/autoload.php';

//Test API address default https://www.bitmex.com
$key='eLB_l505a_cuZL8Cmu5uo7EP';
$secret='wG3ndMquAPl6c-jHUQNhyBQJKGBwdFenIF2QxcgNKE_g8Kz3';
$host='https://testnet.bitmex.com';

$bitmex=new Bitmex($key,$secret,$host);

//bargaining transaction
try {
$result=$bitmex->order()->post([
'symbol'=>'XBTUSD',
'price'=>'100',
'side'=>'Buy',
'orderQty'=>'1',
'ordType'=>'Limit',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

//track the order
try {
$result=$bitmex->order()->getOne([
'symbol'=>'XBTUSD',
'orderID'=>$result['orderID'],
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

//cancellation of order
try {
$result=$bitmex->order()->delete([
'symbol'=>'XBTUSD',
'orderID'=>$result['orderID'],
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

?>
40 changes: 40 additions & 0 deletions tests/order_book.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */

use Lin\Bitmex\Bitmex;

require __DIR__ .'../../vendor/autoload.php';

//Get market data
//Market parameters can not key and secret
try {
$bitmex=new Bitmex();
$result=$bitmex->orderBook()->get([
'symbol'=>'ETHUSD',
'depth'=>20
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}


//Fatal error capture
try {
$bitmex=new Bitmex('xxx','xxx','host');
$result=$bitmex->orderBook()->get([
'symbol'=>'XBTUSD',
'depth'=>30
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
exit;
}

?>
31 changes: 31 additions & 0 deletions tests/position.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* @author lin <[email protected]>
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/bitmex-php.git
* */

use Lin\Bitmex\Bitmex;

require __DIR__ .'../../vendor/autoload.php';

//Test API address default https://www.bitmex.com
$key='eLB_l505a_cuZL8Cmu5uo7EP';
$secret='wG3ndMquAPl6c-jHUQNhyBQJKGBwdFenIF2QxcgNKE_g8Kz3';
$host='https://testnet.bitmex.com';

$bitmex=new Bitmex($key,$secret,$host);

//bargaining transaction
try {
$result=$bitmex->position()->get([
'symbol'=>'XBTUSD',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

?>
Loading

0 comments on commit b3b7215

Please sign in to comment.