Skip to content

Commit

Permalink
add api
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Apr 3, 2019
1 parent c45e85f commit 45db89d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Api/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,28 @@
class Order extends Request
{
/**
*
* Get your orders.
* Parameter Value Description Parameter Type Data Type
symbol Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. query string
You can also send a timeframe, e.g. XBU:monthly. Timeframes are daily, weekly, monthly, quarterly, and biquarterly.
filter Generic table filter. Send JSON key/value pairs, such as {"key": "value"}. You can key on individual fields, and do more advanced querying on timestamps. See the Timestamp Docs for more details. query string
columns Array of column names to fetch. If omitted, will return all columns. query string
Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect.
count Number of results to fetch. query double
start Starting point for results. query double
reverse         If true, will sort results newest first. query boolean
startTime Starting date filter for results. query date-time
endTime Ending date filter for results. query date-time
* */
public function get(array $data=[]){
$this->type='GET';
$this->path='/api/v1/order';

$data['reverse']=$data['reverse'] ?? 'true';
$data['symbol']=$data['symbol'] ?? 'XBTUSD';
$data['count']=$data['count'] ?? '100';


$this->data=$data;

return $this->exec();
Expand All @@ -41,6 +58,9 @@ public function getOne(array $data){
return current($this->get($data));
}

/**
*
* */
public function getAll(array $data){
if(!isset($data['count'])) $data['count']=100;//默认100条

Expand Down
9 changes: 9 additions & 0 deletions tests/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,13 @@
print_r(json_decode($e->getMessage(),true));
}


//Get your orders
try {
$result=$bitmex->order()->get();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

?>
11 changes: 11 additions & 0 deletions tests/position.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,15 @@
print_r(json_decode($e->getMessage(),true));
}

//Choose leverage for a position
try {
$result=$bitmex->position()->postLeverage([
'symbol'=>'XBTUSD',
'leverage'=>0
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

?>

0 comments on commit 45db89d

Please sign in to comment.