MQuant Developers v1
Open MQuant

XTS-compatible API

If your trading code talks to a Symphony XTS Interactive API today, through the Python XTConnect SDK, the Node xts-interactive-api SDK or plain REST, it can talk to MQuant. Change the root URL, appKey and secretKey; the endpoints, function names, field names and replies stay the same.

Orders become signals

Orders you place are stored as signals for the Sykes & Ray desk. Nothing is sent to an exchange or a broker by the API. Trades, positions and holdings are always empty.

The three changes#

SettingAt your XTS brokerAt MQuant
Root URLhttps://xts.your-broker.examplehttps://app.mquant.in/api/v1
appKeyYour broker app keyYour MQuant key id: mq_live_pk_… or mq_test_pk_…
secretKeyYour broker secret keyYour MQuant secret: mq_live_sk_… or mq_test_sk_…
sourceWEBAPIUnchanged. Any XTS source is accepted; it defaults to WEBAPI.

Before and after code for Python, Node.js and curl is in Switching from XTS on the overview. Every endpoint, with its SDK function, is in the XTS API reference.

Ask your MQuant desk contact for a key. Start with a test key: test orders are kept apart from live ones and can never be accepted by the desk. Live keys need an IP allowlist of 1 to 5 static public addresses.

Root URL for each client#

ClientSet the root toRequests go to
Plain REST, curl, any HTTP libraryhttps://app.mquant.in/api/v1https://app.mquant.in/api/v1/interactive/…
Node xts-interactive-api 3.x (new XTSInteractive(url))https://app.mquant.in/api/v1https://app.mquant.in/api/v1/interactive/…
Python XTConnect (XTSConnect(appKey, secretKey, source, root=…))https://app.mquant.in/api/v1https://app.mquant.in/interactive/…, which MQuant serves as the same API

The Python SDK builds every URL with urljoin(root, "/interactive/…"), which drops the path of the root, so it calls https://app.mquant.in/interactive/… whatever root you give it. MQuant answers there with the same API, so root="https://app.mquant.in/api/v1" and root="https://app.mquant.in" both work.

XTConnect reads config.ini from the working directory when it is imported, and fails without it. If you pass root= to XTSConnect you only need the file to exist; if you rely on its default root, change it:

config.ini (Python XTConnect)
[user]
source=WEBAPI

[SSL]
disable_ssl=False

[root_url]
root=https://app.mquant.in/api/v1
broadcastMode=Full

Logging in and sessions#

  1. POST /interactive/user/session with appKey, secretKey and source, as JSON or as a form. The reply carries result.token and result.userID (MQ followed by your trader number, for example MQ12).
  2. Send the token in the authorization header on every other call, as XTS does. A leading Bearer is accepted too.
  3. DELETE /interactive/user/session ends the session.
RuleMQuant
Tokenmq_xts_ followed by 64 letters and digits. MQuant stores only a hash of it.
LifetimeUntil the next midnight IST, or the key's expiry if that is sooner. A token from yesterday gets Invalid Token.
Sessions per keyUp to 3. A fourth login ends the oldest session, so up to three processes can share one key.
Ends early whenYou log out, or the desk suspends, revokes or rotates the key, or deactivates your trader account.
Wrong credentials400 e-user-0001 "Invalid appKey or secretKey", the same for every cause. 20 failed logins or signatures in 15 minutes lock your IP for 15 minutes.
IP allowlistChecked at login and on every call. Live keys must have one.
Scopessignals:write to place, modify and cancel; signals:read for the order book and history. Any key can log in and read the profile, balance, trades, positions and holdings.

When a call answers 400 with "description": "Invalid Token", log in again and repeat the call. Both SDKs already treat this reply as an expired session.

Orders are signals#

MQuant does not route orders to an exchange. An order you place is stored as a signal for the Sykes & Ray desk, which reviews it and decides what happens to it. The same signal is visible through the signed signals API and to the desk.

  • AppOrderID is a number MQuant assigns, 1,000,000,000 or more, unique and increasing within MQuant. Use it to modify, cancel and read the order, as with XTS.
  • orderUniqueIdentifier is your tag. It is echoed back and stored as the signal's tag.
  • Safe retries. Within 10 seconds, an identical order with the same orderUniqueIdentifier is treated as a retry: you get the first order's AppOrderID back with the header Idempotent-Replayed: true, and nothing new is stored. To send two identical orders back to back on purpose, give them different orderUniqueIdentifier values. Orders without one are never treated as retries.
  • The order book lists today's orders (since midnight IST) placed through this interface by your trader, in the key's mode, oldest first. Order history works for any of your AppOrderIDs.
  • Orders show the desk's view in two extra fields on every row: MQuantStatus (the signal status) and MQuantSignalID.

Order fields#

Place (POST /interactive/orders) takes the XTS fields below. Values are matched without regard to case, and numeric strings are accepted where a number is expected. Any other field is a Bad Request.

XTS fieldAccepted valuesStored on the signal as
exchangeSegmentRequired. NSECM, NSEFO, BSECM, BSEFO, MCXFO, or the codes 1, 2, 11, 12, 51 (number or string), any case.exchange: NSE, NFO, BSE, BFO, MCX
exchangeInstrumentIDRequired. The exchange token, as a number or a digit string of up to 15 digits.symbol, instrument_type, expiry, strike, from the instrument master
productTypeRequired. MIS (1), NRML (2), CNC (4). CO, BO and MTF are not supported. CNC only on NSECM and BSECM.product. NRML on NSECM or BSECM is stored as CNC; the order book still shows NRML.
orderTypeRequired. MARKET (1), LIMIT (2), STOPMARKET (4), STOPLIMIT (8), any case, so Limit and StopLimit work.order_type: MARKET, LIMIT, SL-M, SL
orderSideRequired. BUY or SELL.side
timeInForceRequired. DAY (1) or IOC (4). GTC, GTD, EOS, COL and GTDYS are not supported.validity
orderQuantityRequired. Whole number, at least 1, in units (shares or contracts). On NSEFO, BSEFO and MCXFO it must be a multiple of the lot size.quantity
disclosedQuantityOptional, default 0. Not more than orderQuantity.Kept with the order
limitPriceNumber or decimal string, 0 or more, at most 2 decimals, a multiple of the tick size. 0 means not set. Required (above 0) for LIMIT and STOPLIMIT; ignored for MARKET and STOPMARKET.price
stopPriceAs limitPrice. Required (above 0) for STOPLIMIT and STOPMARKET; ignored for MARKET and LIMIT.trigger_price
orderUniqueIdentifierOptional. 1 to 20 characters of A-Z a-z 0-9 _ -. Echoed back on every reply and row.tag
apiOrderSourceOptional. Up to 40 printable characters.Kept with the order; shown as ApiOrderSource
clientIDOptional. Leave it out, or send your userID. undefined and null count as absent.Not stored
algoID, algoCategory, isProOrderAccepted and ignored.Not stored

Modify takes the same values under the XTS modified… names, plus appOrderID. The segment, instrument and side of an order cannot change.

Enum values#

FieldXTS valueMQuant signal value
productTypeMIS / NRML / CNCMIS / NRML on F&O, CNC on cash / CNC
orderTypeMARKET / LIMIT / STOPMARKET / STOPLIMITMARKET / LIMIT / SL-M / SL
orderSideBUY / SELLBUY / SELL
timeInForceDAY / IOCDAY / IOC
dayOrNetDayWise / NetWise (also DAY, NET, 1, 2)Positions are always empty
Order book OrderTypeMarket / Limit / StopMarket / StopLimitXTS response casing

Exchange segments#

exchangeSegmentCodeSignal exchangeInstrumentsStatus
NSECM1NSEEquity (series EQ, BE, BZ, SM, ST, IV, RR)Supported
NSEFO2NFOIndex and stock futures and optionsSupported
BSECM11BSEEquity (every group except F, G and SPOT)Supported
BSEFO12BFOFutures and optionsSupported
MCXFO51MCXCommodity futures and optionsAccepted, but fails with e-instrument-0003 until MQuant has an MCX instrument master
NSECD, BSECD, NCDEX3, 13, 21Currency and NCDEXNot supported: e-instrument-0002

Instrument ids#

  • exchangeInstrumentID is the exchange token. It is the same at every XTS broker (NSECM 2885 is RELIANCE everywhere), so keep getting it from your broker's XTS market data API or instrument master.
  • MQuant looks the id up in its own copy of the exchange instrument master to find the symbol, expiry, strike, option type, lot size and tick size. An id it cannot find gives e-instrument-0001; a contract listed today may not be there yet.
  • Expired contracts give e-instrument-0004. Debt, government securities and index rows give e-instrument-0002.
  • Quantities are units, as at XTS brokers: one lot of a NIFTY option with lot size 65 is orderQuantity: 65.

Order statuses#

Nothing executes, so no order is ever Filled, PartiallyFilled, Expired or PendingNew. CumulativeQuantity is always 0 and OrderAverageTradedPrice is always "0".

Signal statusOrderStatusOpen?ModifyCancel
receivedNew, or Replaced after a modifyYesYesBecomes cancelled
acceptedNew, or Replaced if modified beforeYesNo: e-orders-0003Becomes cancelled
mapped (reserved)New / ReplacedYesNoBecomes cancel_requested
cancel_requestedPendingCancelNoNoSuccess, unchanged
cancelledCancelledNoNoe-orders-0003
rejectedRejected, with the desk's reason in CancelRejectReasonNoNoe-orders-0003
  • Modify works only while the signal is received, before the desk has acted on it. It records a new revision, and the history shows a Replaced row.
  • Cancel and cancel all work while new orders are paused by the desk. Cancel all affects today's open orders placed through this interface, in one segment, and for one instrument unless exchangeInstrumentID is 0.
  • Orders do not expire at the end of the day in v1.

Response envelope#

Every reply under /interactive/ is JSON with type, code, description and result, as XTS sends it. Successes are always HTTP 200.

Success, HTTP 200
{"type": "success", "code": "s-orders-0001", "description": "Request sent", "result": {
  "AppOrderID": 1000000017, "OrderUniqueIdentifier": "reliance1", "ClientID": "MQ12",
  "MQuantSignalID": "sig_9f2c4e1a7b3d5f60a1b2c3d4", "MQuantWarnings": []
}}
Error, HTTP 400
{"type": "error", "code": "e-orders-0001", "description": "Bad Request", "result": {"errors": [
  {"field": ["limitPrice"], "messages": ["limitPrice is required for LIMIT and STOPLIMIT orders"], "location": "body"}
]}}
  • "Invalid Token" and "Bad Request" are sent exactly as XTS sends them, because the Python SDK matches them to raise XTSTokenException and XTSInputException.
  • result.errors names fields by their XTS names (orderQuantity, limitPrice, modifiedLimitPrice …).
  • Fields MQuant adds always start with MQuant, so they cannot clash with XTS fields. Ignore them if you do not need them.
  • Every reply has an X-Request-Id header. Quote it to the desk.
Expired, logged-out or unknown token, HTTP 400
{"type": "error", "code": "e-session-0007", "description": "Invalid Token", "result": {}}

Error codes#

codeHTTPdescriptionWhenWhat to do
e-session-0007400Invalid TokenThe token is missing, malformed, unknown, expired (after midnight IST), logged out, or its key was suspended, revoked or rotated.Log in again. The SDKs raise XTSTokenException (Python) or return the error (Node).
e-user-0001400Invalid appKey or secretKeyLogin failed. The same reply for an unknown key id, a wrong secret or a typo, on purpose.Check the two values. 20 failures in 15 minutes lock your IP for 15 minutes.
e-user-0002429Too many failed logins, try laterYour IP is locked after repeated failed logins or failed signatures.Wait Retry-After seconds and fix the credentials.
e-user-0003400API key is revoked / has expired / is suspended, or Trader is not activeThe secret was right but the key or the trader cannot be used.Contact your MQuant desk contact.
e-user-0004400Bad RequestThe login body could not be read, or source is not an XTS source.Send appKey, secretKey and source as JSON or as a form.
e-user-0005403Requests from <ip> are not allowed for this keyThe request came from an address outside the key's allowlist.Send from an allowlisted address, or ask the desk to change the allowlist.
e-user-0006400clientID does not belong to this sessionA clientID other than your userID was sent.Leave clientID out, or send your userID.
e-user-0007403This key does not have the scope this endpoint needsPlacing, modifying and cancelling need signals:write; the order book and history need signals:read.Use a key with the right scope.
e-orders-0001400Bad RequestAn order field failed validation. result.errors lists every problem by XTS field name.Fix each listed field.
e-orders-0002400Order not foundNo order with that appOrderID for your trader and key mode.Check the id and that you use a key of the same mode (live or test).
e-orders-0003400Order is not openModify of an order that is no longer received, or cancel of a cancelled or rejected order. result.MQuantStatus gives the current status.Read the order history.
e-orders-0004400Order exceeds this key's risk limitsorderQuantity or the order value is above a risk cap on the key.Reduce the size, or ask the desk to review the cap.
e-orders-0005400Duplicate order is still being processed, retryAn identical retry arrived while the first copy was still being stored.Retry after a moment; you get the first order back.
e-portfolio-0001400Bad RequestdayOrNet is missing or not DayWise / NetWise.Send dayOrNet.
e-instrument-0001400Instrument not foundThe exchangeInstrumentID is not in MQuant's copy of the instrument master for that segment.Check the segment and the id. A contract listed today may not be there yet.
e-instrument-0002400Instrument not supported by MQuantNSECD, BSECD or NCDEX, a debt, government-security or index row, or an unusable master row.Trade a supported instrument.
e-instrument-0003400Instrument master unavailableMQuant has no instrument master for the segment yet (MCXFO today).Use another segment, or ask the desk.
e-instrument-0004400Contract has expiredThe contract's expiry date is before today (IST).Use a current contract.
e-request-0001404Not foundThe path ends with a slash.Remove the trailing slash.
e-request-0002405Method not allowedWrong HTTP method for a supported path. Allow lists the right ones.Use the method from the reference.
e-request-0003413Payload too largeThe body is over its limit: 4,096 bytes for login and cancel all, 8,192 for place and modify.Send a smaller body.
e-request-0004400Bad RequestThe body is not a JSON object, has a duplicate key, NaN, an exponent number, or is compressed.Build the body with a JSON library and do not compress it.
e-mquant-0001400Not supported by MQuantA part of XTS that MQuant does not provide: bracket, cover, convert, square-off, GTT, spread, margin, exchange messages and status, the socket.See What MQuant does not provide.
e-rate-0001429Rate limit exceeded. Retry after <n> sA rate limit was hit. Retry-After says how long to wait.Wait and retry. See Rate limits.
e-rate-0002429IP temporarily blockedYour IP hit limits repeatedly.Stop until Retry-After has passed, then slow down.
e-rate-0003429Key temporarily blockedThe key hit its limits repeatedly.Stop until Retry-After has passed, then slow down.
e-mquant-0005500Internal error. Quote X-Request-Id <req_…> to the desk.Something failed on our side.Retry with backoff. Read the order book before resending an order.
e-mquant-0002503The MQuant API is switched offThe API is off for maintenance.Retry later.
e-mquant-0003503Order intake is paused by the deskNew orders and modifications are paused. Reads and cancels still work.Retry later.
e-mquant-0004503Service temporarily unavailable, retry laterA dependency is down.Retry with backoff.

Rate limits#

EndpointsCounts asLimit
LoginLogin30 per minute per IP before the secret is checked; 2 per second, 20 per minute and 200 per day per key after
Place, modify, cancel, cancel allWrite, 1 eachYour key's write limits (default 10 per second, 400 per minute, 5,000 per day), shared with POST /api/v1/signals
Profile, balance, enums, order book, history, trades, positions, holdingsRead, 1 eachYour key's read limits (default 10 per second, 300 per minute), shared with the signed API
LogoutNonePer-IP limits only

XTS and the signed API share the same buckets, so the exchange ceiling of 10 orders per second holds across both. A 429 carries Retry-After. Rate limit headers are described in Rate limits.

What MQuant does not provide#

  • Market data API (/apimarketdata/…: quotes, subscriptions, instrument master, OHLC, search). Keep using your broker's XTS market data API for prices and instrument ids.
  • Interactive socket (socket.io order, trade and position events). You do not need it for any REST call; poll the order book or order history instead.
  • Host lookup. Set the root URL directly.
  • Bracket and cover orders, position conversion, square-off, GTT, spread and AMO orders, margin calculation, exchange status and exchange messages. They return e-mquant-0001 "Not supported by MQuant".
  • Segments NSECD, BSECD and NCDEX. MCXFO until MQuant has its instrument master.
  • Fills, trades, positions, holdings and money. The trade book, positions and holdings are always empty, and the balance is always zero.
  • Browser use. There are no CORS headers.

SDK notes#

Python XTConnect#

  • Check response["type"] on every reply. XTConnect returns error replies as dicts, except "Invalid Token" and "Bad Request", which it raises.
  • XTConnect's wrappers catch their own exceptions and then fail with UnboundLocalError. This is the same with any XTS broker. Wrap calls and log in again on any exception from a call made with an old token.
  • get_dealerposition_daywise and get_dealerposition_netwise build their URL without a leading slash. If you call them, use root="https://app.mquant.in".
  • MQuant answers isInvestorClient: true, so XTConnect never sends clientID.

Node xts-interactive-api#

  • The SDK sends clientID=undefined when you pass no clientID; MQuant treats that as absent.
  • Version 3.0.3 has no cancel-all function. Call POST /interactive/orders/cancelall directly if you need it.
  • Do not create XTSInteractiveWS: there is no socket.

Plain REST in Python#

No SDK needed. Set MQ_API_KEY and MQ_API_SECRET in the environment and run:

Python 3 with requests
import os

import requests

ROOT = "https://app.mquant.in/api/v1"
session = requests.Session()

login = session.post(ROOT + "/interactive/user/session", timeout=10, json={
    "appKey": os.environ["MQ_API_KEY"],
    "secretKey": os.environ["MQ_API_SECRET"],
    "source": "WEBAPI",
}).json()
if login["type"] != "success":
    raise SystemExit(login["code"] + " " + login["description"])
session.headers["authorization"] = login["result"]["token"]

order = session.post(ROOT + "/interactive/orders", timeout=10, json={
    "exchangeSegment": "NSEFO",
    "exchangeInstrumentID": 63624,
    "productType": "NRML",
    "orderType": "LIMIT",
    "orderSide": "BUY",
    "timeInForce": "DAY",
    "disclosedQuantity": 0,
    "orderQuantity": 65,
    "limitPrice": 112.5,
    "stopPrice": 0,
    "orderUniqueIdentifier": "nifty1",
    "apiOrderSource": "WEBAPI",
}).json()
print(order["type"], order["code"], order["result"])
app_order_id = order["result"]["AppOrderID"]

history = session.get(ROOT + "/interactive/orders", params={"appOrderID": app_order_id}, timeout=10).json()
print([row["OrderStatus"] for row in history["result"]])

cancel = session.delete(ROOT + "/interactive/orders", params={"appOrderID": app_order_id}, timeout=10).json()
print(cancel["type"], cancel["result"])

session.delete(ROOT + "/interactive/user/session", timeout=10)

Security#

XTS-style authentication is a bearer token, with no signature on each request. MQuant limits the risk: live keys must have an IP allowlist, tokens are stored only as hashes, every token ends at midnight IST, a key has at most three sessions, and suspending, revoking or rotating a key ends its sessions at once. If you want every request signed, use the signed signals API with the same key.

MQuant is the platform of Sykes & Ray Equities. Questions go to your MQuant desk contact.