Design a program in your favorite programming language that can generate tuples where field values can be unique, have a fixed set of distinct values that are allocated to tuples according to a uniform probability distribution, and a fixed set allocated to the tuples according to a fractal probability distribution (70-30 rule). An example function is pseudocode to do this is as follows:
gen(frac, N)
begin
p:= random permutation of numbers from 1 to N
outvec:= p // so outvec is of length N
while(|p| > 1
p:= first frac*|p| elements of p
concatenate p to outvec
end while
return random permutation of outvec
Execute this program with gen(0.3, x) where x is 70,000 or so (might be more). The idea is to generate an array of 100,000 fractally distributed stock symbols. Populate table trade(stocksymbol, time, quantity, price) such that there are 100,000 stock symbols, quantities uniformly ranging from 100 to 10,000, and prices uniformly ranging between 50 and 500, but for a given stock, successive prices should vary by at least 1 but no more than 5. Time is just a numerical value. The trade table should have 10 million rows with time as the only key.
Next write and time the following queries (send in your typescript file that you get from the script command).
a) Find the weighted (by quantity) average price of each stock over the entire time series.
b) Find the vector of 10 trade unweighted moving averages per stock.
c) Find the vector of 10 trade weighted moving averages per stock.
d) Find the single best buy first/sell later trade you could have done on a single stock (your
e) query should work on our data as well as yours).
Design a program in your favorite programming language that can generate tuples where field values can be unique, have a fixed set of distinct values that are allocated to tuples according to a uniform probability distribution, and a fixed set allocated to the tuples according to a fractal probability distribution (70-30 rule). An example function is pseudocode to do this is as follows:gen(frac, N)beginp:= random permutation of numbers from 1 to Noutvec:= p // so outvec is of length Nwhile(|p| > 1p:= first frac*|p| elements of pconcatenate p to outvecend whilereturn random permutation of outvecExecute this program with gen(0.3, x) where x is 70,000 or so (might be more). The idea is to generate an array of 100,000 fractally distributed stock symbols. Populate table trade(stocksymbol, time, quantity, price) such that there are 100,000 stock symbols, quantities uniformly ranging from 100 to 10,000, and prices uniformly ranging between 50 and 500, but for a given stock, successive prices should vary by at least 1 but no more than 5. Time is just a numerical value. The trade table should have 10 million rows with time as the only key. Next write and time the following queries (send in your typescript file that you get from the script command).Find the weighted (by quantity) average price of each stock over the entire time series.Find the vector of 10 trade unweighted moving averages per stock.Find the vector of 10 trade weighted moving averages per stock.Find the single best buy first/sell later trade you could have done on a single stock (yourquery should work on our data as well as yours).
No comments:
Post a Comment