coinex exchange API 并使用 Curl /BASH 下市价订单加密货币对
coinex exchange API and use Curl /BASH to Place a market order crypto pair
我正在尝试通过在 BASH 环境中应用 curl
在 www.coinex.com 加密货币交易所下市价单。
我使用以下官方指南:
API Invocation Instruction
Place Market Order
我的代码读取输入(amount
、price
、market
、type
、…),通过MD5算法生成登录数据,并发送POST 来自 curl
.
代码:
#!/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
错误:
<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
此外,我使用 VPN 上网。
为什么要在请求中加入 'price'?
配售市场不需要价格,标记将以可能的第一个价格购买
此外,如果我没有错过理解,你应该使用小写字母作为你的对字符串
我成功地解决了以下包的问题(我 运行 它在 Google colab 中):
我正在尝试通过在 BASH 环境中应用 curl
在 www.coinex.com 加密货币交易所下市价单。
我使用以下官方指南:
API Invocation Instruction
Place Market Order
我的代码读取输入(amount
、price
、market
、type
、…),通过MD5算法生成登录数据,并发送POST 来自 curl
.
代码:
#!/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
错误:
<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
此外,我使用 VPN 上网。
为什么要在请求中加入 'price'? 配售市场不需要价格,标记将以可能的第一个价格购买
此外,如果我没有错过理解,你应该使用小写字母作为你的对字符串
我成功地解决了以下包的问题(我 运行 它在 Google colab 中):