Ad
Coinex Exchange API And Use Curl /BASH To Place A Market Order Crypto Pair
I am trying to place a market order in the www.coinex.com crypto exchange, by application of the curl
in the BASH environment.
I use following official guidelines:
API Invocation Instruction
Place Market Order
My code reads inputs (amount
, price
, market
, type
,…), generates sign-in data by MD5 algorithm, and sends POST by curl
.
CODE:
#!/bin/bash
#A code to put a market order in the www.coinex.com exchange pairs
#My Access ID in www.coinex.com
access_id="XXXX"
#My secrect Key in www.coinex.com
secret_key="XXXX"
#Request Url
get_url="https://api.coinex.com/v1/order/market"
#Any Amount
amount="1.0"
#Any pair in the Market
marketpair="DOGEUSDT"
#buy or sell
market_type="sell"
#the market price
price="0.041"
#Get servertime, Tonce is a timestamp with a positive Interger that represents the number of milliseconds from Unix epoch to the current time. Error between tonce and server time can not exceed plus or minus 60s
tonce=`curl -X GET https://api.coinex.com/v1/market/ticker/all | jq .data.date`
#authorization code using 32-bit MD5 Algorithm Signature
authorization=`echo -n 'access_id='$access_id'&amount='$amount'&market='$marketpair'&price='$price'&tonce='$tonce'&type='$market_type'&secret_key='$secret_key''|md5sum`
#Convert authorization to UPPERCASE
echo ${authorization^^}
#Place market order
curl -v -H "authorization:'$authorization'" -H "Content-Type: application/json" -X -POST -d '{"access_id":"'$access_id'", "amount": "'$amount'","market":"'$market'","price": "'$price'", "tonce": "'$tonce'", "type": "'$market_type'"}' $get_url
ERROR:
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host 127.0.0.1 left intact
Also, I use a VPN for the internet.
Ad
Answer
I succeeded to solve problem with the following package ( I run it in Google colab):
Ad
source: stackoverflow.com
Related Questions
- → "Box: laravel/homestead-7" producing "sh.exe":box:: command not found"
- → Retrieve user's image selection from website
- → Getting error when using default task in gulp, shows the following error in Gitbash : Task requires a name that is string
- → Homestead Installaton
- → bash: homestead: command not found
- → Troubles with Artisan Tinker encoding
- → How can I access declared variable in bash when executing Laravel Envoy task?
- → coinex exchange API and use Curl /BASH to Place a market order crypto pair
- → Coiex API Curl Could not resolve host
- → How to GREP words, not lines, that contain specific characters, and print entire word
- → Cmd and Git bash have a different result when run a Python code
- → How can I convert ip ranges formatted in ip1-ip2 to cidr format?
- → Pushing to another user's remote repository without the use of pull requests
Ad