Submit an Order
Create an order. You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified.
For all transactions related to the private endpoint, you must authorize before sending your request.
For more information you can check our Authentication V1 article.
You need to send request with [POST] method.
  • quantity,price,stopPrice, newOrderClientId, orderMethod, orderType , pairSymbol parameters must be used for submit order.
  • price field will be ignored for market orders. Market orders get filled with different prices until your order is completely filled. There is a 5% limit on the difference between the first price and the last price. İ.e. you can't buy at a price more than 5% higher than the best sell at the time of order submission and you can't sell at a price less than 5% lower than the best buy at the time of order submission.
  • stopPrice parameter is valid only for stop orders.
  • You can use symbol parameter in this format: BTCUSDT
quantity for Market Buy Order
quantity for Market Sell Order
quantity for Limit Buy Order
quantity for Limit Sell Order
TRY, USDT or BTC
CRYPTO
CRYPTO
CRYPTO
post
https://api.btcturk.com
/api/v1/order
Submit Order

Code Example

C#
PHP
Python
1
// You can download ApiClient .net core complete library from github https://github.com/BTCTrader/broker-api-csharp-v2
2
3
var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
4
5
var publicKey = configuration["publicKey"];
6
var privateKey = configuration["privateKey"];
7
var resourceUrl = configuration["resourceUrl"];
8
var apiClientV1 = new ApiClientV1(publicKey, privateKey, resourceUrl);
9
10
var limitSellOrder = new OrderInput
11
{
12
Quantity = 0.001m,
13
Price = 40000m,
14
NewOrderClientId = "test",
15
OrderMethod = OrderMethod.Limit,
16
OrderType = OrderType.Sell,
17
PairSymbol = "BTCTRY"
18
};
19
20
////Create New Order
21
var orderOutput = apiClientV1.CreateOrder(limitSellOrder);
22
23
Console.WriteLine(!orderOutput.Result.Success
24
? quot;Code:{orderOutput.Result.Code} , Message: {orderOutput.Result.Message}"
25
: orderOutput.Result.Data.ToString());
Copied!
1
<?php
2
$base = "https://api.btcturk.com";
3
$apiKey = "YOUR_API_PUBLIC_KEY";
4
$apiSecret = "YOUR_API_SECRET";
5
$method = "/api/v1/order";
6
$uri = $base.$method;
7
8
$post_data = "{ 'quantity' : '0.12345678', 'price' : '50000', 'stopPrice' : 0, newOrderClientId: 'BtcTurk API PHPClient', 'orderMethod':'limit', 'orderType':'sell', 'pairSymbol':'BTCTRY' }";
9
10
$nonce = time()*1000;
11
$message = $apiKey.$nonce;
12
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
13
$signature = base64_encode($signatureBytes);
14
$headers = array(
15
"X-PCK: ".$apiKey,
16
"X-Stamp: ".$nonce,
17
"X-Signature: ".$signature,
18
"Cache-Control: no-cache",
19
"Content-Type: application/json");
20
21
$ch = curl_init();
22
curl_setopt($ch, CURLOPT_URL, $uri);
23
curl_setopt($ch, CURLOPT_HTTP_VERSION, "CURL_HTTP_VERSION_1_2");
24
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
25
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
26
curl_setopt($ch, CURLOPT_POST, 1);
27
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
28
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
29
$result = curl_exec($ch);
30
31
if (curl_errno($ch)) {
32
print_r(curl_error($ch));
33
}
34
$answer = json_decode($result);
35
print_r($answer);
Copied!
1
import time, base64, hmac, hashlib, requests, json
2
3
base = "https://api.btcturk.com"
4
method = "/api/v1/order"
5
uri = base+method
6
7
apiKey = "YOUR_API_PUBLIC_KEY"
8
apiSecret = "YOUR_API_SECRET"
9
apiSecret = base64.b64decode(apiSecret)
10
11
stamp = str(int(time.time())*1000)
12
data = "{}{}".format(apiKey, stamp).encode("utf-8")
13
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
14
signature = base64.b64encode(signature)
15
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}
16
17
params={"quantity": 0.001,"price": 50000,"stopPrice": 0, "newOrderClientId":"BtcTurk Python API Test", "orderMethod":"limit", "orderType":"sell", "pairSymbol":"BTCTRY"}
18
19
result = requests.post(url=uri, headers=headers, json=params)
20
result = result.json()
21
print(json.dumps(result, indent=2))
Copied!

Expected Errors

The expected errors when creating an order with the submit order endpoint are listed below. Review the meaning of the error you received.
PARAMETERS_ERROR
One of the giving parameters is not correct.
BALANCE_NOT_ENOUGH_WITHOUT_OPEN_ORDERS
You do not have enough funds for this operation.
BALANCE_NOT_ENOUGH
The available funds is not enough for this operation.
MIN_TOTAL
The order quantity is less than the minimum required.
STOP_PRICE_GREATER_THAN_MARKET
Stop buy price must be above current price.
STOP_PRICE_LESS_THAN_MARKET
Stop sell price must be bellow current price.
PRICE_MUST_BE_LESS_THAN_MAXPRICE
Buy or sell price must be less than max
FAILED_MIN_TOTAL_AMOUNT
Quantity*price must be greater than min amount
FAILED_ORDER_WITH_OPEN_ORDERS
Order submission failed due to open orders
FAILED_MARKET_ORDER
Market order is not open for the pair
ORDER_MIN_PRICE_EXCEEDED
Less than 1/10 of the current price has been set
ORDER_MAX_PRICE_EXCEEDED
More than *10 of the current price has been set