Could not Understand Faq right..!

Lets address you querry like this, If you will look at the trades.json file there are multiple stocks namely aapl, msft, googl. Just think of it what you are doing here, you are passing the json file which has to be mapped to your portfolioManagerApplication.java, TiingoCandle t1 = restTemplate.getForObject(url, TiingoCandle.class)
this will give you one object of tiingoCandle mapped with the output of the response from api, and the above command should very well work if the reponse of the api was limited to 1 but what if the response of api is bigger that is there are multiple dictionaries , how do you plan to solve this in that case. Try running the api in your command line using curl, see its output and you will be able to answer your question yourself.

My bad, the list contains multiple dicts.
https://api.tiingo.com/documentation/end-of-day
Check this link for sample response (Examples). Maybe you will get a clear idea.

what I am doing:
loop for the size number of stock in trades.json
{
different url for every stock that is in trades.json;
creating an object t1 for that URL that is specific for a stock;
adding an entry in a Treemap for t1.getClose() for that stock and name of stock;
}
because treeMap is always sorted according to its values;
taking the name of stocks in a new array list;
returning that list;

I am not able to understand how we can make an generalize url that will work for multiple stocks so that we could get array of strings.

maybe this will help

@nabhanpv Please Help !
I understood that point but now I wanna understand
List collection = mapper.readValue(result,new TypeReference<ArrayList>() {});

what is the variable collection?

You have provided as arguments to the readValue() method,

  1. result - which would be the file object for the resource from which you have to read the JSON data
  2. new TypeReference<ArrayList>() - which asks the readValue() method to store contents of the JSON file as an ArrayList of instances of the type TypeReference

Now, the mapper.readValue() method returns an ArrayList of TypeReference objects - just what we asked for. And, collection is the variable which stores the reference to the ArrayList

Hope it helps

Okay I got it what you well explained but I am not able to loop through collection.
I am failing in collection[i] or collection.get(i) …!
How will I be able to extract field from this ArrayList?
If I am not wrong We have to create loop inside loop. first for trades.json symboles and inside it extracting fields from collection ArrayList unique for every stock symbole. Am I on the right track ?

For Module 2,
I think we have to

  1. Call the Tiingo API for each of the stock in trades.json to get the closing price on the given end date
  2. Return a list of stock symbols sorted by their closing price

For easy sorting of an object, you can extend the corresponding class with comparator or comparable

Yes I have already read objectives

What error are you getting when using collection.get(i)?

@Kunal @AmoghaKS
I am getting this error on the mapping of stock name and the closing price on endDate by (HashMap or TreeMap both).
This error when running test case { of filename and endDate }for mainReadQuote

I also tried this but whole program never terminates may be an infinite loop.
List< TiingoCandle > collection = mapper.readValue(result,new TypeReference <List < TiingoCandle > >(){});

Have you defined the type of list, because this should work perfectly fine
List collection = mapper.readValue(result,new TypeReference(){});
but you have add necessary details in this

@sashi_Crio.Do @Saurav_Crio.Do @Rahul-Crio.do It’s been whole week since I’m on module 2.pease help me!

I have also tried this.
List< TiingoCandle > collection = mapper.readValue(result,new TypeReference<ArrayList < TiingoCandle > >(){});

Hey, you are on the right track , when you create an ArrayList of TiingoCandle, it basically maps your JSON to your java object.
You basically have an arrayList of all the values from startDate to endDate.
Now your task is to take the last value in this list. ->(For closing Price, it requires the value from the lastDate of your API call).
You can now make use of a DataStructure like HashMap or a HashSet to use it to sort the Symbols on the basis of its closing values
OR you can refer to this reference given under the taskboard.

This uses a compareTo() function in the TotalReturnsDTO POJO , you can sort on the basis of the values provided in this POJO.
You can refer to this FAQ, if you are getting any further errors.
https://forum.crio.do/t/error-spot-bug-class-defines-compareto-and-uses-object-equals/7127/2

You can tag me, if you have any doubts.

Hope I have solved your problem now :slight_smile:

@vipulkrishna How did you end up solving this error?
I keep getting this error

The type TypeReference is not generic; it cannot be parameterized with arguments <ArrayList<TiingoCandle>>

This line works like magic.

i am getting this error @Rahul-Crio.do @vipulkrishna

This function is for object of ObjectMapper() class
I am not able to guess it as You have posted so short snnipted?