//get current time
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_URL, $url_root."/api/v2/time");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
$time = json_decode($result, true)['serverTime'];
echo "server time: ".$time."\n";
$nonce = uniqid();
$path = "/exchange/api/v2/order";
//$qs = "market=BTCUSDC&side=SELL&type=LIMIT&quantity=.00012&price=35000&secQuantity=.00012";
$qs ="";
$postbody = json_encode(array(
"market"=>"BTCUSDC",
"side"=>"SELL",
"type"=>"LIMIT",
"quantity"=>0.00012,
"price"=>35000,
"minSecQuantity"=>'',
"secQuantity"=>0.00012,
"minQuantity"=>''
)
);
print_r($postbody);
$postlen = strlen($postbody);
//$signature = $api_key."\x00".$time."\x00".$nonce."\x00"."\x00".$org_id."\x00"."\x00"."POST"."\x00".$path."\x00".$qs;
//$signature = $api_key."\x00".$time."\x00".$nonce."\x00"."\x00".$org_id."\x00"."\x00"."POST"."\x00".$path."\x00".$qs."\x00".$postbody;
$signature = $api_key."\x00".$time."\x00".$nonce."\x00"."\x00".$org_id."\x00"."\x00"."POST"."\x00".$path."\x00".$postbody;
$signhash = hash_hmac('sha256', $signature, $api_secret);
//$postlen = strlen($qs);
//echo $postlen .' <br>';
$headers = array(
"X-Time: {$time}",
"X-Nonce: {$nonce}",
"X-Organization-Id: {$org_id}",
"X-Request-Id: {$nonce}",
"X-Auth: {$api_key}:{$signhash}",
"Content-Length: {$postlen}",
);
echo ' <br>headers: <br>';
print_r ($headers);
$curl = curl_init($url_root.$path);
//curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postbody);
//curl_setopt($curl, CURLOPT_URL, $url_root.$path.'?'.$qs);
//curl_setopt($curl, CURLOPT_URL, $url_root.$path);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
if(curl_errno($curl)){
echo 'Err : ' . curl_error($curl) .'<br>';
}
print_r($result);
curl_close($curl);
//if(!$result){echo "Connection Failure";}
//print_r($result);
$info = json_decode($result, true);
echo '<br>info: <br>';
print_r($info);
echo '-- END -- <br>';
?>`
Hello some time ago I debugged here parameters for STANDARD order in Issue #46 . I now try to create FIXED order. In parameters I replaced STANDARD type with FIXED, but that did not work and returns
Unexpected error: 500: Internal Server Error: b'{"error_id":"ab668244-7212-405e-a6d1-2f7b6bf757ed","errors":[{"code":2999,"message":"Generic Server Error"}]}'
Parameters are:
python3 /home/janbenes/nicehash.py -b https://api2.nicehash.com -o dorg-key1 -k a-key-5 -s 3-secret-e -m POST -p "/main/api/v2/hashpower/order" -d '{"market":"EU","algorithm":"SHA256ASICBOOST","amount":"0.001","poolId":"125c3400-e602-4ae1-953c-402298533158","type":"FIXED","marketFactor":"1000000000000000.00000000","displayMarketFactor":"PH","limit":"500","price":"0.0051","displayPriceFactor":"PH","priceFactor":"1000000000000000.00000000"}'