Reputation: 11
Hi everyone I'm trying to use Binace's bees and so far everything has been fine, I have already made some purchases and sells using the market order mode, all perfect, now I'm trying to place a Limit order.
but I always get the same answer.
"{"code":-2010,"msg":"Account has insufficient balance for requested action."}"
My wallet consists of two test cryptocurrencies:
BNB -> free 0.07100 | Locked 0
USDT -> free 50.69828637 | Locked 0
I'm trying to make the request like this:
symbol=BNBUSDT&type=LIMIT&timeInForce=GTC&quantity=0.333&price=120.001&side=BUY&recvWindow=5000×tamp=1616195182000
This is my main code and as you can see i set the parameters correctly, what can it be?
$request = [
BinanceEndpointApi::fieldSymbol => 'BNBUSDT',
BinanceEndpointApi::fieldType => 'LIMIT',
BinanceEndpointApi::fieldTimeInForce => 'GTC',
BinanceEndpointApi::fieldQuantity => number_format( (30/120),3),
BinanceEndpointApi::fieldPrice => 120.001,
BinanceEndpointApi::fieldSide => 'BUY'
];
$res = $binance->openClosePosition(BinanceEndpointApi::order, $request);
\Kint::dump($res);
here is the screen shown by kint
This is two method used in a class binace to make request
/**
* @param string $signature
* @return string
*/
private function getSignature(string $signature)
{
return hash_hmac('sha256', $signature, $this->secretKey);
}
/**
* @param string $urlApi
* @param array $request
* @return array|null
*/
public function openClosePosition(string $urlApi,array $request) {
$request['timestamp'] = time() * 1000;
$buildQuery = http_build_query($request);
$signature = $this->getSignature($buildQuery);
if(!empty($buildQuery)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlApi);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $buildQuery . "&signature=" . $signature);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "X-MBX-APIKEY: " . $this->apiKey));
$response = curl_exec($ch);
curl_close($ch);
return [
'request' => $buildQuery,
'response' => $response
];
}else {
return NULL;
}
}
What am I doing wrong?
Upvotes: 1
Views: 1699
Reputation: 11
I solved the problem, I made the same call made yesterday without changing anything, it seems that binance had not immediately updated the status of my wallet.
Upvotes: 1