Limit orders
A limit order executes when the market reaches your target price. The required funds are locked when you place it, so you cannot spend them elsewhere.
POST /quotes/ (with target_price) → (≤ 30 s) → POST /limit-orders/ → active
active → done | cancelled | expired
1. Check the market and choose a target
trading.limit_enabledmust betrue.- The amount must be within
limits.limit.min_buy/max_buy(ormin_sell/max_sell). - A buy target must be below the current buy price, and a sell target above the current sell price. Otherwise you get
invalid_target_price.
curl -s -H "X-API-Key: $TALANO_API_KEY" \
https://service.talano.ir/api/public/v1/markets/<MARKET_ID>/price/
{
"market_id": "3f1c9a52-6a7e-4d6b-9a7e-0b1e7c2d9f10",
"buy": { "price": "10512", "fee": "52.56" },
"sell": { "price": "10388", "fee": "51.94" },
"timestamp": "2026-11-07T08:54:11.162172Z"
}
2. The limit quote
The same POST /quotes/, plus target_price (Toman per mg; a number or string with at most 2 decimals, at least 0.01):
curl -s -X POST \
-H "X-API-Key: $TALANO_API_KEY" -H "Content-Type: application/json" \
-d '{"market_id":"<MARKET_ID>","side":"buy","base_amount":1000,"target_price":"10300.00"}' \
https://service.talano.ir/api/public/v1/quotes/
The response has kind: "limit" and price equal to target_price, and the fee uses the limit fee rate.
3. Place the limit order
Within 30 seconds:
curl -s -X POST \
-H "X-API-Key: $TALANO_API_KEY" -H "Content-Type: application/json" \
-d '{"quote_id":"<QUOTE_ID>","base_amount":1000,"expires_at":"2026-11-14T10:00:00Z","client_id":"bot-limit-000045"}' \
https://service.talano.ir/api/public/v1/limit-orders/
| Field | Rules |
|---|---|
quote_id | Required. A limit quote. Market, side and target price come from it |
base_amount | Required, mg, checked against limits.limit |
expires_at | Optional ISO 8601 with an offset. Must be in the future and no later than the server maximum (default 30 days; admins can change it). If omitted, the server's default expiry applies |
client_id | Same rules as spot orders. A client_id used for a spot order can't be reused here (409) |
The response (201, or 200 for a client_id repeat) is an Order object with status: "active" and locked_amount. A buy locks the Toman total, a sell locks base_amount mg. If funds are insufficient: 400 insufficient_balance (there is no gateway).
When you place the order, the target price is compared with the live price again. If the market has moved past your target since the quote (for example the buy price dropped below your buy target), you get invalid_target_price. Read the new price and choose a new target.
4. Track the status
curl -s -H "X-API-Key: $TALANO_API_KEY" \
https://service.talano.ir/api/public/v1/orders/<ORDER_ID>/
Or all active limit orders:
curl -s -H "X-API-Key: $TALANO_API_KEY" \
"https://service.talano.ir/api/public/v1/orders/?order_type=limit&status=active"
When the order executes, status becomes done and execution_price and traded_at are filled in. v1 has no webhooks, so you poll. An interval of a few seconds or more is enough; keep the rate limits in mind.
5. Cancel
curl -s -X POST -H "X-API-Key: $TALANO_API_KEY" \
https://service.talano.ir/api/public/v1/limit-orders/<ORDER_ID>/cancel/
No body. Only active limit orders can be cancelled (including ones placed in the app), and the locked funds are released.
| Response | Meaning |
|---|---|
200 | The order with status: "cancelled" |
400 order_not_cancellable | The order isn't active any more (done, cancelled or expired) |
404 not_found | No such limit order for you (also returned for spot orders) |
Complete Python example
"""Limit order: quote with target_price -> place -> poll -> cancel.
A buy target must be BELOW the current buy price; a sell target ABOVE the current sell price.
"""
import os
import time
import uuid
from datetime import datetime, timedelta, timezone
from decimal import Decimal
import requests
BASE = os.environ.get("TALANO_BASE_URL", "https://service.talano.ir/api/public/v1")
s = requests.Session()
s.headers["X-API-Key"] = os.environ["TALANO_API_KEY"]
def call(method: str, path: str, **kwargs) -> dict:
r = s.request(method, f"{BASE}{path}", timeout=10, **kwargs)
if r.status_code >= 400:
print("error:", r.status_code, r.text)
r.raise_for_status()
return r.json()
market = next(m for m in call("GET", "/markets/") if m["symbol"] == "MLG/TMN")
if not market["trading"]["limit_enabled"]:
raise SystemExit("limit orders are disabled on this market right now")
# 1. Target 2% below the current buy price (Toman per mg, 2 decimals, sent as a string)
price = call("GET", f"/markets/{market['id']}/price/")
buy_price = Decimal(price["buy"]["price"])
target = (buy_price * Decimal("0.98")).quantize(Decimal("0.01"))
print("buy price", buy_price, "-> target", target)
# 2. Limit quote (valid 30 s)
quote = call("POST", "/quotes/", json={
"market_id": market["id"],
"side": "buy",
"base_amount": 1000,
"target_price": str(target),
})
print("quote kind:", quote["kind"], "price:", quote["price"]) # kind is "limit"
# 3. Place it; funds are locked now. Expire in 7 days.
expires_at = (datetime.now(timezone.utc) + timedelta(days=7)).isoformat(timespec="seconds")
order = call("POST", "/limit-orders/", json={
"quote_id": quote["quote_id"],
"base_amount": int(quote["base_amount"]), # response numbers are strings
"expires_at": expires_at,
"client_id": f"limit-{uuid.uuid4()}",
})
print("placed", order["id"], order["status"], "locked", order["locked_amount"], "Toman")
# 4. Poll a few times (each GET counts against the read bucket: 60/min by default)
for _ in range(3):
order = call("GET", f"/orders/{order['id']}/")
print("status:", order["status"])
if order["status"] != "active":
break
time.sleep(1)
# 5. Still waiting? Cancel it and release the locked Toman.
if order["status"] == "active":
order = call("POST", f"/limit-orders/{order['id']}/cancel/")
print("cancelled:", order["status"])
Limit-order errors
| Code | Cause |
|---|---|
limit_disabled | Limit orders are switched off on this market |
invalid_target_price | Target price on the wrong side of the current price, or the market moved past it before you placed the order |
invalid_expires_at | expires_at in the past or beyond the maximum |
quote_kind_mismatch | A spot quote sent to /limit-orders/ (or the other way round) |
order_not_cancellable | The order is no longer active |