在使用ByBit /Sell时遇到问题。ColdFusion任何帮助都很感激。
https://bybit-exchange.github.io/docs/spot/v3/?console#t-authenticationparameters
POST规则的身份验证:时间戳+ api_key + recv_window + raw_request_body
param_str =“1659073093578T0d98KyVamQ62YBzN85000”{“符号”:"BTCUSDT","orderQty":"0.05","side":"Sell","orderType":"LIMITT","timeInForce":"GTC","orderPrice":"24500","orderLinkId":"spotA0008“}
curl --位置--请求发布“https://api-testnet.bybit.com/spot/v3/private/order”\
-标头“X api-键:{api key}”
-标头X-BAPI-时间戳:1659067662307
-报头“X-BAPI-RECV-窗口:5000”
-标头‘X符号: cc63fb44be4a87f4b7bbd42db012ddacc1c935c3d3ae3e01c3b4be393522c213’
-标题‘内容-类型:应用程序/json’
-原始数据{“符号”:"BTCUSDT“、”orderQty“:"21300”、"orderType":“购买”、“orderType”:“限制”、"timeInForce":"GTC“、"orderPrice":”21300“、"orderLinkId":"spotx006”、"orderCategory":1、"triggerPrice":"21700“}
这是邮政的例子。我的签名没问题。
<cfscript>
apiKey = "#_key#";
apiSecret = "#_s#";
newbody = serializeJSON({
"symbol": "#symb#",
"orderQty":"#qty#",
"side": "#side#",
"orderType": "#type#"
});
ts_key_str = #unixdatetimeNow.getTime()# & '#apikey#' & '5000';
str_to_sign = #unixdatetimeNow.getTime()# & '#apikey#' & '5000' & '#newbody#';
HMAC = hmac(str_to_sign, apiSecret, "HMACSHA256");
</cfscript>
<cfhttp url="#base_api##req_path#" method="POST" result="result" charset="utf-8">
<cfhttpparam type="body" value="#newbody#">
<cfhttpparam type="HEADER" name="Content_Type" value="application/json">
<cfhttpparam type="header" name="X-BAPI-SIGN-TYPE" value="2">
<cfhttpparam type="header" name="X-BAPI-API-KEY" value="#_key#">
<cfhttpparam type="header" name="X-BAPI-RECV-WINDOW" value="5000">
<cfhttpparam type="header" name="X-BAPI-SIGN" value="#lhmac#">
<cfhttpparam type="header" name="X-BAPI-TIMESTAMP" value="#unixdatetimeNow.getTime()#">
</cfhttp> 即使在新主体之前添加ts_key_str也不起作用。
我的签名很差。当获取帐户数据时,我使用它可以很好地工作cfhttpparam type="body“”value=“。
任何帮助都很感激。
发布于 2022-10-31 18:56:16
这是一个时间戳问题。
设置一个时间戳,并使用该时间戳。所以它可能不会在延迟的通话中提取不同的时间戳。
更新的代码。
<!--- MARKET --->
<cfset b_body = '{"symbol": "#pair#","orderQty":"#size#","side": "#side#","orderType": "MARKET"}'>
<cfset unixdatetimeNow = dateConvert( "local2Utc", now() )>
<cfset timestamp = #unixdatetimeNow.getTime()#>
<cfscript>
apiKey = "#_key#";
apiSecret = "#_s#";
str_to_sign = #timestamp# & '#apikey#' & '5000' & '#b_body#';
HMAC = hmac(str_to_sign, apiSecret, "HMACSHA256");
</cfscript>
<cfset lhmac = lCase(#hmac#)>
<cfhttp url="#base_api##req_path#" method="POST" result="result" charset="utf-8">
<cfhttpparam type="body" value="#b_body#">
<cfhttpparam type="header" name="X-BAPI-SIGN-TYPE" value="2">
<cfhttpparam type="header" name="X-BAPI-SIGN" value="#lhmac#">
<cfhttpparam type="header" name="X-BAPI-API-KEY" value="#_key#">
<cfhttpparam type="header" name="X-BAPI-TIMESTAMP" value="#timestamp#">
<cfhttpparam type="header" name="X-BAPI-RECV-WINDOW" value="5000">
<cfhttpparam type="HEADER" name="Content_Type" value="application/json">
</cfhttp> https://stackoverflow.com/questions/74174740
复制相似问题