我正在尝试使用 RStudio 通过 Binance API 创建新订单。
我找到了 Binance Official API Docs 并发现我应该使用:
POST /api/v3/order (HMAC SHA256).
以下脚本不起作用并给出状态码:HTTP/1.1 401 Unauthorized
key <- "*[my key]*"
secret <- "*[my secret key]*"
url='https://api.binance.com/api/v3/order'
timestamp <- as.character(jsonlite::fromJSON(content(GET('https://api.binance.com/api/v1/time'), "text"))$serverTime + 999)
query <- list( "symbol" = "XLMBTC", "side" = "BUY", "type" = "MARKET", "quantity" = 10, "recvWindow" = 5000, "timestamp" = timestamp )
signature <- digest::hmac(key = secret, object = paste(names(query), query, sep = "=", collapse = "&"), algo = "sha256")
POST(url, add_headers("X-MBX-APIKEY"= key), query = c(query, signature = signature), verbose())
我的编码中有错误吗?我之前尝试过一次,然后效果很好。但是,现在我无法想出一个工作脚本。
在这里您可以找到有关 Binance API 的文档: https ://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md
有人可以帮帮我吗?