### Get Configuration Response Example Source: https://public-api.tradelocker.com/reference/config This is an example of a successful response (HTTP 200 OK) when retrieving the system configuration. It includes details about customer access permissions and configuration for various panels like positions, orders, and filled orders. ```json { "s": "ok", "d": { "customerAccess": { "orders": true, "ordersHistory": true, "filledOrders": true, "positions": true, "symbolInfo": true, "marketDepth": true }, "positionsConfig": { "id": "positions", "title": "Positions", "columns": [ { "id": "id" }, { "id": "tradableInstrumentId" }, { "id": "routeId" }, { "id": "side" }, { "id": "qty" }, { "id": "avgPrice" }, { "id": "stopLossId" }, { "id": "takeProfitId" } ] } } } ``` -------------------------------- ### Get Account Details using Python Source: https://public-api.tradelocker.com/reference/account This Python example uses the 'requests' library to make a GET request for account details. It shows how to pass parameters and headers, and how to parse the JSON response. Ensure the 'requests' library is installed (`pip install requests`). ```python import requests def get_account_details(acc_num): url = "https://demo.tradelocker.com/backend-api/trade/accounts" headers = { "accept": "application/json" } params = { "accNum": acc_num } try: response = requests.get(url, headers=headers, params=params) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching account details: {e}") return None # Example usage: # account_data = get_account_details(12345) # if account_data: # print(account_data) ``` -------------------------------- ### Get Account Details using Node.js Source: https://public-api.tradelocker.com/reference/account This Node.js example shows how to make a GET request to retrieve account details. It utilizes the 'axios' library for HTTP requests and demonstrates how to handle the JSON response. Ensure 'axios' is installed (`npm install axios`). ```javascript const axios = require('axios'); const getAccountDetails = async (accNum) => { try { const response = await axios.get('https://demo.tradelocker.com/backend-api/trade/accounts', { headers: { 'accept': 'application/json' }, params: { accNum: accNum } }); return response.data; } catch (error) { console.error('Error fetching account details:', error); throw error; } }; // Example usage: // getAccountDetails(12345).then(data => console.log(data)).catch(err => console.error(err)); ``` -------------------------------- ### Get Configuration using cURL Source: https://public-api.tradelocker.com/reference/config This snippet demonstrates how to fetch the system configuration using a cURL request. It specifies the HTTP GET method and the target URL. Ensure you have the correct authorization headers if required for your environment. ```shell curl --request GET \ --url https://demo.tradelocker.com/backend-api/trade/config \ --header 'accept: application/json' ``` -------------------------------- ### Place New Order Request Example (Ruby) Source: https://public-api.tradelocker.com/reference/trading Example of how to place a new order using Ruby with the 'net/http' library. This shows how to construct and send a POST request to the orders endpoint. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse('https://demo.tradelocker.com/backend-api/trade/accounts/YOUR_ACCOUNT_ID/orders') request = Net::HTTP::Post.new(uri) request['accept'] = 'application/json' request['content-type'] = 'application/json' request['developer-api-key'] = 'YOUR_API_KEY' order_data = { "side": "buy", "type": "limit", "validity": "GTC", "qty": 100, "routeId": 123, "tradableInstrumentId": 456 } request.body = order_data.to_json response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| http.request(request) end puts JSON.parse(response.body) ``` -------------------------------- ### Place New Order Request Example (cURL) Source: https://public-api.tradelocker.com/reference/trading Example of how to place a new order using cURL. This request includes essential order details such as side, type, and validity. ```shell curl --request POST \ --url https://demo.tradelocker.com/backend-api/trade/accounts/accountId/orders \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data '{ "side": "buy", "type": "limit", "validity": "GTC" }' ``` -------------------------------- ### Place New Order Request Example (PHP) Source: https://public-api.tradelocker.com/reference/trading Example of how to place a new order using PHP with cURL. This demonstrates setting up a cURL request to send order details to the API. ```php 'buy', 'type' => 'limit', 'validity' => 'GTC', 'qty' => 100, 'routeId' => 123, 'tradableInstrumentId' => 456 ]; $url = "https://demo.tradelocker.com/backend-api/trade/accounts/{$accountId}/orders"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($orderData)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'accept: application/json', 'content-type: application/json', 'developer-api-key: ' . $apiKey ]); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $response; } curl_close($ch); ?> ``` -------------------------------- ### Place New Order Request Example (Node.js) Source: https://public-api.tradelocker.com/reference/trading Example of how to place a new order using Node.js with the 'axios' library. This demonstrates sending a POST request with the necessary order parameters. ```javascript const axios = require('axios'); const accountId = 'YOUR_ACCOUNT_ID'; const orderData = { "side": "buy", "type": "limit", "validity": "GTC", "qty": 100, "routeId": 123, "tradableInstrumentId": 456 }; axios.post(`https://demo.tradelocker.com/backend-api/trade/accounts/${accountId}/orders`, orderData, { headers: { 'accept': 'application/json', 'content-type': 'application/json', 'developer-api-key': 'YOUR_API_KEY' } }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error); }); ``` -------------------------------- ### Place New Order Request Example (Python) Source: https://public-api.tradelocker.com/reference/trading Example of how to place a new order using Python with the 'requests' library. This shows how to send a POST request with JSON data and headers. ```python import requests accountId = 'YOUR_ACCOUNT_ID' apiKey = 'YOUR_API_KEY' order_data = { "side": "buy", "type": "limit", "validity": "GTC", "qty": 100, "routeId": 123, "tradableInstrumentId": 456 } url = f"https://demo.tradelocker.com/backend-api/trade/accounts/{accountId}/orders" headers = { 'accept': 'application/json', 'content-type': 'application/json', 'developer-api-key': apiKey } response = requests.post(url, json=order_data, headers=headers) print(response.json()) ``` -------------------------------- ### Example JSON Response for Account Details Source: https://public-api.tradelocker.com/reference/account This is an example of the JSON response structure received when successfully retrieving account details. It includes an array 'd' containing account objects, each with properties like currency, ID, name, risk rules, status, and trading rules. ```json { "d": [ { "currency": "JPY", "id": "ACC-001", "name": "Demo trading account", "riskRules": { "balanceRelativeDrawdown": 0, "dailyLossLimit": { "value": 0, "warnLevel1": 0, "warnLevel2": 0 }, "dailyProfitTarget": 0, "maxDrawdownLevel": 0, "maxOrderAmount": 0, "maxOrderCapital": 0, "maxOrdersCount": 0, "maxPendingOrdersNumber": 0, "maxPositionsNumber": 0, "maxTrailingDrawdown": 0, "positionLossLimit": 0, "totalMaxPositionQty": 0, "unrealizedLossLimit": { "value": 0, "warnLevel1": 0, "warnLevel2": 0 }, "weeklyLossLimit": { "value": 0, "warnLevel1": 0, "warnLevel2": 0 } }, "status": "ACTIVE", "tradingRules": { "supportBrackets": true, "supportPartialClosePosition": true, "supportSelfTrading": true, "supportTradingOutOfTradingHours": true } } ] } ``` -------------------------------- ### Get Current Daily Bar Response Example (JSON) Source: https://public-api.tradelocker.com/reference/market-data Provides an example of a successful JSON response (HTTP 200 OK) from the /trade/dailyBar endpoint. It outlines the structure of the 'd' object containing OHLCV data and the 's' status field. ```json { "d": { "c": 0, "h": 0, "l": 0, "o": 0, "v": 0 }, "s": "ok" } ``` -------------------------------- ### Get Account Details using Ruby Source: https://public-api.tradelocker.com/reference/account This Ruby script illustrates how to fetch account details using the 'net/http' library. It constructs the GET request, sets the necessary headers, and parses the JSON response. This approach is suitable for standard Ruby environments. ```ruby require 'net/http' require 'uri' require 'json' def get_account_details(acc_num) uri = URI.parse("https://demo.tradelocker.com/backend-api/trade/accounts?accNum=#{acc_num}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) request['accept'] = 'application/json' response = http.request(request) JSON.parse(response.body) end # Example usage: # puts get_account_details(12345) ``` -------------------------------- ### GET /backend-api/trade/config Source: https://public-api.tradelocker.com/reference/config Retrieves the general configuration settings for the trade module, including user access permissions and panel configurations for various trading features. ```APIDOC ## GET /backend-api/trade/config ### Description Retrieves the general configuration settings for the trade module. This includes user access permissions and panel configurations for orders, positions, and other trading-related information. ### Method GET ### Endpoint https://demo.tradelocker.com/backend-api/trade/config ### Parameters #### Query Parameters - **accNum** (int32) - Required - Account number. ### Request Example ``` { "accNum": 123456 } ``` ### Response #### Success Response (200) - **s** (string) - Status, will always be `ok`. - **d** (object) - Data object containing configuration details. - **customerAccess** (object) - Permissions to use specific functions and information in the client terminal. - **filledOrdersConfig** (object) - Panel configuration for filled orders. - **ordersConfig** (object) - Panel configuration for orders. - **ordersHistoryConfig** (object) - Panel configuration for order history. - **positionsConfig** (object) - Panel configuration for positions. - **rateLimits** (object) - Rate limit information. - **limits** (object) - Limit information. #### Response Example ```json { "s": "ok", "d": { "customerAccess": { "orders": true, "ordersHistory": true, "filledOrders": true, "positions": true, "symbolInfo": true, "marketDepth": true }, "positionsConfig": { "id": "positions", "title": "Positions", "columns": [ { "id": "id" }, { "id": "tradableInstrumentId" }, { "id": "routeId" }, { "id": "side" }, { "id": "qty" }, { "id": "avgPrice" }, { "id": "stopLossId" }, { "id": "takeProfitId" } ] } } } ``` #### Error Responses - **401** Unauthorized - **403** Forbidden - **404** Not Found ``` -------------------------------- ### GET /websites/public-api_tradelocker_reference Source: https://public-api.tradelocker.com/reference/modifyorder Retrieves the OpenAPI specification for the TradeLocker Public API. ```APIDOC ## GET /websites/public-api_tradelocker_reference ### Description Retrieves the OpenAPI specification document for the TradeLocker Public API. This endpoint provides the full API schema, including available endpoints, parameters, request/response formats, and security schemes. ### Method GET ### Endpoint /websites/public-api_tradelocker_reference ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **content** (object) - The OpenAPI specification in JSON format. #### Response Example ```json { "openapi": "3.0.0", "info": { "title": "TradeLocker API", "version": "1.0.0" }, "paths": { "/some/endpoint": { "get": { "summary": "Example endpoint", "responses": { "200": { "description": "Successful response" } } } } }, "servers": [ { "url": "https://demo.tradelocker.com/backend-api" } ], "components": { "securitySchemes": { "BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } } ``` ``` -------------------------------- ### Get Account Details Source: https://public-api.tradelocker.com/reference/getaccounts Fetches detailed information about the account specified by the account number. ```APIDOC ## GET /websites/public-api_tradelocker_reference ### Description Detailed information about the account selected by accNum. ### Method GET ### Endpoint /websites/public-api_tradelocker_reference ### Parameters #### Query Parameters - **accNum** (string) - Required - The account number for which to retrieve details. ### Response #### Success Response (200) - **accountDetails** (object) - An object containing the detailed information of the account. - **accountNumber** (string) - The unique identifier for the account. - **balance** (number) - The current balance of the account. - **currency** (string) - The currency of the account. - **accountType** (string) - The type of the account (e.g., 'trading', 'margin'). - **creationDate** (string) - The date when the account was created (ISO 8601 format). #### Response Example ```json { "accountDetails": { "accountNumber": "ACC123456789", "balance": 15000.50, "currency": "USD", "accountType": "trading", "creationDate": "2023-01-15T10:30:00Z" } } ``` ``` -------------------------------- ### Get Account Details using PHP Source: https://public-api.tradelocker.com/reference/account This PHP code snippet demonstrates fetching account details using cURL. It sets up the cURL request, specifies the URL and headers, and executes the request to retrieve the account data. Error handling for the cURL request is included. ```php ``` -------------------------------- ### GET /trade/sessions/{sessionId} Source: https://public-api.tradelocker.com/reference/gettradesession Retrieves detailed information about a specific trade session, including its trading hours and holiday schedule. ```APIDOC ## GET /trade/sessions/{sessionId} ### Description Get detailed information about a specific trade session. ### Method GET ### Endpoint /trade/sessions/{sessionId} ### Parameters #### Path Parameters - **sessionId** (integer) - Required - Identifier of the trade session. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **d** (object) - Contains session details. - **blockTrading** (boolean) - If true, trading will be fully blocked for all instruments for which a selected trade session is active. - **holidays** (array) - The list of national holidays specified for the trading session. - **date** (string) - Holiday date. - **name** (string) - Holiday name. - **session_aftermarket** (object) - Details about aftermarket trading hours on holidays. - **sub_type** (array) - List of aftermarket session types. - **name** (string) - Name of the aftermarket session subtype. - **sessionTime** (array) - Trading hours for the aftermarket session. - **endTime** (string) - Trading period end time. - **startTime** (string) - Trading period start time. - **timeZone** (string) - The time zone of the trading session. - **s** (object) - Contains status information. #### Response Example ```json { "d": { "blockTrading": false, "holidays": [ { "date": "2023-01-01", "name": "New Year's Day", "session_aftermarket": { "sub_type": [ { "name": "Regular", "sessionTime": [ { "endTime": "18:00:00", "startTime": "09:00:00" } ] } ] } } ], "timeZone": "UTC" }, "s": { "code": 0, "message": "Success" } } ``` ``` -------------------------------- ### Get Current Daily Bar Request (cURL) Source: https://public-api.tradelocker.com/reference/market-data Demonstrates how to make a GET request to the /trade/dailyBar endpoint using cURL. It specifies the base URL, query parameters like 'barType', and required headers such as 'accept'. ```shell curl --request GET \ --url 'https://demo.tradelocker.com/backend-api/trade/dailyBar?barType=ASK' \ --header 'accept: application/json' ``` -------------------------------- ### Get account details Source: https://public-api.tradelocker.com/reference/account Retrieves detailed information about the account selected by the `accNum` parameter. ```APIDOC ## GET /backend-api/trade/accounts ### Description Retrieves detailed information about the account selected by `accNum`. ### Method GET ### Endpoint https://demo.tradelocker.com/backend-api/trade/accounts ### Parameters #### Query Parameters - **accNum** (int32) - Required - Account number ### Request Example ```json { "accNum": 12345 } ``` ### Response #### Success Response (200) - **d** (array of objects) - Required - Contains account details. - **currency** (string) - Abbreviation of account currency. - **id** (string) - Required - Unique account identifier. - **name** (string) - Required - Account title that is displayed to a user. - **riskRules** (object) - RiskRules object. - **status** (string) - enum: `ACTIVE`, `CLOSED`, `FINRA_DAY_TRADER_PATTERN`, `LIQUIDATION_ONLY`, `SUSPENDED`, `TRADE_OFF` - Status of the account. - **tradingRules** (object) - TradingRules object. - **type** (string) - enum: `demo`, `live` - Type of the account. - **s** (string) - Required - Status will always be `ok`. #### Response Example ```json { "d": [ { "currency": "JPY", "id": "ACC-001", "name": "Demo trading account", "riskRules": { "balanceRelativeDrawdown": 0, "dailyLossLimit": { "value": 0, "warnLevel1": 0, "warnLevel2": 0 }, "dailyProfitTarget": 0, "maxDrawdownLevel": 0, "maxOrderAmount": 0, "maxOrderCapital": 0, "maxOrdersCount": 0, "maxPendingOrdersNumber": 0, "maxPositionsNumber": 0, "maxTrailingDrawdown": 0, "positionLossLimit": 0, "totalMaxPositionQty": 0, "unrealizedLossLimit": { "value": 0, "warnLevel1": 0, "warnLevel2": 0 }, "weeklyLossLimit": { "value": 0, "warnLevel1": 0, "warnLevel2": 0 } }, "status": "ACTIVE", "tradingRules": { "supportBrackets": true, "supportPartialClosePosition": true, "supportSelfTrading": true, "supportTradingOutOfTradingHours": true }, "type": "demo", "s": "ok" } ] } ``` #### Error Responses - **401** Unauthorized - **403** Forbidden - **404** Not Found ``` -------------------------------- ### Instrument Response Example (JSON) Source: https://public-api.tradelocker.com/reference/instruments-and-sessions This JSON object represents a successful response (HTTP 200 OK) when querying for instrument details. It includes various properties describing the instrument, such as its trading parameters, market data, and status. ```json { "d": { "barSource": "ASK", "baseCurrency": "string", "betSize": 0, "betStep": 0, "bettingCurrency": "string", "contractMonth": "2026-01-17", "country": 0, "deliveryStatus": "DELIVERED", "description": "string", "exerciseStyle": "AMERICAN", "firstTradeDate": "2026-01-17", "hasDaily": true, "hasIntraday": true, "industry": "string", "isin": "string", "lastTradeDate": "2026-01-17", "leverage": 0, "localizedName": "string", "logoUrl": "string", "lotSize": 0, "lotStep": 0, "margin_hedging_type": "string", "marketCap": 0.0, "marketDataExchange": "string", "maxLot": 0, "minLot": 0, "name": "string", "noticeDate": "2026-01-17", "quotingCurrency": "string", "sector": "string", "settlementDate": "2026-01-17", "settlementSystem": "Immediate", "strikePrice": 0, "strikeType": "CALL", "symbolStatus": "FULLY_OPEN", "tickCost": [ { "leftRangeLimit": 0, "tickCost": 0 } ], "tickSize": [ { "leftRangeLimit": 0, "tickSize": 0 } ], "tradeSessionId": 0, "tradeSessionStatusId": 0, "tradingExchange": "string", "type": "CRYPTO" }, "s": "ok" } ``` -------------------------------- ### Get Account Details using cURL Source: https://public-api.tradelocker.com/reference/account This snippet demonstrates how to fetch account details using a cURL request. It specifies the GET method, the API endpoint URL, and the 'accept' header for JSON responses. This is a fundamental way to interact with the API. ```shell curl --request GET \ --url https://demo.tradelocker.com/backend-api/trade/accounts \ --header 'accept: application/json' ``` -------------------------------- ### Place a New Order using TradeLocker API Source: https://public-api.tradelocker.com/reference/placeorder This snippet demonstrates how to place a new order via the TradeLocker public REST API. It requires mandatory fields like quantity, side, instrument ID, order type, route ID, and validity. Price can be set to 0 for market orders. Stop loss and take profit parameters can also be configured. ```json { "openapi": "3.0.0", "info": { "description": "TradeLocker public REST API specification.", "version": "2.11.0", "title": "TradeLocker REST API specification.", "contact": {} }, "tags": [ { "name": "Trading", "description": "Creating, modifying and deleting orders." } ], "paths": { "/trade/accounts/{accountId}/orders": { "post": { "tags": [ "Trading" ], "summary": "Place a new order", "description": "Place a new order.
\nFields `qty, routeId, side, validity, type, tradableInstrumentId` are mandatory inside of the request body. Price can be set to 0 for market orders.\n\nIf using a `stop` type of order, you must specify the `stopPrice`.\n\nValidity (also known as TimeInForce - TIF in some error messages) must be `IOC` for `market` orders and `GTC` for `limit` and `stop` orders.", "operationId": "placeOrder", "parameters": [ { "name": "accountId", "in": "path", "description": "Account identifier.", "required": true, "schema": { "type": "integer", "format": "int32" } }, { "name": "accNum", "in": "header", "description": "Account number", "required": true, "schema": { "type": "integer", "format": "int32" } }, { "name": "developer-api-key", "in": "header", "description": "developer-api-key", "required": false, "schema": { "type": "string" } } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "required": [ "qty", "side", "tradableInstrumentId", "type", "routeId", "validity" ], "properties": { "price": { "type": "number", "description": "Limit Price for Limit order." }, "qty": { "type": "number", "description": "The number of units to open the buy or sell order." }, "routeId": { "type": "number", "description": "Identifier of the trade connection. Find the corresponding INFO or TRADE routeId by querying the /trade/accounts/{accountId}/instruments endpoint." }, "side": { "type": "string", "description": "Order side. If the creating order is a closing one for the position, then the side must\nbe opposite to the side of the position", "enum": [ "buy", "sell" ] }, "strategyId": { "type": "string", "description": "Arbitrary string (up to 31 chars) that can be attached to identify orders and positions placed through algorithmic trading.\nThis value will also be visible in `GET /orders`, `GET /ordersHistory`, and `GET /positions`." }, "stopLoss": { "type": "number", "description": "Stop loss amount for the order. Must be specified in case of `absolute` or `offset` stop loss type." }, "stopLossType": { "type": "string", "description": "Type of stop loss price for the order. Available types: absolute, offset, trailingOffset.", "enum": [ "absolute", "offset", "trailingOffset" ] }, "stopPrice": { "type": "number", "description": "Stop Price for Stop orders." }, "takeProfit": { "type": "number", "description": "TakeProfit amount for the order. Must be specified together with the `takeProfitType` field. Specifies either the absolute price, or an offset in pips." }, "takeProfitType": { "type": "string", "description": "Type of take profit for the order. Available types: [absolute, offset]. Must be specified together with the `takeProfit` field.", "enum": [ "absolute", "offset" ] }, "trStopOffset": { "type": "number" } } } } } } } } } } ``` -------------------------------- ### Get Instrument Details (cURL) Source: https://public-api.tradelocker.com/reference/instruments-and-sessions This snippet demonstrates how to retrieve detailed information about a specific tradable instrument using cURL. It requires the instrument's ID and an authorization token. ```shell curl --request GET \ --url https://demo.tradelocker.com/backend-api/trade/instruments/tradableInstrumentId \ --header 'accept: application/json' \ --header 'authorization: Bearer YOUR_JWT_TOKEN' ``` -------------------------------- ### POST /trade/accounts/{accountId}/orders Source: https://public-api.tradelocker.com/reference/placeorder Place a new order. This endpoint allows you to submit buy or sell orders for trading. Mandatory fields include quantity, route ID, side, validity, type, and tradable instrument ID. Market orders can have a price of 0. Stop orders require a `stopPrice`. ```APIDOC ## POST /trade/accounts/{accountId}/orders ### Description Place a new order. This endpoint allows you to submit buy or sell orders for trading. Mandatory fields include quantity, route ID, side, validity, type, and tradable instrument ID. Market orders can have a price of 0. Stop orders require a `stopPrice`. ### Method POST ### Endpoint `/trade/accounts/{accountId}/orders` ### Parameters #### Path Parameters - **accountId** (integer) - Required - Account identifier. #### Query Parameters None #### Header Parameters - **accNum** (integer) - Required - Account number - **developer-api-key** (string) - Optional - developer-api-key #### Request Body - **qty** (number) - Required - The number of units to open the buy or sell order. - **side** (string) - Required - Order side. If the creating order is a closing one for the position, then the side must be opposite to the side of the position. Enum: `buy`, `sell`. - **tradableInstrumentId** (string) - Required - Identifier of the tradable instrument. - **type** (string) - Required - Order type. Enum: `market`, `limit`, `stop`. - **routeId** (number) - Required - Identifier of the trade connection. Find the corresponding INFO or TRADE routeId by querying the /trade/accounts/{accountId}/instruments endpoint. - **validity** (string) - Required - Validity of the order. Must be `IOC` for `market` orders and `GTC` for `limit` and `stop` orders. Enum: `IOC`, `GTC`. - **price** (number) - Optional - Limit Price for Limit order. - **strategyId** (string) - Optional - Arbitrary string (up to 31 chars) that can be attached to identify orders and positions placed through algorithmic trading. - **stopLoss** (number) - Optional - Stop loss amount for the order. Must be specified in case of `absolute` or `offset` stop loss type. - **stopLossType** (string) - Optional - Type of stop loss price for the order. Enum: `absolute`, `offset`, `trailingOffset`. - **stopPrice** (number) - Optional - Stop Price for Stop orders. - **takeProfit** (number) - Optional - TakeProfit amount for the order. Must be specified together with the `takeProfitType` field. - **takeProfitType** (string) - Optional - Type of take profit for the order. Enum: `absolute`, `offset`. - **trStopOffset** (number) - Optional - Trailing stop offset in pips. ### Request Example ```json { "qty": 100, "side": "buy", "tradableInstrumentId": "EURUSD", "type": "limit", "routeId": 12345, "validity": "GTC", "price": 1.12345, "stopLoss": 1.12000, "stopLossType": "absolute", "takeProfit": 1.13000, "takeProfitType": "absolute" } ``` ### Response #### Success Response (200) - **orderId** (string) - Unique identifier for the placed order. - **status** (string) - The status of the order. Enum: `pending`, `accepted`, `rejected`, `filled`, `partiallyFilled`, `cancelled`. #### Response Example ```json { "orderId": "ord_123abc456def", "status": "accepted" } ``` ``` -------------------------------- ### Fetch JWT Token using Ruby Source: https://public-api.tradelocker.com/reference/auth This Ruby example illustrates how to retrieve a JWT token by making an HTTP POST request to the TradeLocker authentication API using the 'net/http' library. It includes setting the necessary headers and sending the user credentials as a JSON payload. The response is parsed to access the token details. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse('https://demo.tradelocker.com/backend-api/auth/jwt/token') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['accept'] = 'application/json' request['content-type'] = 'application/json' request.body = { email: 'user@example.com', password: 'your_password', server: 'your_server_name' }.to_json response = http.request(request) if response.code == '201' data = JSON.parse(response.body) puts "Access Token: #{data['accessToken']}" puts "Refresh Token: #{data['refreshToken']}" puts "Expire Date: #{data['expireDate']}" else puts "Error: #{response.code} - #{response.body}" end ``` -------------------------------- ### Fetch JWT Token using cURL Source: https://public-api.tradelocker.com/reference/auth This example demonstrates how to fetch a JWT token using a cURL command. It sends a POST request to the authentication endpoint with JSON content type and accepts JSON responses. The body parameters for user credentials (email, password, server) are sent in the request body. ```shell curl --request POST \ --url https://demo.tradelocker.com/backend-api/auth/jwt/token \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data '{ "email": "user@example.com", "password": "your_password", "server": "your_server_name" }' ``` -------------------------------- ### GET /trade/accounts Source: https://public-api.tradelocker.com/reference/getaccounts Retrieves detailed information about a specific account using its account number. ```APIDOC ## GET /trade/accounts ### Description Detailed information about the account selected by accNum. ### Method GET ### Endpoint /trade/accounts ### Parameters #### Header Parameters - **accNum** (integer) - Required - Account number ### Response #### Success Response (200) - **d** (array) - An array of account details. - **currency** (string) - Abbreviation of account currency. - **id** (string) - Unique account identifier. - **name** (string) - Account title that is displayed to a user. - **riskRules** (object) - Rules related to account risk management. - **balanceRelativeDrawdown** (number) - The minimum allowable Projected balance value that the account can have. Max drawdown value calculates as % from the current Balance value. - **dailyLossLimit** (object) - Defines the limits for daily losses. - **value** (number) - The daily loss limit value. - **warnLevel1** (number) - The first warning level for daily losses. - **warnLevel2** (number) - The second warning level for daily losses. - **dailyProfitTarget** (number) - A maximum value of daily net profit allowed for an account. - **maxDrawdownLevel** (number) - The minimal allowed Projected balance value in the account currency for the account not to trigger a Stop out. - **maxOrderAmount** (number) - The maximum amount for a single order measured in the instrument units. - **maxOrderCapital** (number) - The maximum order capital which can be sent by user. Order capital = Qty. * Lot size * Price * Cross price. - **maxOrdersCount** (number) - The maximum number of concurrent orders allowed. - **s** (string) - Status message. #### Response Example ```json { "d": [ { "currency": "JPY", "id": "ACC-001", "name": "Demo trading account", "riskRules": { "balanceRelativeDrawdown": 0.05, "dailyLossLimit": { "value": 1000, "warnLevel1": 500, "warnLevel2": 800 }, "dailyProfitTarget": 2000, "maxDrawdownLevel": 5000, "maxOrderAmount": 100000, "maxOrderCapital": 500000, "maxOrdersCount": 10 } } ], "s": "OK" } ``` ``` -------------------------------- ### Get Trade Session Information (OpenAPI) Source: https://public-api.tradelocker.com/reference/gettradesession This snippet defines the OpenAPI 3.0.0 specification for retrieving detailed information about a specific trade session. It includes parameters for session ID and account number, and outlines the expected JSON response structure for a successful request (200 OK). ```json { "openapi": "3.0.0", "info": { "description": "TradeLocker public REST API specification.", "version": "2.11.0", "title": "TradeLocker REST API specification.", "contact": {} }, "tags": [ { "name": "Instruments and Sessions", "description": "Detailed information about instruments and sessions." } ], "paths": { "/trade/sessions/{sessionId}": { "get": { "tags": [ "Instruments and Sessions" ], "summary": "Get trade session information", "description": "Get detailed information about a specific trade session.", "operationId": "getTradeSession", "parameters": [ { "name": "sessionId", "in": "path", "description": "Identifier of the trade session.", "required": true, "schema": { "type": "integer", "format": "int32" } }, { "name": "accNum", "in": "header", "description": "Account number", "required": true, "schema": { "type": "integer", "format": "int32" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "required": [ "d", "s" ], "properties": { "d": { "type": "object", "required": [ "blockTrading", "timeZone" ], "properties": { "blockTrading": { "type": "boolean", "description": "If true, trading will be fully blocked for all instruments for which a selected trade session is active." }, "holidays": { "type": "array", "description": "The list of national holidays specified for the trading session.", "items": { "type": "object", "properties": { "date": { "type": "string", "format": "date", "description": "Holiday date." }, "name": { "type": "string", "description": "Holiday name." }, "session_aftermarket": { "type": "object", "properties": { "sub_type": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "sessionTime": { "type": "array", "description": "Trading hours. Next sequence is used: sun, mon, tue, wed, thu, fri, sat, shortened day", "items": { "type": "object", "properties": { "endTime": { "type": "string", "description": "Trading period end time" }, "startTime": { "type": "string", "description": "Trading period start time." } }, "title": "SessionTime", "x-readme-ref-name": "SessionTime" } } }, "title": "SubType", "x-readme-ref-name": "SubType" } } }, "title": "SessionPeriod" } }, "title": "Holiday", "x-readme-ref-name": "Holiday" } }, "timeZone": { "type": "string", "description": "Time zone of the trading session." } }, "title": "SessionData", "x-readme-ref-name": "SessionData" }, "s": { "type": "string", "description": "Status of the request." } }, "title": "SessionResponse", "x-readme-ref-name": "SessionResponse" } } } } } } } } } ```