Unable to Understand Alpha Vantage Api

I Tried to Map to AlphaVantageDailyResponse got Key Deserializer error
I Tried to map to AlphaVantage Candle got unknown fields
how to map those

If you will look at the structure of response of alphavantage api, it is very clear that the response cannot be directly mapped into alphavantageCandle. However Crio has provided necessary files to proceed with the mapping. As you have already mentioned alphavantageDailyResponse, try to understand the structure of it, see if you can use the method provided in the alphavantageDailyResponse, once you will get through these questions you will be able to map the response quite easily :slight_smile:

i understood that its only taking the second part not the metadata through DailyResponse Main Issue i face is Key Deserializer as of now.Wont i need to do this if i try to use methods in it

Understanding alphavantageDailyResponse is a very important task for the current scenario, you have to figure how you can use the class to map responses from the api.
Secondly once you are able to do so, you have to figure how you can operate on the response you have just mapped, does alphavantageDailyResponse provides a class method which can help you accomplish the same?
Thirdly once you have been able to figure out all these, then selecting responses based on dates and sorting them will be a cake walk. :slight_smile:

2 Likes

I am Getting MetaDeta into Response How do i ignore it?

That is not necessary you can try running the api using postman

Hey @Kunal I have one doubt.

AlphavantageCandle has a member variable of Date but response from API does not have date as a key (like “1. open”) because it wil be the 1st value in the map. How will we handle that?

I hope you are getting what I am trying to say.

I too have the same issue.

image

You need to first map the Alpha Vantage response to alphavantageDailyResponse and then to alphavantageCandle format. Don’t forget to implement the candle file beforehand. Talking about how to map the dates in the candle, you may implement a setDate function in the candle file to do that.

Hey @saikiran0802

  • You are getting Deserializer error when you are using AlphaVantageDailyResponse because of Localdate Data type in AlphaVantageDailyResponse so take care of that maximum time it happens because of Localdate.

  • As mentioned in task you have to extract data or get the data from startDate to endDate so you have to use AlphaVantageDailyResponse to call data in map format then use Candle interface via alphavantagecandle.java to extract fields from startDate To endDate.

Thanks

You can use jackson annotation for the same,
You can follow this link for further reference

Do read the resources given in AlphavantageCandle file and a slight trick : You could look up the structure of the api result in the test file.

How do i apply the Second Filter(AlphaVantageCandle) to map those values to that object

i tried and got build successful but could run spring boot application gives error
“trace”: "java.lang.NullPointerException\n\tat com.crio.warmup.stock.quotes.StockQuoteServiceFactory.getService(StockQuoteServiceFactory.java:26)\n\tat com.crio.warmup.stock.portfolio.PortfolioManagerFactory.getPortfolioManager(PortfolioManagerFactory.java:28)\n\tat com.crio.stock.annualreturnapp.AnnualReturnsController.calculateReturns(AnnualRet

Hi @saikiran0802,

From the stacktrace, I’ll recommend you start with line 2 of StockQuoteServiceFactory, see why its getting a null value and where is that null value coming from.

My analysis, its possible you are not explicitly checking if the passed provider string is null or not. Please do that if you aren’t already doing it and return the right service, before checking the string further.

Maybe you wrote the code to check string for ‘tiingo’ only to return a service and return the other service in all other cases. This code won’t work if provider string is null. You need to check for null first.

Let me know if this helps!

in case if its null what should i return

The TODOs say that in that scenario Alpha Vantage needs to be returned

i had modified it but i get compileTest Error error after whole build was successful

That’s something you’ll need to figure out. But unless you check explicitly for null using an if statement, it’s not evaluated.