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
(Swift 3,4,5...) Bitfinex v2 REST Submit OrderSubmit an order. For more information, see https://docs.bitfinex.com/reference#rest-auth-submit-order
func chilkatTest() { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let http = CkoHttp()! var success: Bool let crypt = CkoCrypt2()! var apiPath: String? = "v2/auth/w/order/submit" var apiKey: String? = "MY_API_KEY" var apiSecret: String? = "MY_API_SECRET" let dt = CkoDateTime()! dt.setFromCurrentSystemTime() let sbNonce = CkoStringBuilder()! sbNonce.append(dt.getAsUnixTimeStr(false)) sbNonce.append("000") var nonce: String? = sbNonce.getAsString() let json = CkoJsonObject()! json.update("type", value: "LIMIT") json.update("symbol", value: "tBTCUSD") json.update("price", value: "15") json.update("amount", value: "0.001") json.updateInt("flags", value: 0) var body: String? = json.emit() let sbSignature = CkoStringBuilder()! sbSignature.append("/api/") sbSignature.append(apiPath) sbSignature.append(nonce) sbSignature.append(body) crypt.encodingMode = "hex_lower" crypt.hashAlgorithm = "sha384" crypt.macAlgorithm = "hmac" crypt.setMacKeyString(apiSecret) var sig: String? = crypt.macStringENC(sbSignature.getAsString()) http.setRequestHeader("bfx-apikey", value: apiKey) http.setRequestHeader("bfx-signature", value: sig) http.setRequestHeader("bfx-nonce", value: nonce) var resp: CkoHttpResponse? = http.postJson2("https://api.bitfinex.com/v2/auth/w/order/submit", contentType: "application/json", jsonText: body) if http.lastMethodSuccess == false { print("\(http.lastErrorText!)") return } print("Response body:") print("\(resp!.bodyStr!)") resp = nil } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.