Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

Commit

Permalink
Added ability to query orders of specific types
Browse files Browse the repository at this point in the history
  • Loading branch information
timothymarois committed Nov 19, 2019
1 parent d005932 commit 6138083
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ $alpaca = $polygon->orders()->get('ORDER_ID');
**[Get All Orders](https://docs.alpaca.markets/api-documentation/api-v2/orders/#order-entity)**: Get an array of all open orders

```php
// get all open orders
$alpaca = $polygon->orders()->getAll();

// get orders of specific types
// type: open, closed, or all
$alpaca = $polygon->orders()->getAll($type,$limit,$dateFrom,$dateTo,$direction);
```

**[Cancel An Order](https://docs.alpaca.markets/api-documentation/api-v2/orders/#cancel-all-orders)**: Cancel a specific order
Expand Down
10 changes: 8 additions & 2 deletions src/Account/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ public function replace($id, $options = [])
*
* @return array
*/
public function getAll()
public function getAll($status = 'open', $limit = 50, $from = null, $to = null, $dir = 'desc')
{
return $this->alpaca->request('orders')->contents();
return $this->alpaca->request('orders',[
'status' => $status,
'limit' => $limit,
'after' => $from,
'until' => $to,
'direction' => $dir
])->contents();
}

/**
Expand Down

0 comments on commit 6138083

Please sign in to comment.