Can anybody explain what exactly is happening within this function.any help is greatly appreciateddxy:{[d;x;y]first$[0>type x;d(x;y);flip d flip(keys d)!(x;y)]} / utilThanksMike
Got any descritpion of the d;x;y inputs?
Looks like some kind of indexing function for keyed tables and dictionaries. What context is it used in?
It seems d is a table with two key columns, and dxy indexes on thekeys, returning the third column.q)dxy:{[d;x;y]first$[0>type x;d(x;y);flip d flip(keys d)!(x;y)]}q)show a:([p:1 2 3;q:`x`y`z]r:2 3 5;s:`a`b`c)p q| r s—| —1 x| 2 a2 y| 3 b3 z| 5 cq)dxy[a;2;`y]3q)dxy[a;2 3;`y`z]3 5q)dxy[a;2 3;`y`w]3 0N
Apologies for not complete info.Actually this is adjustment implementation on code.kx.com/ put this file in taq// corporate actions: symbol, split and dividend adjustmentssmd:select first sym by cusip,date from mas where not wismd:select from smd where differ sym,(cusip=prev cusip)|cusip=nextcusipsmd:delete cusip from update mas:last sym by cusip from smddxy:{[d;x;y]first$[0>type x;d(x;y);flip d flip(keys d)!(x;y)]} / util/ taq master data should be overridden.msd:s#select by sym,date from smd;MSD:{x^dxy[msd;x;y]} / mas from symsmd:
s#select by mas,date from smd;SMD:{x^dxy[smd;x;y]} / sym from masso in this context what is dxy doing?On Apr 2, 9:30?pm, Chris Burke <cdbu…> wrote:> It seems d is a table with two key columns, and dxy indexes on the> keys, returning the third column.>> q)dxy:{[d;x;y]first$[0>type x;d(x;y);flip d flip(keys d)!(x;y)]}>> q)show a:([p:1 2 3;q:`x`y`z]r:2 3 5;s:`a`b`c)> p q| r s> —| —> 1 x| 2 a> 2 y| 3 b> 3 z| 5 c>> q)dxy[a;2;`y]> 3>> q)dxy[a;2 3;`y`z]> 3 5>> q)dxy[a;2 3;`y`w]> 3 0N</cdbu…>
any help on this please?On Apr 3, 9:35?am, Mike <ejb…> wrote:> Apologies for not complete info.>> Actually this is adjustment implementation on code.kx.com>> / put this file in taq/> / corporate actions: symbol, split and dividend adjustments> smd:select first sym by cusip,date from mas where not wi> smd:select from smd where differ sym,(cusip=prev cusip)|cusip=next> cusip> smd:delete cusip from update mas:last sym by cusip from smd> dxy:{[d;x;y]first$[0>type x;d(x;y);flip d flip(keys d)!(x;y)]} / util>> / taq master data should be overridden.> msd:s#select by sym,date from smd;MSD:{x^dxy[msd;x;y]} / mas from sym> smd:
s#select by mas,date from smd;SMD:{x^dxy[smd;x;y]} / sym from mas>> so in this context what is dxy doing?>> On Apr 2, 9:30?pm, Chris Burke <cdbu…> wrote:>>>> > It seems d is a table with two key columns, and dxy indexes on the> > keys, returning the third column.>> > q)dxy:{[d;x;y]first$[0>type x;d(x;y);flip d flip(keys d)!(x;y)]}>> > q)show a:([p:1 2 3;q:`x`y`z]r:2 3 5;s:`a`b`c)> > p q| r s> > —| —> > 1 x| 2 a> > 2 y| 3 b> > 3 z| 5 c>> > q)dxy[a;2;`y]> > 3>> > q)dxy[a;2 3;`y`z]> > 3 5>> > q)dxy[a;2 3;`y`w]> > 3 0N- Hide quoted text ->> - Show quoted text -</cdbu…></ejb…>
X-Mailer: Apple Mail (2.930.3)
mike,
it is just a simple mapping function that helps retrieving the master
symbol from the current record (sym and date).
try to run the script over a sample set of the taq data and look how
it used in the full context.
felix