Giter VIP home page Giter VIP logo

Comments (4)

thakkarparth007 avatar thakkarparth007 commented on June 12, 2024

The least flexible solution for part 2 is to simply have multiple tables for each interval. That way querying would be simply SELECT * from the right table with the right limits. But that will require storing duplicate data (not an issue because the storage will be small - if we assume the game lasts for 10 days running 6 hours each day, for interval of 1 minute we'll have about 6 x 60 x 10 = 3600 rows, and each row would store OHLC (Open High Low Close) integers, rowid, stockid, time and maybe something else that I'm missing. Overall each row will have 4 + 1 + 1 integers (4 bytes each) and a timestamp string (20 bytes). Overall each row will have 40-50 bytes. That's 180kb for one stock. If we have 30 stocks the space for the history will be only 5.4MB for 1min interval. With other intervals this could maybe grow to 20-30MB. That's not an issue at all.

The problem with that is that adding new intervals or something like that will be painful.

If we have only a single Stock history table querying becomes quite complex.

from dalal-street-server.

coderick14 avatar coderick14 commented on June 12, 2024

We can use a single table StockHistory (or any other name) where we store the details of each stock at one minute intervals. Now, to get the stock history at every N minute intervals, we use the following query

SELECT * FROM StockHistory WHERE MOD(ID, N) = 0;

Thus, storing stock history in a single table at one minute intervals will suffice.

Note that this assumes there will be no deletions or rollbacks. But there won't be any in this case. So we can use the above query safely.
@Ar-Sibi @thakkarparth007

from dalal-street-server.

thakkarparth007 avatar thakkarparth007 commented on June 12, 2024

@Ar-Sibi we'll go ahead with this.

from dalal-street-server.

thakkarparth007 avatar thakkarparth007 commented on June 12, 2024

Fixed by #108

from dalal-street-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.