Calculate Tick Size

Question: The tick size is the minimum prize movement of a trading security. Given the trade table below, calculate and return the tick size for each ticker. The expected columns are sym, ticksize.

More Information:

https://www.investopedia.com/terms/t/tick-size.asp

Example

                                
                                q)trade:([]sym:asc raze 200#`AAPL`IBM;px:raze 200 123 +' 1 5 *\: %[;100]"j"$100*cos ((2*acos -1)%100)*til 100;size:200#100j)
q)trade
sym  px     size
----------------
AAPL 201    100
AAPL 201    100
AAPL 200.99 100
AAPL 200.98 100
AAPL 200.97 100
AAPL 200.95 100
AAPL 200.93 100
AAPL 200.9  100
AAPL 200.88 100
AAPL 200.84 100
AAPL 200.81 100
AAPL 200.77 100
AAPL 200.73 100
AAPL 200.68 100
AAPL 200.64 100
..

==== Expected ====

sym  ticksize
-------------
AAPL 0.01
IBM  0.05
                                
                            

Solution

Tags:
finance math sql tables
Searchable Tags
algorithms api architecture csv data structures dictionaries disk feedhandler finance functions ingestion ipc iterators math multithreading optimizations realtime sql streaming strings tables temporal websockets

Email sent!

Email not sent