Not sure if this is the right sub to ask this question but I figured it's a good start. I've been gathering data provided by my brokers api. I've used it to calculate things like weekly performance. Everything was working fine using the market value of a position between two dates to calculate the percentage increase. What I didn't think of was, that the calculation would not work correctly anymore if I bought more shares. I can't figure out how to properly calculate the percentage increase in this case and could use some help.
Here are two data points of a position. Essentially one is from the week start and the week end. I've increased my postion in the middle of the week.
Week Start:
"position": 245, "mktPrice": 9.0290003, "mktValue": 2212.11, "avgCost": 8.65110205, "avgPrice": 8.65110205, "realizedPnl": 0, "unrealizedPnl": 92.59
Week End:
"position": 493, "mktPrice": 8.934, "mktValue": 4404.46, "avgCost": 8.8708925, "avgPrice": 8.8708925, "realizedPnl": 0, "unrealizedPnl": 31.11
Are these two data points even enough to calculate the percentage increase or would extra data be needed?
Submitted September 25, 2021 at 12:28PM by eXploit90 https://ift.tt/2ZwnN37