-
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.
Implements Place Order (limit and market)
- Loading branch information
dve
committed
Jan 24, 2018
1 parent
3d322d1
commit f256378
Showing
9 changed files
with
648 additions
and
0 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
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,11 @@ | ||
<?php | ||
|
||
namespace DVE\CEXApiClient\ConstantHelper; | ||
|
||
class OrderType | ||
{ | ||
const BUY = 'buy'; | ||
const SELL = 'sell'; | ||
const MARKET = 'market'; | ||
const LIMIT = 'limit'; | ||
} |
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,59 @@ | ||
<?php | ||
|
||
namespace DVE\CEXApiClient\Definition\Request; | ||
|
||
class PlaceLimitOrderRequest extends PlaceOrderRequest | ||
{ | ||
/** | ||
* @var float | ||
*/ | ||
private $price; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUri(): string | ||
{ | ||
return '/place_order/'.$this->getSymbol1().'/'.$this->getSymbol2(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMethod(): string | ||
{ | ||
return 'POST'; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getBodyParams(): array | ||
{ | ||
return parent::getBodyParams() + [ | ||
'type' => $this->getType(), | ||
'amount' => $this->getAmount(), | ||
'price' => $this->price | ||
]; | ||
} | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getPrice(): float | ||
{ | ||
return $this->price; | ||
} | ||
|
||
/** | ||
* @param float $price | ||
* @return PlaceLimitOrderRequest | ||
*/ | ||
public function setPrice(float $price): PlaceLimitOrderRequest | ||
{ | ||
$this->price = $price; | ||
return $this; | ||
} | ||
|
||
|
||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace DVE\CEXApiClient\Definition\Request; | ||
|
||
class PlaceMarketOrderRequest extends PlaceOrderRequest | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getUri(): string | ||
{ | ||
return '/place_order/'.$this->getSymbol1().'/'.$this->getSymbol2(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMethod(): string | ||
{ | ||
return 'POST'; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getBodyParams(): array | ||
{ | ||
return parent::getBodyParams() + [ | ||
'type' => $this->getType(), | ||
'amount' => $this->getAmount(), | ||
'order_type' => 'market' | ||
]; | ||
} | ||
|
||
} |
Oops, something went wrong.