instrument_history: Get instrument history

Description Usage Arguments Value Note Examples

Description

Get historical information on an instrument

Usage

1
2
3
4
5
6
7
instrument_history(token, instrument, granularity = c("S5", "S10", "S15",
  "S30", "M1", "M2", "M3", "M4", "M5", "M10", "M15", "M30", "H1", "H2", "H3",
  "H4", "H6", "H8", "H12", "D", "W", "M"), count = 500, start = NULL,
  end = NULL, candleFormat = c("bidask", "midpoint"), includeFirst = TRUE,
  dailyAlignment = 21, alignmentTimezone = "America/New_York",
  weeklyAlignment = c("Friday", "Saturday", "Sunday", "Monday", "Tuesday",
  "Wednesday", "Thursday"), accountType = c("Trade", "Practice"))

Arguments

token

The personal access token. There is a link on your OANDA fxTrade account profile page titled 'Manage API Access' (My Account -> My Services -> Manage API Access). From there, you can generate a personal access token to use with the OANDA API, as well as revoke a token you may currently have.

instrument

Name of the instrument to retrieve history for. The instrument should be one of the available instrument from the instrument_list response.

granularity

The time range represented by each candlestick. The value specified will determine the alignment of the first candlestick. Default is 5 seconds.

count

The number of candles to return in the response. Count willl be ignored if both the start and end parameters are also specified. If not specified, count will default to 500. The maximum acceptable value for count is 5000.

start

The start timestamp for the range of candles requested. It must be a string in the following format: YYYY-MM-DD HH:MM:SS (UTC).

end

The end timestamp for the range of candles requested. It must be a string in the following format: YYYY-MM-DD HH:MM:SS (UTC).

candleFormat

Candlesticks representation (about candestick representation). This can be one of the following: 'midpoint' - Midpoint based candlesticks. 'bidask' - Bid/Ask based candlesticks The default for candleFormat is 'bidask' if the candleFormat parameter is not specified.

includeFirst

If includeFirst is set to TRUE, the candlestick covered by the start timestamp will be returned. If it is set to FALSE, this candlestick will not be returned. This field exists so clients may easily ensure that they can poll for all candles more recent than their last received candle. The default for includeFirst is TRUE if the includeFirst parameter is not specified.

dailyAlignment

The hour of day used to align candles with hourly, daily, weekly, or monthly granularity. The value specified is interpreted as an hour in the timezone set through the alignmentTimezone parameter and must be an integer between 0 and 23. The default for dailyAlignment is 21 when Eastern Daylight Time is in effect and 22 when Eastern Standard Time is in effect.

alignmentTimezone

The timezone to be used for the dailyAlignment parameter. This parameter does NOT affect the returned timestamp, the start or end parameters, these will always be in UTC. The timezone format used is defined by the IANA Time Zone Database, a full list of the timezones supported by the REST API can be found here: http://developer.oanda.com/docs/timezones.txt. The default for alignmentTimezone is 'America/New_York' if the alignmentTimezone parameter is not specified.

weeklyAlignment

The day of the week used to align candles with weekly granularity. The value specified will be used as the start/end day when calculating the weekly candles. Valid values are: 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'. The default for weeklyAlignment is 'Friday' if the weeklyAlignment parameter is not specified.

accountType

The subdomain for the request is dependent on the environment you wish to obtain access tokens for. Possible choices are Practice or Trade

Value

A data frame with time, openBid, openAsk, highBid, highAsk, lowBid, lowAsk, closeBid, closeAsk, volume and complete

Note

Valid values for the granularity are:
Seconds: 'S5', 'S10', 'S15', 'S30' - 5,10,15,30 seconds
Minutes: 'M1', 'M2', 'M3', 'M4', 'M5', 'M10', 'M15', 'M30', 1,2,3,4,5,10,15,30 minutes
Hours: 'H1', 'H2', 'H3', 'H4', 'H6', 'H8', 'H12' - 1,2,3,4,6,8,12 hours
Days: 'D' - 1 day
Weeks: 'W' - 1 week
Months: 'M' - 1 month

Examples

1
instrument_history(token, 'EUR_USD', accountType = 'Practice', start = '2015-01-01 12:00:00', end = '2015-01-29 12:00:00', granularity = 'M10')

RossiLorenzo/oandaR documentation built on May 9, 2019, 10:32 a.m.