D
DoctorWhoKnew
Guest
I am downloading stock data in the following code:
[HttpGet]
public async Task<ActionResult> Get()
{
var Client = _httpClientFactory.CreateClient();
string result = await Client.GetStringAsync("https://api.iextrading.com/1.0/stock/msft/chart/1y");
return Ok(result);
}
This is the data I get on the page:
"[{\"date\":\"2017-10-24\",\"open\":77.5032,\"high\":77.7979,\"low\":77.071,\"close\":77.4639,\"volume\":17517182,\"unadjustedVolume\":17517182,\"change\":0.02947,\"changePercent\":0.038,\"vwap\":77.4904,\"label\":\"Oct 24, 17\",\"changeOverTime\":0},{\"date\":\"2017-10-25\",\"open\":77.1889,\"high\":77.6996,\"low\":76.6289,\"close\":77.238,\"volume\":20410808,\"unadjustedVolume\":20410808,\"change\":-0.225928,\"changePercent\":-0.292,\"vwap\":77.178,\"label\":\"Oct 25, 17\",\"changeOverTime\":-0.0029161970930975047},{\"date\":\"2017-10-26\",\"open
I create this class to match the file data
public class IexTradingStock
{
public int Id { get; set; }
public DateTime Date { get; set; }
public decimal Open { get; set; }
public decimal High { get; set; }
public decimal Low { get; set; }
public decimal Close { get; set; }
public long Volume { get; set; }
public long UnadjustedVolume { get; set; }
public decimal Change { get; set; }
public decimal ChangePercent { get; set; }
public decimal Vwap { get; set; }
public DateTime Label { get; set; }
public long ChangeOvertime { get; set; }
}
I believe I should use a list of all of the objects. How may I put the file data into a list of objects I can access such as the date and closing price to calculate a moving average?
Continue reading...
[HttpGet]
public async Task<ActionResult> Get()
{
var Client = _httpClientFactory.CreateClient();
string result = await Client.GetStringAsync("https://api.iextrading.com/1.0/stock/msft/chart/1y");
return Ok(result);
}
This is the data I get on the page:
"[{\"date\":\"2017-10-24\",\"open\":77.5032,\"high\":77.7979,\"low\":77.071,\"close\":77.4639,\"volume\":17517182,\"unadjustedVolume\":17517182,\"change\":0.02947,\"changePercent\":0.038,\"vwap\":77.4904,\"label\":\"Oct 24, 17\",\"changeOverTime\":0},{\"date\":\"2017-10-25\",\"open\":77.1889,\"high\":77.6996,\"low\":76.6289,\"close\":77.238,\"volume\":20410808,\"unadjustedVolume\":20410808,\"change\":-0.225928,\"changePercent\":-0.292,\"vwap\":77.178,\"label\":\"Oct 25, 17\",\"changeOverTime\":-0.0029161970930975047},{\"date\":\"2017-10-26\",\"open
I create this class to match the file data
public class IexTradingStock
{
public int Id { get; set; }
public DateTime Date { get; set; }
public decimal Open { get; set; }
public decimal High { get; set; }
public decimal Low { get; set; }
public decimal Close { get; set; }
public long Volume { get; set; }
public long UnadjustedVolume { get; set; }
public decimal Change { get; set; }
public decimal ChangePercent { get; set; }
public decimal Vwap { get; set; }
public DateTime Label { get; set; }
public long ChangeOvertime { get; set; }
}
I believe I should use a list of all of the objects. How may I put the file data into a list of objects I can access such as the date and closing price to calculate a moving average?
Continue reading...