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
(SQL Server) Bitfinex v2 REST Submit OrderSubmit an order. For more information, see https://docs.bitfinex.com/reference#rest-auth-submit-order
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @http int -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int DECLARE @crypt int -- Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT DECLARE @apiPath nvarchar(4000) SELECT @apiPath = 'v2/auth/w/order/submit' DECLARE @apiKey nvarchar(4000) SELECT @apiKey = 'MY_API_KEY' DECLARE @apiSecret nvarchar(4000) SELECT @apiSecret = 'MY_API_SECRET' DECLARE @dt int -- Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.CkDateTime', @dt OUT EXEC sp_OAMethod @dt, 'SetFromCurrentSystemTime', @success OUT DECLARE @sbNonce int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbNonce OUT EXEC sp_OAMethod @dt, 'GetAsUnixTimeStr', @sTmp0 OUT, 0 EXEC sp_OAMethod @sbNonce, 'Append', @success OUT, @sTmp0 EXEC sp_OAMethod @sbNonce, 'Append', @success OUT, '000' DECLARE @nonce nvarchar(4000) EXEC sp_OAMethod @sbNonce, 'GetAsString', @nonce OUT DECLARE @json int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'type', 'LIMIT' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'symbol', 'tBTCUSD' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'price', '15' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'amount', '0.001' EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'flags', 0 DECLARE @body nvarchar(4000) EXEC sp_OAMethod @json, 'Emit', @body OUT DECLARE @sbSignature int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbSignature OUT EXEC sp_OAMethod @sbSignature, 'Append', @success OUT, '/api/' EXEC sp_OAMethod @sbSignature, 'Append', @success OUT, @apiPath EXEC sp_OAMethod @sbSignature, 'Append', @success OUT, @nonce EXEC sp_OAMethod @sbSignature, 'Append', @success OUT, @body EXEC sp_OASetProperty @crypt, 'EncodingMode', 'hex_lower' EXEC sp_OASetProperty @crypt, 'HashAlgorithm', 'sha384' EXEC sp_OASetProperty @crypt, 'MacAlgorithm', 'hmac' EXEC sp_OAMethod @crypt, 'SetMacKeyString', @success OUT, @apiSecret DECLARE @sig nvarchar(4000) EXEC sp_OAMethod @sbSignature, 'GetAsString', @sTmp0 OUT EXEC sp_OAMethod @crypt, 'MacStringENC', @sig OUT, @sTmp0 EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'bfx-apikey', @apiKey EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'bfx-signature', @sig EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'bfx-nonce', @nonce DECLARE @resp int EXEC sp_OAMethod @http, 'PostJson2', @resp OUT, 'https://api.bitfinex.com/v2/auth/w/order/submit', 'application/json', @body EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @crypt EXEC @hr = sp_OADestroy @dt EXEC @hr = sp_OADestroy @sbNonce EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @sbSignature RETURN END PRINT 'Response body:' EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @resp EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @crypt EXEC @hr = sp_OADestroy @dt EXEC @hr = sp_OADestroy @sbNonce EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @sbSignature END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.