Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
parsilver committed Dec 11, 2023
1 parent 121501f commit 3a5b527
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 1 deletion.
2 changes: 1 addition & 1 deletion example/get-my-balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Farzai\Bitkub\ClientBuilder;

$client = ClientBuilder::create()
->setCredentials('2f45daf1214fe9bbcd45995d91d63b6cf998f6d84be58768abb59c94815eb0ef', 'd2465d55764140c7b82c8106cb641007f0a674a33079494cabcabdff483d5982qUVyglzHi1BpKCaVf8CqouDrMbqi')
->setCredentials('YOUR_API_KEY', 'YOUR_SECRET_KEY')
->build();

$market = $client->market();
Expand Down
184 changes: 184 additions & 0 deletions src/Endpoints/MarketEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@

class MarketEndpoint extends AbstractEndpoint
{
/**
* Get user available balances
*
* @response
* {
* "error": 0,
* "result": {
* "THB": {
* "available": 1000,
* "reserved": 0
* },
* "BTC": {
* // ...
* },
* }
* }
*/
public function wallet(): ResponseInterface
{
$config = $this->client->getConfig();
Expand All @@ -17,6 +34,144 @@ public function wallet(): ResponseInterface
->send();
}

/**
* Create a buy order.
*
* sym string The symbol. Please note that the current endpoint requires the symbol thb_btc. However, it will be changed to btc_thb soon and you will need to update the configurations accordingly for uninterrupted API functionality.
* amt float Amount you want to spend with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok)
* rat float Rate you want for the order with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok)
* typ string Order type: limit or market (for market order, please specify rat as 0)
* client_id string your id for reference ( not required )
*
* @param array<{
* sym: string,
* amt: string,
* rat: string,
* typ: string,
* client_id: string,
* }> $params
*
* @response
* {
* "error": 0,
* "result": {
* "id": "1", // order id
* "hash": "fwQ6dnQWQPs4cbatF5Am2xCDP1J", // order hash
* "typ": "limit", // order type
* "amt": 1000, // spending amount
* "rat": 15000, // rate
* "fee": 2.5, // fee
* "cre": 2.5, // fee credit used
* "rec": 0.06666666, // amount to receive
* "ts": 1533834547 // timestamp
* "ci": "input_client_id" // input id for reference
* }
* }
*/
public function placeBid(array $params): ResponseInterface
{
$config = $this->client->getConfig();

return $this->makeRequest('POST', '/api/v3/market/place-bid')
->acceptJson()
->withInterceptor(new GenerateSignatureV3($config))
->withBody($params)
->send();
}

/**
* Create a sell order.
*
* sym string The symbol. Please note that the current endpoint requires the symbol thb_btc. However, it will be changed to btc_thb soon and you will need to update the configurations accordingly for uninterrupted API functionality.
* amt float Amount you want to sell with no trailing zero (e.g. 0.10000000 is invalid, 0.1 is ok)
* rat float Rate you want for the order with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok)
* typ string Order type: limit or market (for market order, please specify rat as 0)
* client_id string your id for reference ( not required )
*
* @param array<{
* sym: string,
* amt: string,
* rat: string,
* typ: string,
* client_id: string,
* }> $params
*
* @response
* {
* "error": 0,
* "result": {
* "id": "1", // order id
* "hash": "fwQ6dnQWQPs4cbatF5Am2xCDP1J", // order hash
* "typ": "limit", // order type
* "amt": 1.000000, // selling amount
* "rat": 15000, // rate
* "fee": 0.0025, // fee
* "cre": 0.0025, // fee credit used
* "rec": 15000, // amount to receive
* "ts": 1533834547 // timestamp
* "ci": "input_client_id" // input id for reference
* }
* }
*/
public function placeAsk(array $params): ResponseInterface
{
$config = $this->client->getConfig();

return $this->makeRequest('POST', '/api/v3/market/place-ask')
->acceptJson()
->withInterceptor(new GenerateSignatureV3($config))
->withBody($params)
->send();
}

/**
* Cancel an open order.
*
* sym string The symbol. Please note that the current endpoint requires the symbol thb_btc. However, it will be changed to btc_thb soon and you will need to update the configurations accordingly for uninterrupted API functionality.
* id string Order id you wish to cancel
* sd string Order side: buy or sell
* hash string Cancel an order with order hash (optional). You don't need to specify sym, id, and sd when you specify order hash.
*
* @param array<{
* sym: string,
* id: string,
* sd: string,
* hash: string,
* }> $params
*
* @response
* {
* "error": 0
* }
*/
public function cancelOrder(array $params): ResponseInterface
{
$config = $this->client->getConfig();

return $this->makeRequest('POST', '/api/v3/market/cancel-order')
->acceptJson()
->withInterceptor(new GenerateSignatureV3($config))
->withBody($params)
->send();
}

/**
* Get balances info: this includes both available and reserved balances.
*
* @response
* {
* "error": 0,
* "result": {
* "THB": {
* "available": 1000,
* "reserved": 0
* },
* "BTC": {
* // ...
* },
* }
* }
*/
public function balances(): ResponseInterface
{
$config = $this->client->getConfig();
Expand All @@ -27,6 +182,35 @@ public function balances(): ResponseInterface
->send();
}

/**
* List all open orders of the given symbol.
* Note : The client_id of this API response is the input body field name client_id , was inputted by the user of APIs.
*
* @param string $sym The symbol (e.g. btc_thb)
*
* @response
* {
* "error": 0,
* "result": [
* {
* "id": "2", // order id
* "hash": "fwQ6dnQWQPs4cbatFSJpMCcKTFR", // order hash
* "side": "SELL", // order side
* "type": "limit", // order type
* "rate": 15000, // rate
* "fee": 35.01, // fee
* "credit": 35.01, // credit used
* "amount": 0.93333334, // amount
* "receive": 14000, // amount to receive
* "parent_id": 1, // parent order id
* "super_id": 1, // super parent order id
* "client_id": "client_id" // client id
* "ts": 1533834844 // timestamp
* }
* // ...
* ]
* }
*/
public function openOrders(string $sym): ResponseInterface
{
$config = $this->client->getConfig();
Expand Down
19 changes: 19 additions & 0 deletions src/Endpoints/UserEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@

class UserEndpoint extends AbstractEndpoint
{
/**
* Check trading credit balance.
*
* @response
* {
* "error": 0,
* "result": 100
* }
*/
public function tradingCredits(): ResponseInterface
{
$config = $this->client->getConfig();

return $this->makeRequest('POST', '/api/v3/user/trading-credits')
->acceptJson()
->withInterceptor(new GenerateSignatureV3($config))
->send();
}

public function userLimits(): ResponseInterface
{
$config = $this->client->getConfig();
Expand Down

0 comments on commit 3a5b527

Please sign in to comment.