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 2) 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.UpdateString("type", value: "LIMIT") json.UpdateString("symbol", value: "tBTCUSD") json.UpdateString("price", value: "15") json.UpdateString("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.