InstrumentsCandles¶
-
class
oandapyV20.endpoints.instruments.
InstrumentsCandles
(instrument, params=None)¶ Bases:
oandapyV20.endpoints.instruments.Instruments
Get candle data for a specified Instrument.
-
ENDPOINT
= 'v3/instruments/{instrument}/candles'¶
-
EXPECTED_STATUS
= 200¶
-
METHOD
= 'GET'¶
-
__init__
(instrument, params=None)¶ Instantiate an InstrumentsCandles request.
Parameters: - instrument (string (required)) – the instrument to fetch candle data for
- params (dict) – optional request query parameters, check developer.oanda.com for details
Params example:
{ "count": 5, "granularity": "M5" }
Candle data example:
>>> import oandapyV20 >>> import oandapyV20.endpoints.instruments as instruments >>> client = oandapyV20.API(access_token=...) >>> params = ... >>> r = instruments.InstrumentsCandles(instrument="DE30_EUR", >>> params=params) >>> client.request(r) >>> print r.response
Output:
{ "candles": [ { "volume": 132, "mid": { "h": "10508.0", "c": "10506.0", "l": "10503.8", "o": "10503.8" }, "complete": true, "time": "2016-10-17T19:35:00.000000000Z" }, { "volume": 162, "mid": { "h": "10507.0", "c": "10504.9", "l": "10502.0", "o": "10506.0" }, "complete": true, "time": "2016-10-17T19:40:00.000000000Z" }, { "volume": 196, "mid": { "h": "10509.8", "c": "10505.0", "l": "10502.6", "o": "10504.9" }, "complete": true, "time": "2016-10-17T19:45:00.000000000Z" }, { "volume": 153, "mid": { "h": "10510.1", "c": "10509.0", "l": "10504.2", "o": "10505.0" }, "complete": true, "time": "2016-10-17T19:50:00.000000000Z" }, { "volume": 172, "mid": { "h": "10509.8", "c": "10507.8", "l": "10503.2", "o": "10509.0" }, "complete": true, "time": "2016-10-17T19:55:00.000000000Z" } ], "granularity": "M5", "instrument": "DE30/EUR" }
-