public bool login(String userName, String password) { Http.RestCaller restCaller; restCaller = new Http.RestCaller(); var requestBuilder = new UriBuilder("https://api.tdameritrade.com/v1/oauth2/token"); var values = new Dictionary <string, string>() { { "grant_type", "authorization_code" }, { "access_type", "offline" }, //{"code", Request.Query["code"].ToString()}, //{"code", "0".ToString()}, { "code", "" }, { "client_id", "" }, { "redirect_uri", "http://127.0.0.1/" } }; //HttpContent content = new FormUrlEncodedContent(values); FormUrlEncodedContent content = new FormUrlEncodedContent(values); //content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded"); var response = restCaller.Post(requestBuilder.ToString(), content); return(true); }
/// <summary> /// Queries a Real-Time quote from Yahoo! This is the main method that needs to pass for a simple OHLC call. /// </summary> /// <param name="Symbol">The symbol to acquire the real time quote</param> /// <returns>returns the date, volume, and candle for the day as a real time quote</returns> public Candle GetQuote(String Symbol) { string Url = GetQuoteUrl(Symbol); String cvsData = ""; Candle candle = new Candle(); Http.RestCaller restCaller = new Http.RestCaller(); cvsData = restCaller.Get(Url); var data = JsonConvert.DeserializeObject <RootObject>(cvsData); //OHCL candle.Date = (data.quoteResponse.Result[0].market == "REGULAR") ? candle.Date = DateTime.Now : candle.Date = DateTime.Today; candle.Open = System.Convert.ToDecimal(data.quoteResponse.Result[0].regularMarketOpen); candle.High = System.Convert.ToDecimal(data.quoteResponse.Result[0].regularMarketDayHigh); candle.Close = System.Convert.ToDecimal(data.quoteResponse.Result[0].regularMarketPrice); candle.Low = System.Convert.ToDecimal(data.quoteResponse.Result[0].regularMarketDayLow); candle.Volume = System.Convert.ToDecimal(data.quoteResponse.Result[0].regularMarketVolume); return(candle); }
public ApiYahoo() { restCaller = new Http.RestCaller(); }
public ApiGoogle() { restCaller = new Http.RestCaller(); ApiGoogleHelper.Style.PopulateStyles(); }