-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added helper for checking minimal volume size
- Loading branch information
1 parent
beefc18
commit 45b0610
Showing
4 changed files
with
123 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
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 | ||
|
||
namespace Butschster\Kraken\Exceptions; | ||
|
||
class MinimalVolumeSizeNotFound extends \Exception | ||
{ | ||
|
||
} |
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,65 @@ | ||
<?php | ||
|
||
namespace Butschster\Kraken; | ||
|
||
use Butschster\Kraken\Exceptions\MinimalVolumeSizeNotFound; | ||
use Butschster\Kraken\Objects\Pair; | ||
|
||
class OrderVolume | ||
{ | ||
/** | ||
* Check minimal volume size for selected pair | ||
* | ||
* @param Pair $pair | ||
* @param float $volume | ||
* @return bool | ||
* @throws MinimalVolumeSizeNotFound | ||
*/ | ||
public function checkMinimalSizeForPair(Pair $pair, float $volume): bool | ||
{ | ||
return $this->getMinimalSizeForPair($pair) < $volume; | ||
} | ||
|
||
/** | ||
* Check minimal volume size for selected currency | ||
* | ||
* @param string $currency | ||
* @param float $volume | ||
* @return bool | ||
* @throws MinimalVolumeSizeNotFound | ||
*/ | ||
public function checkMinimalSize(string $currency, float $volume): bool | ||
{ | ||
return $this->getMinimalSize($currency) < $volume; | ||
} | ||
|
||
/** | ||
* Get minimal volume size for selected pair | ||
* | ||
* @param Pair $pair | ||
* @return mixed | ||
* @throws MinimalVolumeSizeNotFound | ||
*/ | ||
public function getMinimalSizeForPair(Pair $pair) | ||
{ | ||
return $this->getMinimalSize($pair->base()); | ||
} | ||
|
||
/** | ||
* Get minimal volume size for selected currency | ||
* | ||
* @param string $currency | ||
* @return mixed | ||
* @throws MinimalVolumeSizeNotFound | ||
*/ | ||
public function getMinimalSize(string $currency) | ||
{ | ||
$minimalSize = config('kraken.minimal_volumes.'.$currency); | ||
|
||
if (is_null($minimalSize)) { | ||
throw new MinimalVolumeSizeNotFound("Minimal volume size for currency [{$currency}] not found."); | ||
} | ||
|
||
return $minimalSize; | ||
} | ||
} |