· 7 years ago · Dec 05, 2018, 02:50 PM
1apiKey <- "*My API key*"
2secretKey <- "*My Secret key*"
3
4timestamp <- GET(url = "https://api.binance.com", path = "/api/v1/time")
5timestamp=content(timestamp, as="parsed")
6timestamp=timestamp$serverTime - 1542213129131.6
7
8"symbol" = "BTS-BTC"
9"side" = "SELL"
10"type" = "MARKET"
11"quantity" = 1000
12"recvWindow" = 5000000000000
13"timeInForce" = "GTC"
14
15
16postmsg <- paste0("timestamp=", timestamp,"&recvWindow=",recvWindow,"&symbol=",symbol,
17"&side=",side,"&type=",type,"&quantity=",quantity,"&timeInForce=",timeInForce)
18
19signature <- openssl::sha256(postmsg, key=secretKey)
20
21POST(
22url = "https://api.binance.com",
23path = "api/v3/order",
24content_type('application/json'), add_headers(.headers = c("X-MBX- APIKEY"=apiKey)),
25query=list(signature=signature),
26encode = 'json'
27)