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
(Tcl) Bitfinex v2 REST Submit OrderSubmit an order. For more information, see https://docs.bitfinex.com/reference#rest-auth-submit-order
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] set crypt [new_CkCrypt2] set apiPath "v2/auth/w/order/submit" set apiKey "MY_API_KEY" set apiSecret "MY_API_SECRET" set dt [new_CkDateTime] CkDateTime_SetFromCurrentSystemTime $dt set sbNonce [new_CkStringBuilder] CkStringBuilder_Append $sbNonce [CkDateTime_getAsUnixTimeStr $dt 0] CkStringBuilder_Append $sbNonce "000" set nonce [CkStringBuilder_getAsString $sbNonce] set json [new_CkJsonObject] CkJsonObject_UpdateString $json "type" "LIMIT" CkJsonObject_UpdateString $json "symbol" "tBTCUSD" CkJsonObject_UpdateString $json "price" "15" CkJsonObject_UpdateString $json "amount" "0.001" CkJsonObject_UpdateInt $json "flags" 0 set body [CkJsonObject_emit $json] set sbSignature [new_CkStringBuilder] CkStringBuilder_Append $sbSignature "/api/" CkStringBuilder_Append $sbSignature $apiPath CkStringBuilder_Append $sbSignature $nonce CkStringBuilder_Append $sbSignature $body CkCrypt2_put_EncodingMode $crypt "hex_lower" CkCrypt2_put_HashAlgorithm $crypt "sha384" CkCrypt2_put_MacAlgorithm $crypt "hmac" CkCrypt2_SetMacKeyString $crypt $apiSecret set sig [CkCrypt2_macStringENC $crypt [CkStringBuilder_getAsString $sbSignature]] CkHttp_SetRequestHeader $http "bfx-apikey" $apiKey CkHttp_SetRequestHeader $http "bfx-signature" $sig CkHttp_SetRequestHeader $http "bfx-nonce" $nonce # resp is a CkHttpResponse set resp [CkHttp_PostJson2 $http "https://api.bitfinex.com/v2/auth/w/order/submit" "application/json" $body] if {[CkHttp_get_LastMethodSuccess $http] == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkCrypt2 $crypt delete_CkDateTime $dt delete_CkStringBuilder $sbNonce delete_CkJsonObject $json delete_CkStringBuilder $sbSignature exit } puts "Response body:" puts [CkHttpResponse_bodyStr $resp] delete_CkHttpResponse $resp delete_CkHttp $http delete_CkCrypt2 $crypt delete_CkDateTime $dt delete_CkStringBuilder $sbNonce delete_CkJsonObject $json delete_CkStringBuilder $sbSignature |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.