我成功创建了hitbtc api caller
Protected Overrides Function getJsonPrivate(method As String, otherParameters() As Tuple(Of String, String)) As String
Dim content = "/api/1/trading/" + method + "?nonce=" + ExchangesClass.getNonce().ToString + "&apikey=" + _apiKey1
Dim postar = otherParameters.ToList.ConvertAll(Function(x) x.Item1 + "=" + x.Item2)
Dim post = String.Join("&", postar) ' "id=4987469178"
Dim sighash = computeSig(content) '"https://api.hitbtc.com/api/1/trading/cancel_order?nonce=36411402&apikey=13a2492a3f0631d657ecd510ceacc509"
Dim url = "https://api.hitbtc.com" + content
Dim response = CookieAwareWebClient.downloadString1(url, post, {Tuple.Create("X-Signature", sighash)})
'Dim response1 = CookieAwareWebClient.downloadString1("https://api.hitbtc.com" + content + "&" + post, "", {Tuple.Create("X-Signature", sighash)})
Return response
End Function
它适用于他们的获取请求。我可以得到平衡。我可以获得有效订单。但是,要取消订单,我需要发布请求。
例如,做 _jsonResult = getJsonPrivate(“balance”,{})
工作得很好,我会得到:
"{""balance"":[{""currency_code"":""1ST"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""8BT"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""ADX"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AE"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AEON"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AIR"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AMB"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AMP"",""cash"":""0"",""reserved"":""0""},
响应只会导致零。
我试图在这里看到PhP代码示例
https://github.com/hitbtc-com/hitbtc-api/blob/master/APIv1.md#examples
这里的PHP示例
https://gist.github.com/hitbtc-com/10885873
这仍然很奇怪。
我是否应该根据过多添加到URI的帖子请求来计算computeSig?没有基础&
有没有C#或vb.net样本?我认为它只需要对代码进行一次小的更改,因此我可以执行cancel_order方法而不是只获取
downloadstring1的内容如下。所以它基本上根据post参数是否为空字符串进行发布或获取。我认为这很明显。
Public Shared Function downloadString1(url As String, post As String, otherHeaders As Tuple(Of String, String)()) As String
Dim wc = New CookieAwareWebClient()
For Each oh In otherHeaders
wc.Headers.Add(oh.Item1, oh.Item2)
Next
Dim response = String.Empty
Try
If post = "" Then
response = wc.DownloadString(url)
Else
response = wc.UploadString(url, post)
End If
Catch ex As Exception
Dim a = 1
End Try
Return response
End Function
答案 0 :(得分:0)
我需要的唯一变化是在计算签名时包含帖子消息
我改变了这个
Dim sighash = computeSig(content)
到
Dim sighash = computeSig(content + post)
现在我收到了这条消息
"{""CancelReject"":{""rejectReasonCode"":""orderNotFound""}}"
这是一个问题(在我刚拿到空字符串之前。
那将是另一个问题。
<强>更新强>
啊我应该使用clientOrderId而不是id或order id。一些最低限度的文件。
我得到了这个
?响应
"{""ExecutionReport"":{""orderId"":""4987469178"",""latestOrderId"":""4987469178"",""clientOrderId"":""2c90f00aee8e4d21b0cd83d421297c9a"",""orderStatus"":""canceled"",""userId"":""user_319564"",""symbol"":""UGTBTC"",""side"":""buy"",""price"":""0.000018"",""quantity"":111,""type"":""limit"",""timeInForce"":""GTC"",""lastQuantity"":0,""lastPrice"":"""",""leavesQuantity"":0,""cumQuantity"":0,""averagePrice"":""0"",""created"":1509439576948,""execReportType"":""canceled"",""timestamp"":1509962441283}}"
答案 1 :(得分:0)
获得create an account on Hitbtc和create API key并添加Place/cancel orders
访问权限后,您可以通过DELETE
请求取消订单(而不是POST
,而不是GET
,它是DELETE
):
DELETE /api/2/order/{clientOrderId}
您的请求看起来像这样(有卷曲):
curl -X DELETE -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.hitbtc.com/api/2/order/d8574207d9e3b16a4a5511753eeef175"
从您的源代码中,我看到您使用API V1端点(/ api / 1 / trading),但请注意 API V1已过时,最好切换到API V2 。
您最后可以参考official Hitbtc API documentation。
您还可以仔细检查订单是否已取消?
此致