Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8193879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:37:56+00:00 2026-06-07T04:37:56+00:00

I have a system where people can pick some stocks and it values their

  • 0

I have a system where people can pick some stocks and it values their portfolios but I’m having trouble doing this in a efficient way on a daily basis because I’m creating entries for days that don’t have any changes(think of it like I’m measuring the values and having version control so I can track changes to the way the portfolio is designed).

Here’s a example(each day’s portfolio with stock name and weight):

Day1:
ibm = 10%
microsoft = 50%
google = 40%

day5:
ibm = 20%
microsoft = 20%
google = 40%
cisco = 20%

I can measure the value of the portfolio on day1 and understand I need to measure it again on day5(when it changed) but how do I measure day2-4 without recreating day1’s entry in the database?

My approach right now(which I don’t like) is to create a temp entry in my database for when someone changes the portfolio and then at the end of the day when I calculate the values if there is a temp entry I use that otherwise I create a new entry(for day2-4) using the last days data. The issue is as data often doesn’t change I’m creating entries that are basically duplicates. The catch is: my stock data is all daily. I also thought of taking the portfolio and if it hasn’t been updated in 3 days to find the returns of the last 3 days for each stock but I wasn’t sure if there was a better solution.

Any ideas? I think this is a straight forward problem but I just can’t see a efficient way of doing it.

note: in finance terms, its called creating a NAV and most firms do it the inefficient way I’m doing it but its because the process was created like 50 years ago and hasn’t changed. I think this problem is very similar to version control but I can’t seem to make a solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:37:58+00:00Added an answer on June 7, 2026 at 4:37 am

    In storage terms is makes most sense to just store:

    UserId – StockId1 – 23% – 2012-06-25
    UserId – StockId2 – 11% – 2012-06-26
    UserId – StockId1 – 20% – 2012-06-30

    So you see that stock 1 went down at 30th. Now if you want to know the StockId1 percentage at the 28th you just select:

    SELECT * 
    FROM stocks 
    WHERE datecolumn<=DATE(2012-06-28) 
    ORDER BY datecolumn DESC LIMIT 0,1
    

    If it gives nothing back you did not have it, otherwise you get the last position back.

    BTW. if you need for example a graph of stock 1 you could left join against a table full of dates. Then you can fill in the gaps easily.

    Found this post here for example:

    UPDATE mytable
    SET number = (@n := COALESCE(number, @n))
    ORDER BY date;
    

    SQL QUERY replace NULL value in a row with a value from the previous known value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP/MySQL sign-up system that limits the number of people who can
I have an inheritance hierarchy with overlap. The system knows about People that can
I'm hoping non-IIS people can help me on this though the issue I'm having
I have a log-in system, where people can login with an username. I really
I have a submission script set up where people can submit their details and
Which system is more natural rating for users? I have a website where people
Suppose I have a complex system where there large trees of people. Simple thoughts
Maybe the C++ and Java people can help me to define this problem I'm
I am trying to set up a system where people can send an email
I have a system where people would upload something, then a single link would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.