I have an data object like below :
public class RootObject
{
public string ticker {get;set;}
public List<Result> results {get;set;}
}
and Result Object is like :
{
public double open {get;set;}
public double close {get;set;}
}
Now every time I will be multiple result for same ticker. So I want to add all result elements into same ticker. Instead of create it to multiple times into list.
public static List<RootObject> minuteAggregateList = new List<RootObject>();
public void historicalMinuteAggData(string symbol)
{
int daysCount = 0;
for(int i=1; i<=20; i++)
{
DateTime date = DateTime.Now.Date.AddDays(-i);
if (date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday)
{
daysCount++;
var startUnixTime = (date.Add(new TimeSpan(13, 30, 00)).Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds;
var endUnixTime = (date.Add(new TimeSpan(20, 00, 00)).Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds;
using (var reader = new StreamReader(new WebClient().OpenRead(string.Format("API For Fetch Data"))))
{
var x = reader.ReadLine();
RootObject data = JsonConvert.DeserializeObject<RootObject>(x);
minuteAggregateList.Add(data);
}
}
if (daysCount == 7)
break;
}
}
Right now it's giving us multiple Results for same ticker in minuteAggregateList. How ever I need like if AAPL is in list then add new element in nested Result of AAPL. So how to make it possible to add elements in nested position under particular ticker ?