· 8 years ago · Dec 27, 2017, 03:12 PM
1Function PrivateBitfinex(Method As String, apikey As String, secretkey As String, Optional MethodOptions As String) As String
2
3
4Dim NonceUnique As String
5Dim body As String
6Dim payload As String
7Dim signature As String
8
9'Kraken nonce: 16 characters
10NonceUnique = DateDiff("s", "1/1/1970", Now)
11NonceUnique = NonceUnique & Right(Timer * 100, 2) & "0000"
12
13TradeApiSite = "https://api.bitfinex.com"
14urlPath = "/v1/" & Method
15body = "{""request="": """ & urlPath & """, ""nonce="":" & NonceUnique & "}"
16payload = Base64Encode(body)
17signature = ComputeHash_C("SHA384", payload, secretkey, "STR64")
18
19Url = TradeApiSite & urlPath
20
21' Instantiate a WinHttpRequest object and open it
22Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
23objHTTP.Open "POST", Url, False
24objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
25objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
26objHTTP.setRequestHeader "X-BFX-APIKEY", apikey
27objHTTP.setRequestHeader "X-BFX-PAYLOAD", payload
28objHTTP.setRequestHeader "X-BFX-SIGNATURE", signature
29objHTTP.Send (body)
30
31objHTTP.WaitForResponse
32PrivateBitfinex = objHTTP.ResponseText
33Set objHTTP = Nothing
34
35End Function