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
(Unicode C++) Bitfinex v2 REST Submit OrderSubmit an order. For more information, see https://docs.bitfinex.com/reference#rest-auth-submit-order
#include <CkHttpW.h> #include <CkCrypt2W.h> #include <CkDateTimeW.h> #include <CkStringBuilderW.h> #include <CkJsonObjectW.h> #include <CkHttpResponseW.h> void ChilkatSample(void) { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpW http; bool success; CkCrypt2W crypt; const wchar_t *apiPath = L"v2/auth/w/order/submit"; const wchar_t *apiKey = L"MY_API_KEY"; const wchar_t *apiSecret = L"MY_API_SECRET"; CkDateTimeW dt; dt.SetFromCurrentSystemTime(); CkStringBuilderW sbNonce; sbNonce.Append(dt.getAsUnixTimeStr(false)); sbNonce.Append(L"000"); const wchar_t *nonce = sbNonce.getAsString(); CkJsonObjectW json; json.UpdateString(L"type",L"LIMIT"); json.UpdateString(L"symbol",L"tBTCUSD"); json.UpdateString(L"price",L"15"); json.UpdateString(L"amount",L"0.001"); json.UpdateInt(L"flags",0); const wchar_t *body = json.emit(); CkStringBuilderW sbSignature; sbSignature.Append(L"/api/"); sbSignature.Append(apiPath); sbSignature.Append(nonce); sbSignature.Append(body); crypt.put_EncodingMode(L"hex_lower"); crypt.put_HashAlgorithm(L"sha384"); crypt.put_MacAlgorithm(L"hmac"); crypt.SetMacKeyString(apiSecret); const wchar_t *sig = crypt.macStringENC(sbSignature.getAsString()); http.SetRequestHeader(L"bfx-apikey",apiKey); http.SetRequestHeader(L"bfx-signature",sig); http.SetRequestHeader(L"bfx-nonce",nonce); CkHttpResponseW *resp = http.PostJson2(L"https://api.bitfinex.com/v2/auth/w/order/submit",L"application/json",body); if (http.get_LastMethodSuccess() == false) { wprintf(L"%s\n",http.lastErrorText()); return; } wprintf(L"Response body:\n"); wprintf(L"%s\n",resp->bodyStr()); delete resp; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.