@dknutsen No need to apologize, thank you for the long explanation, I am a financial planner and not a professional developer after all, so I need all the help I can get lol. I’m actually kind of glad you acknowledged that this is pretty complex, because I was thinking I just wasn’t smart enough for this stuff! Everything you said made sense though. I did get hung up on whether ember-data was even good for this project, but I think I’m stuck without it? The idea of making a model for the historical data really makes sense.
This is a real API response I’d be working with: https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY_ADJUSTED&symbol=MSFT&apikey=demo
So one specific question I have is where to store Portfolio Allocation percentages, because each portfolio is made up of different funds. It’ll probably also help to understand what I’m really trying to create, which is a table that lists time-interval performance/returns for a handful of portfolios where each portfolio has a number stocks/mutual funds, etc as you guessed. So right now this is how I do this without using ember-data…
// performance.js route
model() {
return RSVP.hash({
SLGAX: this.get("ajax") // SEI LARGE CAP
.request("https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY_ADJUSTED&symbol=SLGAX&apikey=**", {
})
.then(SLGAX => {
return SLGAX;
}),
// and so forth forth for each mutual fund
Then I created a computed property for each time period performance in my component (I know now this should probably be done in a controller). 5-6 lines of code for each computed property, times a couple dozen stocks/mutual funds… that’s a lot of repeated code!
SLGAXMonthToDate: computed('model.SLGAX', function() {
let SLGAX = this.model.SLGAX;
let listOfDates = Object.keys(SLGAX['Monthly Adjusted Time Series'])
let finalAdjClose = parseFloat(SLGAX['Monthly Adjusted Time Series'][listOfDates[0]]['5. adjusted close']);
let lastMonthAdjClose = parseFloat(SLGAX['Monthly Adjusted Time Series'][listOfDates[1]]['5. adjusted close']);
return ((((finalAdjClose - lastMonthAdjClose) / lastMonthAdjClose) * 100).toFixed(2))
}),
It get’s even more complex knowing that each portfolio is made up different mutual funds, but they all have a different weight in the portfolio. So Portfolio A has Stock A and Stock B, but it isn’t 50/50. Stock A might make up 60% of the portfolio, for example.
Ideally a user could create a Portfolio in the app, add funds to it and specify the % weight of each fund, and the app would add that portfolio to the table and calculate the returns for each time period. Thanks so much for being willing to provide me with some guidance here, especially with the conceptual questions! I really appreciate it.
Here’s the table I’ve already created just for monitoring returns of each individual fund. It works well for what it is, albeit the amount of computed property code is over the top.