Skip to content

7. Historical prices

Arthika edited this page Mar 9, 2016 · 34 revisions

Historical prices polling

The 'getHistoricalPrice' (polling) request returns a single set of up to 150 candles with a granularities ranging from 1 second to 6 hours. Price candles are typically used to initialise a trading strategy.
Please note that although it would be syntactically correct to request 150 6-hours candles, more than 30 days, this would exceed the capacity of the REST API price buffer that stores one-week worth of data (Five days, or current week or...) with a 1 second granularity.

Example

Request the last two ("number":2) 1-second candles ("granularity":"s1") with ask ("side":"ask") prices from the demo account:

curl -i --data '{"getHistoricalPrice":{"user":"demo","token":"E79133C6902B63D2E5F5D9E9F1E658019F143675","security":["EUR/USD"],"granularity":"s1","side":"ask","number":2}}' http://certification.arthikatrading.com:83/fcgi-bin/IHFTRestAPI/getHistoricalPrice --header 'Content-Type: application/json'
HTTP/1.1 200 OK
Date: Tue, 01 Mar 2016 11:10:36 GMT
Server: Apache/2.4.7 (Ubuntu)
Transfer-Encoding: chunked
Content-Type: application/json

{ "getHistoricalPriceResponse": { "candle": [ { "security": "EUR\/USD", "tinterface": "LMAX_LMAX", "timestamp": 1456830635, "side": "ask", "open": 1.087270, "high": 1.087270, "low": 1.087270, "close": 1.087270, "ticks": 2 }, { "security": "EUR\/USD", "tinterface": "LMAX_LMAX", "timestamp": 1456830633, "side": "ask", "open": 1.087270, "high": 1.087270, "low": 1.087270, "close": 1.087270, "ticks": 2 } ], "timestamp": "1456830636.155432" } }

getHistoricalPrice()

Request: getHistoricalPrice object

  • user: Required. Strategy login assigned by the backend administrator.
  • token: Required. Token obtained during the authentication procedure.
  • security: Required. List of securities/instruments whose prices will be returned.
  • tinterface: Optional. List of trading interfaces whose prices will be returned. Default value: All.
  • granularity: Optional. One of the following: {s1, s5, s10, s30, m1, m5, m10, m30, h1, h2, h6}, where 's' stands for seconds, 'm' for minutes, 'h' for hours. Default value: s1.
  • side: Optional. Can be 'ask', 'bid' or 'both'. Default value: 'both'.
  • number: Optional. The number of candles to be delivered. Maximum value: 512. Default value: 128. If side is 'both' twice the number candles is delivered; for example the maximum 512 value would result in 1024 candles, 512 on each side. If the streaming price buffer is not yet filled to capacity the request may deliver less candles than requested.

Response: getHistoricalPriceResponse object

  • candle: Object that includes a list of candles with following fields:

    • security: Instrument name.
    • tinterface: Trading intarface name where price has been reported. Please refer to getInterface() web-service.
    • timestamp: The Epoch time at the start of the candle's period, in seconds.
    • side: Which type (side) side the candle prices are, ask or bid.
    • open: The price at the start of the candle's period.
    • high: The highest price reached over the candle interval.
    • low: The lowest price reached over the duration of the candle.
    • close: The price at the end of the candle's period.
    • ticks: The number of price changes that have the candle has been .
  • timestamp: Epoch time of the response. Decimals define the number of micro-seconds. Integer part represents the seconds from "epoch" time.

Historical prices streaming

** Note: ** Candles streaming is under development and will be delivered soon jointly with the streaming of Technical Analysis Library indicators..