public static OandaCandle[] LoadLiveCandles(string instrument, string granularity, int count = 5000) { string url = $"{practice}/v3/instruments/{instrument}/candles?price=M&granularity={granularity}&count={count}"; var request = (HttpWebRequest)WebRequest.Create(url); request.Headers["Authorization"] = $"Bearer {_token}"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string json; using (var sr = new StreamReader(response.GetResponseStream())) { json = sr.ReadToEnd(); } var result = OandaCandles.FromJson(json); return(result.Candles); }
private static OandaCandles GetCandles(string instrument, string granularity, DateTimeOffset from) { string url = $"{practice}/v3/instruments/{instrument}/candles?price=M&granularity={granularity}&from={from.ToRfc3339()}&count=5000"; var request = (HttpWebRequest)WebRequest.Create(url); request.Headers["Authorization"] = $"Bearer {_token}"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string json; using (var sr = new StreamReader(response.GetResponseStream())) { json = sr.ReadToEnd(); } var result = OandaCandles.FromJson(json); return(result); }
public static string ToJson(this OandaCandles self) => JsonConvert.SerializeObject(self, FxEngine.Library.Converter.Settings);