Design a tempTable in class to hold a "matrix" of values

In another post I got to, by the great help of Martin, a solution with a TempTable to hold values.

In post you can see the discussion

So I want to create a class of a TempTable and then GetSettermethods to get and set the values in the table.

If I'm not wrong I can do that by (assume I created a class of type TempTable named "Commodity" 

public real parmOpen(int _id, real _open = 0)

//update value

if(_open != 0)


select forupdate Commodity where == _id; = _open;



return commodity::find(_id).open;


Wrote it form the top of my head, but its about the concept.

What do you think?

Parents Reply
  • Let's talk about the data model before writing code.

    Good idea

    If I understand it correctly, you get the data as a combination of three values: ID, tick type and price. But you want to save it in a different format - you want to have a single record record for all tick types for a single ID, with a field for every tick type.

    Yes I receive it that way. Not sure if I understand you correctly about the different format.

    In a simplistic conceptual way: There are 3 interesting ticktypes: 1(bid),  2(ask) and 7 (open) those come in random order.

    So I want 1 record per _id, with a field named Bid, a field named Ask and a field named Open. (and more fields, see later)

    So those 3 fields are written in the tmpTable in the method onEventTickprice.

    If the field Bid != 0 and field Ask != 0, I fill a 4th field of that same record called Spread.

    Spread is calculated by ask -/- bid.

    In the checkprices method I will compare bid with open, so at that moment I have to read the bid and open from the table.

    In the init I fill more fields per ID with values like deviationtrigger, Qty etc. all used at checkPrices method
    That's why I thought of 1 method per field which can write and read, depending on the params I feed.

    Hope it's clear