本文介绍了作法:通过RStudio的新订单Binance API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用RStudio通过Binance API创建新订单.
I am trying to create a new order via the Binance API using RStudio.
我找到了Binance官方API文档,并发现我应该使用
I found the Binance Official API Docs and figured out that I should use
POST /api/v3/order (HMAC SHA256).
以下脚本对我不起作用:
The following script doesn't work out for me:
url='https://api.binance.com/api/v3/account'
GET(url,
add_headers("X-MBX-APIKEY"= *[my API key]*),
query=list("symbol"="ETHBTC",
"side"="BUY",
"type"="MARKET",
"quantity"=1,
recvWindow=5000,
"timestamp"=1499827319559,
"signature"=**???**),
verbose())
有人知道我在做什么错吗,如何使用RSTUDIO通过Binance API创建订单以及如何创建签名?
Does anyone know what I'm doing wrong and how I can create an order via the Binance API using RSTUDIO and how I can create my signature?
推荐答案
library(httr)
timestamp <-
as.character(jsonlite::fromJSON(content(
GET("https://api.binance.com/api/v1/time"), "text"
))$serverTime + 999)
query <-
list(
"symbol" = "VENBTC",
"side" = "BUY",
"type" = "MARKET",
"quantity" = 1,
"recvWindow" = 5000,
"timestamp" = timestamp
)
signature <-
digest::hmac(
key = "*[my secret key]*",
object = paste(names(query), query, sep = "=", collapse = "&"),
algo = "sha256"
)
POST(
url,
add_headers("X-MBX-APIKEY" = "*[my API key]*"),
query = c(query, signature = signature),
verbose()
)
这篇关于作法:通过RStudio的新订单Binance API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!