Web Query
New in Latinum 3.3.0, from March 27 2015
The Web Query server allows retrieving up-to-date prices, historic candles and tick data with any application or programming language that supports HTTP and JSON.
WebQuery is for programmatically exporting price data from Latinum, it cannot be used to import data. WebQuery is only compatible with FXCM (ForexConnect) connections only.
API URL
Default URL
http://localhost:5000
The port number is configurable in the Preferences or Options dialog window. This documentation uses the default port number (5000) for the examples. The port number must not be in use by another application when you launch Latinum. The port number can be overridden using the LATINUM_WEBQUERY_PORT
environment variable.
The default port number in Benchmark is also 5000, one will need to change if you want to use both WebQuery servers at the same time.
Notes
- Some requests use chunked transfer encoding, each JSON document is separated by
\r\n
(CR+LF). - Input date times are ISO 8601 formatted or Unix time in seconds
- Output date times are ISO 8601 formatted or Unix time in milliseconds.
- Set date format with the
X-Accept-Datetime-Format
header with value “unix” or “isodate” (default). - Some FXCM Demo accounts only return timestamps with second resolution.
Do’s
- Do handle unexpected or missing fields.
Dont’s
- Don’t expect field values to be in any particular order. Attributes of a JSON object are unordered.
Streaming Prices
GET /v1/stream/prices
Open a streaming connection to receive updating market quotes for all subscribed instruments.
Parameters
instruments = comma separated list of symbols, symbols must be subscribed in Latinum. (optional) If instruments in not specified, only instruments with an open chart will be streamed. includeSnapshot = if “false” the current snapshot of prices will not be streamed (optional) String, “true” or “false”. Default “true”
Examples
Example Request:
http://localhost:5000/v1/stream/prices?instruments=AUD/USD,EUR/USD
Example Response:
Transfer-Encoding: chunked {"tick":{"instrument":"EUR/USD","time":"2015-03-16T09:37:59Z","bid":1.05342,"ask":1.05365,"volume":117}} {"tick":{"instrument":"AUD/USD","time":"2015-03-16T09:38:06Z","bid":0.76325,"ask":0.76346,"volume":8}} {"tick":{"instrument":"EUR/USD","time":"2015-03-16T09:38:13Z","bid":1.05342,"ask":1.05367,"volume":1}} {"tick":{"instrument":"EUR/USD","time":"2015-03-16T09:38:14Z","bid":1.05342,"ask":1.05366,"volume":2}} {"tick":{"instrument":"EUR/USD","time":"2015-03-16T09:38:14Z","bid":1.05342,"ask":1.05367,"volume":3}}
Get Instruments
GET /v1/instruments
Parameters
instruments = comma separated list of symbols. (optional) columns = specify columns to be returned, default “instrument”,”displayName”,”pip” (optional) Valid column names: instruments – always returned displayName pip precision
Examples
Example Request:
http://localhost:5000/v1/instruments?instruments=AUD/USD,EUR/USD
Example Response:
{ "instruments": [ { "instrument": "EUR/USD", "displayName": "EUR/USD", "pip": "0.0001" }, { "instrument": "AUD/USD", "displayName": "AUD/USD", "pip": "0.0001" } ] }
Get Prices
GET /v1/prices
Parameters
instruments = comma separated list of symbols. (optional) since = unix time (seconds) or ISO date, return prices that changed after the specified timestamp. (optional, exclusive)
Examples
Example Request:
http://localhost:5000/v1/prices?instruments=AUD/USD,EUR/USD
Example Response:
{ "prices": [ { "instrument": "EUR/USD", "time": "2015-03-27T03:26:22.000Z", "bid": 1.08804, "ask": 1.0883, "high": 1.08972, "low": 1.08636 }, { "instrument": "AUD/USD", "time": "2015-03-27T03:26:21.000Z", "bid": 0.78057, "ask": 0.7808, "high": 0.78375, "low": 0.77906 } ] }
Get Candles
GET /v1/candles
Parameters
instrument = symbol of the instrument (required) interval: interval of each candle in seconds (optional) Valid interval codes: 60 = 1 minute 300 = 5 minute 900 = 15 minute 1800 = 30 minute 3600 = 1 hour 7200 = 2 hour 10800 = 3 hour 14400 = 4 hour 21600 = 6 hour 28800 = 8 hour 86400 = 1 day 604800 = 1 week 2592000 = 1 month start = start date in Unix time (seconds) or ISO date. (optional, inclusive) end = end date in Unix time (seconds) or ISO date. (optional, inclusive) count = maximum number of bars. default 300, maximum 5000, minimum 2. (optional) The WebQuery server may ignore the count value when start or end is specified. field = string; “bid”, “ask”, or “mid”. default is “bid” (optional) includeWeekends = if “false” only Monday through Friday data is included. (optional) String, “true” or “false”. Default “false”
Examples
Example Request:
http://localhost:5000/v1/candles?instrument=AUD/USD&interval=900&count=3
Example Response:
Transfer-Encoding: chunked {"time":"2015-03-16T09:00:00Z","open":0.76383,"high":0.76415,"low":0.76241,"close":0.7625,"volume":1948} {"time":"2015-03-16T09:15:00Z","open":0.7625,"high":0.76328,"low":0.76217,"close":0.76303,"volume":2500} {"time":"2015-03-16T09:30:00Z","open":0.76303,"high":0.76332,"low":0.76293,"close":0.76325,"volume":803}
Get Ticks
GET /v1/ticks
Parameters
instrument = symbol of the instrument (required) start = start date in Unix time (seconds) or ISO date. (optional, inclusive) end = end date in Unix time (seconds) or ISO date. (optional, inclusive) count = maximum number of ticks. default 1000, maximum 5000, minimum 2. (optional) The WebQuery server may ignore the count value when start or end is specified. includeWeekends = if “false” only Monday through Friday data is included. (optional) String, “true” or “false”. Default “false”
Examples
Example Request:
http://localhost:5000/v1/ticks?instrument=AUD/USD&count=3
Example Response:
Transfer-Encoding: chunked {"time":"2015-03-16T09:37:56Z","bid":0.76326,"ask":0.76346} {"time":"2015-03-16T09:37:56Z","bid":0.76326,"ask":0.76347} {"time":"2015-03-16T09:37:57Z","bid":0.76325,"ask":0.76347}