(C#) Bitfinex v2 REST Submit Order
Submit an order. For more information, see https://docs.bitfinex.com/reference#rest-auth-submit-order
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Chilkat.Http http = new Chilkat.Http();
bool success;
Chilkat.Crypt2 crypt = new Chilkat.Crypt2();
string apiPath = "v2/auth/w/order/submit";
string apiKey = "MY_API_KEY";
string apiSecret = "MY_API_SECRET";
Chilkat.CkDateTime dt = new Chilkat.CkDateTime();
dt.SetFromCurrentSystemTime();
Chilkat.StringBuilder sbNonce = new Chilkat.StringBuilder();
sbNonce.Append(dt.GetAsUnixTimeStr(false));
sbNonce.Append("000");
string nonce = sbNonce.GetAsString();
Chilkat.JsonObject json = new Chilkat.JsonObject();
json.UpdateString("type","LIMIT");
json.UpdateString("symbol","tBTCUSD");
json.UpdateString("price","15");
json.UpdateString("amount","0.001");
json.UpdateInt("flags",0);
string body = json.Emit();
Chilkat.StringBuilder sbSignature = new Chilkat.StringBuilder();
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);
string sig = crypt.MacStringENC(sbSignature.GetAsString());
http.SetRequestHeader("bfx-apikey",apiKey);
http.SetRequestHeader("bfx-signature",sig);
http.SetRequestHeader("bfx-nonce",nonce);
Chilkat.HttpResponse resp = http.PostJson2("https://api.bitfinex.com/v2/auth/w/order/submit","application/json",body);
if (http.LastMethodSuccess == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
Debug.WriteLine("Response body:");
Debug.WriteLine(resp.BodyStr);
|