Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Bitfinex v2 REST Submit OrderSubmit an order. For more information, see https://docs.bitfinex.com/reference#rest-auth-submit-order
IncludeFile "CkJsonObject.pb" IncludeFile "CkDateTime.pb" IncludeFile "CkHttp.pb" IncludeFile "CkCrypt2.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkHttpResponse.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i crypt.i = CkCrypt2::ckCreate() If crypt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf apiPath.s = "v2/auth/w/order/submit" apiKey.s = "MY_API_KEY" apiSecret.s = "MY_API_SECRET" dt.i = CkDateTime::ckCreate() If dt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkDateTime::ckSetFromCurrentSystemTime(dt) sbNonce.i = CkStringBuilder::ckCreate() If sbNonce.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbNonce,CkDateTime::ckGetAsUnixTimeStr(dt,0)) CkStringBuilder::ckAppend(sbNonce,"000") nonce.s = CkStringBuilder::ckGetAsString(sbNonce) json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(json,"type","LIMIT") CkJsonObject::ckUpdateString(json,"symbol","tBTCUSD") CkJsonObject::ckUpdateString(json,"price","15") CkJsonObject::ckUpdateString(json,"amount","0.001") CkJsonObject::ckUpdateInt(json,"flags",0) body.s = CkJsonObject::ckEmit(json) sbSignature.i = CkStringBuilder::ckCreate() If sbSignature.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbSignature,"/api/") CkStringBuilder::ckAppend(sbSignature,apiPath) CkStringBuilder::ckAppend(sbSignature,nonce) CkStringBuilder::ckAppend(sbSignature,body) CkCrypt2::setCkEncodingMode(crypt, "hex_lower") CkCrypt2::setCkHashAlgorithm(crypt, "sha384") CkCrypt2::setCkMacAlgorithm(crypt, "hmac") CkCrypt2::ckSetMacKeyString(crypt,apiSecret) sig.s = CkCrypt2::ckMacStringENC(crypt,CkStringBuilder::ckGetAsString(sbSignature)) CkHttp::ckSetRequestHeader(http,"bfx-apikey",apiKey) CkHttp::ckSetRequestHeader(http,"bfx-signature",sig) CkHttp::ckSetRequestHeader(http,"bfx-nonce",nonce) resp.i = CkHttp::ckPostJson2(http,"https://api.bitfinex.com/v2/auth/w/order/submit","application/json",body) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbNonce) CkJsonObject::ckDispose(json) CkStringBuilder::ckDispose(sbSignature) ProcedureReturn EndIf Debug "Response body:" Debug CkHttpResponse::ckBodyStr(resp) CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbNonce) CkJsonObject::ckDispose(json) CkStringBuilder::ckDispose(sbSignature) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.