forked from zhouaini528/bitmex-php
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
271dcc2
commit b3b7215
Showing
24 changed files
with
292 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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; | ||
|
@@ -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){ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
?> |
Oops, something went wrong.