structure interrelated baskets

Discussion in 'Programming' started by 2rosy, Mar 11, 2013.

  1. 2rosy

    2rosy

    i have various baskets of stocks that are related to each other by one or two stocks
    1) A,B,C
    2) C,D,E
    3) E,F,G
    4) E,G,H

    whats the best structure or structures to keep track of them so when a price comes in for C i reprice basket 1 and 2, when a price comes in for E i reprice 2,3,4
     
  2. Sounds like something a good currency trader would know
     
  3. hoppla

    hoppla

    How about each stock [object] holds a reference to a container/collection of baskets (where it is a member of) where each basket itself is a container/ collection of references to the stocks? So whenever a stock's price updates you enumerate over the basket collection/ container and call a reprice method. Since you're working with references you'd always have the most-up-to-date price of any basket if you were to require the current baskets' price from elsewhere in your code.
     
  4. sma202

    sma202

    create a single array of prices A..Z which has pointers to the various baskets. More or less like a hashmap.