4

I have the following function in q:

{
    raze {[x]
        update PnlTime:x from
            flip ?[getPnl[`date`status!(2013.05.14;`traded)];
            ();();`date`Id`market`pnl!(`date;`Id;`market;x)]
    } each `pnl_0s`pnl_1s`pnl_5s
}

Here, I am retrieving data for a particular date from function getPnl and creating a new column pnl by joining pnl_0s etc. How can I modify this query so as to pass a time range (firstdate;lastdate)?

mollmerx
  • 648
  • 1
  • 5
  • 18
anu
  • 295
  • 2
  • 7
  • 15

1 Answers1

4

Best answer depends on your table. If this a date-splayed table I'd imagine the best place to do this is inside the getPnl function. Presumably it's doing something like:

select from aTable where date=x,....

Replace with:

select from aTable where date within (d1;d2),...

For a date-splayed table there is no hit for "date=" vs "date within" when d1==d2.

If you don't have access to this function unfortunately you'll need to do another each, something like this:

say d1=2014.01.01, d2=2014.02.14

raze {[x] getPnl[`date`status!(x;`traded)]} each d1,d1+til 1+d2-d1

The last bit does the magic of creating a list of dates from d1 to d2 (inclusive)

Manish Patel
  • 4,411
  • 4
  • 25
  • 48