I am using the following 'suggested' code to post a test order to Bybit. (https://github.com/bybit-exchange/api-usage-examples/blob/master/api_demo/futures/Encryption.php)
<?php
function get_signed_params($public_key, $secret_key, $params) {
$params = array_merge(['api_key' => $public_key], $params);
ksort($params);
//decode return value of http_build_query to make sure signing by plain parameter string
$signature = hash_hmac('sha256', urldecode(http_build_query($params)), $secret_key);
return http_build_query($params) . "&sign=$signature";
}
$params = [
'symbol' => 'BTCUSDT',
'side' => 'Buy',
'order_type' => 'Limit',
'qty' => '1',
'price' => '30000',
'time_in_force' => 'GoodTillCancel',
'reduce_only' => false,
'close_on_trigger' => false,
'timestamp' => time() * 1000,
'position_idx' => 0
];
//$url = 'https://api-testnet.bybit.com/private/linear/order/create';
$url = 'https://api.bybit.com/v2/private/order/create';
$public_key = 'my_key_is_here_in_my_code';
$secret_key = 'my_secret_key_is_here_in_my_code';
$qs=get_signed_params($public_key, $secret_key, $params);
$curl_url=$url."?".$qs;
$curl=curl_init($curl_url);
echo $curl_url;
curl_setopt($curl, CURLOPT_URL, $curl_url);
#curl_setopt($curl, CURLOPT_POSTFIELDS, $qs);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
#curl_setopt($curl, CURLOPT_PROXY,"127.0.0.1:1087");
$response=curl_exec($curl);
echo $response;
However, I receive the following within the response: validation for 'symbol' failed on the 'symbol' tag"
https://api.bybit.com/v2/private/order/create?api_key=XXXXXX_my_key_XXXXX&close_on_trigger=0&order_type=Limit&position_idx=0&price=30000&qty=1&reduce_only=0&side=Buy&symbol=BTCUSDT&time_in_force=GoodTillCancel×tamp=1647644020000&sign=0e08e9f9be4cf5e4d7b1294d769ab4bf3b5b79ae9f92bab717670b3d95be0672{"ret_code":10001,"ret_msg":"Param validation for 'symbol' failed on the 'symbol' tag","ext_code":"","ext_info":"","result":null,"time_now":"1647644020.389465","rate_limit_status":99,"rate_limit_reset_ms":1647644020387,"rate_limit":100}
Could somebody pls suggest why Bybit is not recognising the 'BTCUSDT' symbol as expected. As everything seems setup on the exchange. Many thanks for your help.
BTCUSDT is not a valid symbol as per the documenation. These are the list of valid symbols that you can use.