Ratios between items

ratios y     ratios[y]

Where y is a non-symbolic sortable list, returns the ratios of the underlying values of consecutive pairs of items of y.

ratios is an aggregate function.

Examples: queries to get returns on prices:

update ret:ratios price by sym from trade
select log ratios price from trade

In a query to get price movements:

update diff:deltas price by sym from trade

With signum to count the number of up/down/same ticks:

q)select count i by signum deltas price from trade
price| x
-----| ----
-1   | 247
0    | 3
1    | 252