Closed mtmy2 closed 6 years ago
Hi @mtmy2 , I haven't seen this problem before, but can try to replicate it somewhere in the coming week. Cheers
Hi @mtmy2 could you do a debug.print of your postdata string?
Like so: postdata = "symbol=" & sym... etc... debug.print postdata
My guess is that your value has a comma in it, so you'd need to replace that by a dot.
Debug gave: symbol=BTCUSD&quantity=0,01&type=market&side=buy
this error with qty=0,01: {"error":{"code":2010,"message":"Quantity not a valid number","description":"Quantity not a valid number or not set"}} And this error with qty=1: {"error":{"code":20001,"message":"Insufficient funds","description":"Check that the funds are sufficient, given commissions"}}
Hi @mtmy2 , do you see the "qty=0,01" -> that is a comma, and HitBTC only accepts a . (dot) as a decimal symbol So you could add a line after that postdata line to do that: postdata = Replace(postdata , ",", ".", 1)
That should solve the first error. For the second error, you need enough funds in your account.
It's work! Thak you so much!
Good day. Thank you for great work for vba users! I have one problem with post order on btsusd pair. I set quantity = 0.01, type = market and get response with error "Quantity is not valid number". If i try to change quantity = 1, i have response "Insufficient funds". and if I post order wiht DOGEBTC for examply where quantity =1000 i have success order. It seems like HitBTC don't alLow me trade with quantity less than 1 BTC. But quantityIncrement ia 0.01 for BTCUSD. I have general verification account. Can anybody explain me how solve this problem?
`Sub placeorderHitBTC() Dim httpObject As Object Dim nonce As Double Dim verb, symbol, url, postdata, replytext, nonceStr As String 'âðåìåííî Set thiswb = ActiveWorkbook qty = 0.01 side = "sell"
' Set api key and secret apiKey = ".." apiSecret = ".."
nonce = CreateNonce(10) nonceStr = nonce symbol = "BTCUSD" url = "/api/2/order" postdata = "symbol=" & symbol & "&quantity=" & qty & "&type=market" & "&side=" & side
Set httpObject = CreateObject("msxml2.xmlhttp") ' httpObject.Open "POST", "https://api.hitbtc.com" & url, False httpObject.setRequestHeader "accept", "application/json" httpObject.setRequestHeader "Authorization", "Basic " & Base64Encode(apiKey & ":" & apiSecret) httpObject.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" httpObject.Send postdata
' Catch response replytext = httpObject.ResponseText thiswb.Worksheets("Òåðìèíàë").Cells(1, "Q") = replytext
Set httpObject = Nothing `