Thank you! Your submission has been received!

Oops! Something went wrong while submitting the form

Thank you! Your submission has been received!

Oops! Something went wrong while submitting the form

2

$10- $30

You are given a series of trades. Each trade has a key, a value, a quantity, and a sequence number. For each trade, print the weighted moving average of all the trades for that particular key. Round your average to two decimal places. If the sequence number for any trade TT is less than the sequence number for any previous trade, throw out TT. Do not print anything for TT or factor it into your WMA.

M_{x+1} = {(M_x * Q_x)+(v_{x+1} * q_{x+1}) \over Q_{x+1}}Mx+1=Qx+1(Mx∗Qx)+(vx+1∗qx+1)

Where M = weighted moving average, Q = total quantity, q = current quantity, and v = current value.

0 rating(0 Reviews)