
>> On Mon, Jun 20, 2011 at 7:42 AM, <emerson.wu@ubs.com> wrote:
>>
>>> **
>>> Hi, we've been trying to figure out if there is an efficient way to
>>> calculate intraday NAV for ETFs, Indices, etc.
>>>
>>> We have the tick data for all the underlying securities and need to
>>> recompute the NAV with each update of any constituent in the basket.
>>>
>>> The different methods we've come up with are:
>>>
>>> 1) With each quote update, update a dictionary containing the bid/ask of
>>> each constituent and recompute NAV
>>> 2) Multiply the bid/ask time series of each constituent by the
>>> constituent weighting and somehow add the time series together (not sure
>>> how)
>>> 3) Since our tick data only has millisecond granularity, lj each
>>> constituent's bid/ask time series into a table with all possible millisecond
>>> times and do *fills and mmu*
>> Historical data only.  We're hoping to run this over a large list of ETFs,
>> standard indices, customized indices, etc.  There are several hundred ETFs
>> that we'd like to run this on.  Underlying syms will vary by ETF/Index,
>> anywhere from 10 to 3,000.  Number of quotes will depend on the trading
>> day.  For 6/17/11 I see about 72mm quotes for the S&P 500 names.
>>
>
>
> On Mon, Jun 20, 2011 at 10:07 AM, <emerson.wu@ubs.com> wrote:
>
>> **
>> Just tested lj'ing each ticker in S&P 500 keyed on millisecond times, took
>> ~1 sec per name.  Could probably get each day's calculationsdone overnight
>> if we use peach, but wanted to see if there was an even more efficient
>> method.
>>

http://kx.com/q/nav.q


/calc nav for sets of portfolios,ETFs,indices,..

/one day of ([]time;sym;price) sorted by time
n:10000000;S:10000?`4
t:([]time:09:30:00.0+til n;sym:n?S;price:n?1.0)

/calc price deltas once
\t update deltas price by sym from`t

/for each portfolio
a:([sym:-100?S]weight:100?1.0)

r:select time,sums price*weight from(select from t where sym in exec sym
from a),\:a


better with ij:


r:select time,sums price*weight from t ij a
>
>
>
> with 10 million quotes each  100 stock portfolio should take about .1 sec
> so maybe around 1 second per portfolio with 100 million quotes?
>
>
