Example #1
0
        /// <summary>
        /// Retrieve instrument history
        /// Get historical information on an instrument
        /// </summary>
        /// <param name="instrument">
        /// Required Name of the instrument to retrieve history for.
        /// The instrument should be one of the available instrument from the /v1/instruments response
        /// </param>
        /// <param name="granularity">
        /// Optional The time range represented by each candlestick. The value specified will determine the alignment of the first candlestick.
        /// </param>
        /// <returns></returns>
        public async Task <Candle <CandleMid> > GetCandlesMid(string instrument, OandaTypes.GranularityType granularity)
        {
            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add("instrument", instrument);
            properties.Add("granularity", granularity);
            properties.Add("candleFormat", OandaTypes.CandleFormat.midpoint);

            Candle <CandleMid> result = await Get <Candle <CandleMid> >(null, properties, _candleRoute);

            return(result);
        }
Example #2
0
        /// <summary>
        /// Retrieve instrument history
        /// Get historical information on an instrument
        /// </summary>
        /// <param name="instrument">
        /// Required Name of the instrument to retrieve history for.
        /// The instrument should be one of the available instrument from the /v1/instruments response
        /// </param>
        /// <param name="granularity">
        /// Optional The time range represented by each candlestick. The value specified will determine the alignment of the first candlestick.
        /// </param>
        /// <param name="start">
        /// The start timestamp for the range of candles requested. The value specified must be in a valid datetime format.
        /// </param>
        /// <param name="end">
        /// The end timestamp for the range of candles requested. The value specified must be in a valid datetime format.
        /// </param>
        /// <returns></returns>
        public async Task <Candle <CandleBidAsk> > GetCandles(string instrument, OandaTypes.GranularityType granularity, DateTime start, DateTime end)
        {
            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add("instrument", instrument);
            properties.Add("granularity", granularity);
            properties.Add("start", start.ToString("o"));
            properties.Add("end", end.ToString("o"));
            properties.Add("candleFormat", OandaTypes.CandleFormat.bidask);

            Candle <CandleBidAsk> result = await Get <Candle <CandleBidAsk> >(null, properties, _candleRoute);

            return(result);
        }